jspsych / jsPsych

Create behavioral experiments in a browser using JavaScript
http://www.jspsych.org
MIT License
1.04k stars 678 forks source link

[Feature Add] Add a new attribute to allow the plugin "html-button-response" to delay the display of the button #3289

Closed thtTNT closed 6 months ago

thtTNT commented 6 months ago

Hi JsPsych Amazing Team,

Recently, our project team asked us to delay the display of a button, For example, participants were asked to recall something and were only allowed to click the button after 30 seconds.

I think this is a pretty common request in psychology experiments, so I'd like to add an attribute to do this, what do you think?

I can do that, and if you allow me to do that, what would you like the attribute to be called?

jodeleeuw commented 6 months ago

Hey @thtTNT,

The way that I would do this currently is to stack two trials sequentially (one with a fixed trial_duration and no response option, the second with a button). But I can see the value in making this easier to do.

Do you imagine having the buttons disabled or the buttons hidden? My instinct is that disabled is a better default, but if there's a good reason for them to be hidden I'm open to considering.

enable_buttons_after or show_buttons_after could be clear parameter names.

If you add this to html-button-response would you be willing to add it to all the other -button-response plugins for consistency?

thtTNT commented 6 months ago

Hi @jodeleeuw ,

Thank you for your prompt reply.

I'm working on "audio-button-response" and "video-button-response" but the problem is that they already have a attribute called "response_allowed_while_playing". So What I plan to do is that start the timer of delay only after the playback is over.

Please allow me to confirm this to you. If you don't think this is a good idea, please let me know.

jodeleeuw commented 6 months ago

That's tricky! I think if response_allowed_while_playing is true then the timer should start right away. Does that match your intuition?

anasophiarc commented 6 months ago

Hi @thtTNT I am a student who is new to jsPsych and I really want to use your attribute for a video button response trial (it would make it difficult to stack 2 trials seamlessly). Would u mind briefly explaining how I could include your attribute into my work?

thtTNT commented 6 months ago

Hi @anasophiarc, so happy to see my work help you. It's a good start that checking the document of each plugin (https://www.jspsych.org/7.3/plugins/html-button-response/) I don't think here is a good place to talk about this. Maybe you can create a new issue with more detail? That's really helpful for me.

anasophiarc commented 6 months ago

Hi @thtTNT I can do that! I guess my main question is what I have to include in my script to be able to use your attribute. Right now I have as one of the plugins included at the top of my script. And then in my trial I am trying to use the attribute - is this all I need to do to use the attribute?

var cue = { type: jsPsychVideoButtonResponse, stimulus: jsPsych.timelineVariable('video'), choices: ['Blast'], enable_button_after: 1000, //this is the feature I want to add ==> Not sure if another plugin is needed? response_allowed_while_playing: true, response_ends_trial: true, trial_ends_after_video: true, width: 800, height: 450 }

thtTNT commented 6 months ago

@anasophiarc, I think you have already found the problem. The 'enable_button_after' attribute is only available in 1.2.0+. So upgrade the plugin should help you.