Modifying datafile
#2647
-
My experiment utilizes the html_button_response plugin and I'm trying to change the contents of the datafile to show the actual button contents participants select, instead of 0 or 1. Here is the code with the button choices array and test variable:
I would appreciate any help on this! |
Beta Was this translation helpful? Give feedback.
Answered by
jodeleeuw
May 26, 2022
Replies: 1 comment
-
Hi @au-justin, You can modify the data stored for a trial in the var test_stimuli = [
{stimulus: images[0], choices: ['one', 'two']}, // 1
{stimulus: images[1], choices: ['ten', 'twenty']}, // 2
];
var test = {
type: jsPsychImageButtonResponse,
stimulus: jsPsych.timelineVariable('stimulus'),
choices: jsPsych.timelineVariable('choices'),
button_html: [
'<button class="jspsych-btn" style = "position: relative; left: -50px; top: 100px; font-size: 40px; height: 200px; width: 250px">%choice%</button>',
'<button class="jspsych-btn" style = "position: relative; left: 50px; top: 100px; font-size: 40px; height: 200px; width: 250px">%choice%</button>',
],
data: {
task: 'response'
},
on_finish: (data) => {
data.response = jsPsych.timelineVariable('choices')[data.response];
}
} This grabs the |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
au-justin
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi @au-justin,
You can modify the data stored for a trial in the
on_finish
event. Something like this should work: