Problems with modified image-button-response #2456
-
Hi! I'm having a couple of problems with a plugin that I made by modifying the image-button-response plugin. Following @becky-gilbert 's advice, I put in some code to add a skip/"I don't know" button which would appear for the users after a minute. I'm having two issues with this code (but they are not giving me any errors that I can see):
I've attached my plugin as a .txt file, and I've included my test trial procedure and an example of trial data for one of my test trials below. I'd appreciate any help that people can offer! Thanks, Test trial procedure: var test = {
type: jsPsychOddOneOut,
stimulus: jsPsych.timelineVariable('stimulus'),
choices: function(){
return jsPsych.randomization.shuffle(jsPsych.timelineVariable('choices'));
},
button_html: '<img src="img/images/%choice%.jpg" style="width:30vw; border:2px solid #000000;" onclick=badading.play() />',
prompt: '<span style="font-size:2vw;">Click the image that you think does not belong.</span>', // THIS DOES NOT APPEAR
data: jsPsych.timelineVariable('data'),
save_trial_parameters: {
choices: true // save the randomly-selected button order to the trial data
},
post_trial_gap: 600, // inserted to allow the image button noise to finish
} Example trial data: {
stimulus: '',
choices: [
'brake/brake_01b',
'needle/needle_01s',
'float/float_01b',
],
data: {
bin_number: 'Interval 0.2-0.3',
pair_number: '13',
triplet_index: '3406755',
test_part: 'test',
odd_one_out: 'float',
},
}, |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
Hi @kburkin, html += '<div class="jspsych-odd-one-out-button" style="display:block; position:fixed; width:13vw; left:calc(90vw - 8.5vw); bottom:0; margin:2vw" id="skip-button" data-choice="unsure"><button class="jspsych-btn" style="visibility:hidden;" onclick=bloop.play()>'+"I don't know >"+'</button></div>';
display_element.innerHTML = html; the last line above is removing some content that had been added to the page already. One confusing thing about the image-* plugins is that the content is added to the page in two different ways, depending on whether So one thing you could try is just using Or if you want to keep using the canvas rendering method, you could change your code so that the "don't know" button is added to the bottom of the existing page content like this: var unsure_button = '<div class="jspsych-odd-one-out-button" style="display:block; position:fixed; width:13vw; left:calc(90vw - 8.5vw); bottom:0; margin:2vw" id="skip-button" data-choice="unsure"><button class="jspsych-btn" style="visibility:hidden;" onclick=bloop.play()>'+"I don't know >"+'</button></div>';
display_element.insertAdjacentHTML("beforeend", unsure_button); Does that help? |
Beta Was this translation helpful? Give feedback.
-
Oh and for your second question, the value of the data-choice attribute is an integer for all of the normal response buttons, but for your "don't know" button it's a string (unsure). In the response.button = parseInt(choice) When if (choice === "unsure") {
response.button = choice;
} else {
response.button = parseInt(choice);
} |
Beta Was this translation helpful? Give feedback.
Hi @kburkin,
I'm not sure, but I think the problem with your plugin code is that in this part:
the last line above is removing some content that had been added to the page already. One confusing thing about the image-* plugins is that the content is added to the page in two different ways, depending on whether
render_on_canvas
is true or false. If it's true (the …