Welcome to the LimeSurvey Community Forum

Ask the community, share ideas, and connect with other LimeSurvey users!

lab.js integration

  • sdyckfr
  • sdyckfr's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
4 years 4 months ago - 4 years 4 months ago #191504 by sdyckfr
lab.js integration was created by sdyckfr
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()
  }
})
Last edit: 4 years 4 months ago by sdyckfr.
The topic has been locked.
More
4 years 3 months ago #192129 by Skyler9
Replied by Skyler9 on topic lab.js integration

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.
The topic has been locked.
  • DenisChenu
  • DenisChenu's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
4 years 3 months ago #192142 by DenisChenu
Replied by DenisChenu on topic lab.js integration
1. Add a text question to store the data
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.
The topic has been locked.

Lime-years ahead

Online-surveys for every purse and purpose