- Posts: 1
- Thank you received: 0
Welcome to the LimeSurvey Community Forum
Ask the community, share ideas, and connect with other LimeSurvey users!
lab.js integration
- sdyckfr
- Topic Author
- Offline
- New Member
Could anyone help me out with how to set up the JavaScript in LS to data from the lab.js experiment in a hidden textarea within LS?
The description for Qualtrics uses an "embedded data field" in Qualtrics, which - to my understanding - Limesurvey does not have. The lab.js experiment is embeded in an iframe. The following code is used for connecting lab.js and the qualtrics "embedded data field".
// Listen for the study sending data window.addEventListener('message', function(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 const data = event.data.json // ... save data and submit page Qualtrics.SurveyEngine.setEmbeddedData('labjs-data', data) document.querySelector('.NextButton').click() } })
- Skyler9
- Offline
- New Member
- Posts: 1
- Thank you received: 0
sdyckfr wrote: I have an experimental video segmentation task set up with lab.js ( lab.js.org ) and want to integrate it in LS (3.20.2+191119) similar to how the lab.js developers describe its integration with Qualtrics ( labjs.readthedocs.io/en/latest/learn/deploy/3a-qualtrics.html ).
Could anyone help me out with how to set up the JavaScript in LS to data from the lab.js experiment in a hidden textarea within LS?
The description for Qualtrics uses an "embedded data field" in Qualtrics, which - to my understanding - Limesurvey does not have. The lab.js experiment is embeded in an iframe. The following code is used for connecting lab.js and the qualtrics "embedded data field".
Code:// Listen for the study sending data window.addEventListener('message', function(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 const data = event.data.json // ... save data and submit page Qualtrics.SurveyEngine.setEmbeddedData('labjs-data', data) document.querySelector('.NextButton').click() } })
Its important to understand that running a controlled experiment on an algorithm that is so complex is nearly if not completely impossible. Thousands of variables are at play and it’s our job to try and minimise those variables to the best of our abilities. By doing so, we have to restrict the questions we may be able to answer to their simplest form. Only by doing that we may get some meaningful answers.
- DenisChenu
- Offline
- LimeSurvey Community Team
- Posts: 13597
- Thank you received: 2487
2. Add javascript : labjs.readthedocs.io/en/latest/learn/deploy/3-third-party.html
3. Fill the input with data $("answer{SGQ}").val(theData) using jquery
See manual.limesurvey.org/Workarounds:_Manip...ime_using_Javascript
If you want a more automatic system : check manual.limesurvey.org/BeforeQuestionRender
Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member, professional service on demand , plugin development .
I don't answer to private message.