Skip to content
This repository has been archived by the owner on Nov 22, 2022. It is now read-only.

Commit

Permalink
Update Qualtrics integration code to consistently use the survey API
Browse files Browse the repository at this point in the history
  • Loading branch information
FelixHenninger committed Feb 15, 2020
1 parent 835cb43 commit 585a827
Showing 1 changed file with 8 additions and 10 deletions.
18 changes: 8 additions & 10 deletions docs/learn/deploy/3a-qualtrics.rst
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,6 @@ Because the data is saved in the embedded field you set up above, the study is b

<!-- Adjust the page style slightly -->
<style>
/* Hide button for skipping the page */
.NextButton {
visibility: hidden;
}
/* Remove border from last question */
.QuestionOuter:last-of-type .QuestionText {
border: none;
Expand All @@ -67,18 +63,20 @@ To achieve the connection, you'll need to add JavaScript logic to the `Descripti

.. code-block:: JS
const page = this
page.hideNextButton()
// Listen for the study sending data
window.addEventListener('message', function(event) {
window.addEventListener('message', function _labjs_data_handler(event) {
// Make sure that the event is from lab.js, then ...
if (event.data.type === 'labjs.data') {
// ... extract the data lab.js is sending.
// We're going to work with JSON data
// ... extract the JSON data lab.js is sending.
const data = event.data.json
// ... save data and submit page
Qualtrics.SurveyEngine.setEmbeddedData('labjs-data', data)
document.querySelector('.NextButton').click()
page.setEmbeddedData('labjs-data', data)
window.removeEventListener('message', _labjs_data_handler)
page.clickNextButton()
}
})
Expand Down

0 comments on commit 585a827

Please sign in to comment.