-
I wanted to insert a variable in a likert scale question and the variable was previously stored in the data. I had the following code: var test_trial = {
type: 'survey-multi-select',
questions: jsPsych.timelineVariable('questions'),
data:{
trial_part: 'test',
questions: jsPsych.timelineVariable('questions'),
correct_response: jsPsych.timelineVariable('correct_response'),
},
on_finish: function(data) {
var name = data.questions[0].name
data.name = name;
}
};
var scale_1 = [
"1",
"2",
"3",
"4",
"5"
];
var likert_page = {
type: 'survey-likert',
questions: [
{
prompt: function() {
var name = jsPsych.data.getLastTrialData().values()[0].name;
var text = "How familiar are you with the word "+name+"?"
return text;
}, labels: scale_1}
]
};
var test = {
timeline: [test_trial, likert_page],
timeline_variables: stimuli_info,
}
timeline.push(test) The whole function in the likert scale page was printed as text, i.e. the out put was " function() { var name=jsPsych.data.getLastTrialData().values()[0].name; var text = "How familiar are you with the word "+name+"?" return text;". I would appreciate it very much if someone could point out what I did wrong with the code. Thank you! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Hi @y-j-huang, Can you try updating to jsPsych 6.3.0? Previous versions of jsPsych didn't have support for using functions in nested parameters, but we added it in 6.3.0. |
Beta Was this translation helpful? Give feedback.
Hi @y-j-huang,
Can you try updating to jsPsych 6.3.0? Previous versions of jsPsych didn't have support for using functions in nested parameters, but we added it in 6.3.0.