You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi everybody,
I have a timeline with a language selection trial at the beginning. After that trial, I have 3 almost identical timeline versions, with some language modifications in their texts (prompts). I"'m trying to code my script so after the language selection there will be a switching function that will push the correct timeline according to the user's selection. this is my code for the timeline selection:
"var switchTimeline = {
type: jsPsychCallFunction,
func: function() {
var languageCode = jsPsych.data.get().last(1).values()[0].language; // Retrieve the language code from the last trial's data
if (languageCode === 1) {
timeline.push(...timelineMALE);
} else if (languageCode === 2) {
timeline.push(...timelineFEMALE);
} else if (languageCode === 3 || languageCode === null) {
timeline.push(...timelineOTHER);
} else {
console.error("Invalid language code:", languageCode);
}
}
};
timeline.push(switchTimeline);"
As you can see, after the user selects a language, it is coded as 1, 2, or 3. In the switchTimeline element, I try to continue the experiment with the corresponding timeline (timelineMALE for 1, timelineFEMALE for 2, and timelineOTHER for 3 or not answering).
I have also tried a different switch function:
"var switchTimeline = {
type: jsPsychCallFunction,
func: function() {
var languageCode = jsPsych.data.get().last(1).values()[0].language; // Retrieve the language code
switch (languageCode) {
case '1':
timeline.push(...timelineMALE);
break;
case '2':
timeline.push(...timelineFEMALE);
break;
case '3':
timeline.push(...timelineOTHER);
break;
default:
console.error("Invalid language code:", languageCode);
}
}
};
timeline.push(switchTimeline);"
Unfortunately, after this language selection trial, the screen stays blank and the experiment gets stuck.
I would appreciate any help. Thanks!
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Hi everybody,
I have a timeline with a language selection trial at the beginning. After that trial, I have 3 almost identical timeline versions, with some language modifications in their texts (prompts). I"'m trying to code my script so after the language selection there will be a switching function that will push the correct timeline according to the user's selection. this is my code for the timeline selection:
"var switchTimeline = {
type: jsPsychCallFunction,
func: function() {
var languageCode = jsPsych.data.get().last(1).values()[0].language; // Retrieve the language code from the last trial's data
if (languageCode === 1) {
timeline.push(...timelineMALE);
} else if (languageCode === 2) {
timeline.push(...timelineFEMALE);
} else if (languageCode === 3 || languageCode === null) {
timeline.push(...timelineOTHER);
} else {
console.error("Invalid language code:", languageCode);
}
}
};
timeline.push(switchTimeline);"
As you can see, after the user selects a language, it is coded as 1, 2, or 3. In the switchTimeline element, I try to continue the experiment with the corresponding timeline (timelineMALE for 1, timelineFEMALE for 2, and timelineOTHER for 3 or not answering).
Beta Was this translation helpful? Give feedback.
All reactions