Loop_function for SurveyMultiChoice #3290
Replies: 1 comment
-
Hi @DondersCitylab, I think one problem is that inside your In your code, the data argument that's passed into the loop function is called loop_function: function (allData) {
if (allData.values()[0].response == {Q0: 'I would like to see the animation again before I can answer'}) {
return true; // loop again
} else {
return false; // continue
}
} And I don't know for sure if this is the case in your code, but you might also have a problem with the way that you're trying to access the participant's response from the last timeline loop. If so, one trick is to print the value of the data collection that's passed into the loop function to the console, so that you can see how it's structured: loop_function: function (allData) {
console.log("last loop data: ", allData.values());
// ... etc ...
} Since you have two trials in the timeline that you're looping over ( Does that help? |
Beta Was this translation helpful? Give feedback.
-
Hi all,
I am trying to create a loop when a certain answer is given. Participants will see an animation and then they get a multichoice question in which they can select to see the animation again. If they choose to see the animation again, they will get the question again after the animation. However, I can't get the loop_function to work. With the code below it'll repeat the animation & question once regardless of the answer. Then I get the following error:
loop_test.html:136 Uncaught ReferenceError: data is not defined
at Object.loop_function (loop_test.html:136:13)
at TimelineNode.advance (jspsych.js:2431:49)
at TimelineNode.advance (jspsych.js:2394:99)
at JsPsych.nextTrial (jspsych.js:3040:44)
at onExtensionCallbacksFinished (jspsych.js:2846:30)
at JsPsych.finishTrial (jspsych.js:2871:17)
at HTMLFormElement. (plugin-survey-multi-choice.js:214:28)
I am using JsPsych version 7.3. My experiment will be both in English and Dutch. I started to do the loop just for the English version but will eventually make it for both languages.
Any help would be greatly appreciated!
Beta Was this translation helpful? Give feedback.
All reactions