feedback problem #2195
-
Hi there. var image_trial = {
type: 'image-button-response',
stimulus: 'img/b/004_o_m_s_b.jpeg',
choices: ['sad', 'frightened', 'neutral','angry','disgusting','happy'],
data: {
stimulus_type: 'image'
},
on_finish: function(data){
if(jsPsych.pluginAPI.compareKeys(data.response, "sad")){
data.correct = true;
} else {
data.correct = false;
}
}
}
var feedback = {
type: 'instructions',
stimulus: function(){
var last_trial_correct = jsPsych.data.get().last(1).values()[0].correct;
if(last_trial_correct){
return "<p>Correct!</p>";
} else {
return "<p>Wrong!... The correct answer was 'sad'.</p>";
show_clickable_nav; true,
button_label_previous; 'previous',
button_label_next; '<h2>next</h2>'
}
}
}
timeline.push(image_trial, feedback); |
Beta Was this translation helpful? Give feedback.
Answered by
becky-gilbert
Oct 4, 2021
Replies: 1 comment 3 replies
-
Hi @mary-9555, can you say more about what's happening when you run the code? Are you seeing any errors in the browser's JavaScript console? I did notice a few things:
Also, if you do want to stick with the
var feedback = {
type: 'instructions',
pages: function(){
var last_trial_correct = jsPsych.data.get().last(1).values()[0].correct;
if(last_trial_correct){
return ["<p>Correct!</p>"];
} else {
return ["<p>Wrong!... The correct answer was 'sad'.</p>"];
}
},
show_clickable_nav: true,
button_label_previous: 'previous',
button_label_next: '<h2>next</h2>'
} |
Beta Was this translation helpful? Give feedback.
3 replies
Answer selected by
mary-9555
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi @mary-9555, can you say more about what's happening when you run the code? Are you seeing any errors in the browser's JavaScript console?
I did notice a few things:
jsPsych.pluginAPI.compareKeys
function is just meant for comparing keyboard responses, not button responses. So in yourimage_trial
, you should compare the participant's response and correct response directly in theon_finish
function. The participant's button response is stored using the indices in thechoices
array, and in your case "sad" is the first button choice (index = 0), so you want to check if the response was "sad" like this:if (data.response == 0) { ...
feedback
trial, using theinstructions
plugin…