-
Hi, I'm still a beginner in jsPsych. Does anyone know how to randomise button positions (left/right) with the html-button-response plugin? I just couldn't get it work. Thank you very much in advance! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 3 replies
-
Hi @mw719 , The button order is determined by the order in the var trial = {
type: 'html-button-response',
stimulus: 'Pick one.',
choices: jsPsych.randomization.shuffle(['Option One', 'Option Two'])
} The trouble with this is that you need to know the button order to know which one was pressed. You can solve this by saving the button order in the trial's data like this: var trial = {
type: 'html-button-response',
stimulus: 'Pick one.',
choices: jsPsych.randomization.shuffle(['Option One', 'Option Two']),
on_start: function(params){
params.data.button_order = JSON.stringify(params.choices);
}
} The above method uses the You could then save the label of the button clicked in the data when the trial finishes: var trial = {
type: 'html-button-response',
stimulus: 'Pick one.',
choices: jsPsych.randomization.shuffle(['Option One', 'Option Two']),
on_start: function(params){
params.data.button_order = JSON.stringify(params.choices);
},
on_finish: function(data){
var button_order = JSON.parse(data.button_order);
data.button_pressed_label = button_order[data.button_pressed]
}
} |
Beta Was this translation helpful? Give feedback.
Hi @mw719 ,
The button order is determined by the order in the
choices
array, so you canshuffle()
the array to get a random order.The trouble with this is that you need to know the button order to know which one was pressed. You can solve this by saving the button order in the trial's data like this:
The above method …