diff --git a/.changeset/slimy-planets-change.md b/.changeset/slimy-planets-change.md new file mode 100644 index 0000000000..b347790a26 --- /dev/null +++ b/.changeset/slimy-planets-change.md @@ -0,0 +1,8 @@ +--- +"@jspsych/plugin-audio-button-response": minor +"@jspsych/plugin-html-button-response": minor +"@jspsych/plugin-image-button-response": minor +"@jspsych/plugin-video-button-response": minor +--- + +Issue (#3289), Add parameter "enable_button_after" to all "-button-response" plugins diff --git a/contributors.md b/contributors.md index 7e68072cca..f43ac2e539 100644 --- a/contributors.md +++ b/contributors.md @@ -60,4 +60,5 @@ The following people have contributed to the development of jsPsych by writing c * Erik Weitnauer - https://github.com/eweitnauer * Rob Wilkinson - https://github.com/RobAWilkinson * Andy Woods - https://github.com/andytwoods -* Reto Wyss - https://github.com/retowyss \ No newline at end of file +* Reto Wyss - https://github.com/retowyss +* Haotian Tu - https://github.com/thtTNT \ No newline at end of file diff --git a/docs/plugins/audio-button-response.md b/docs/plugins/audio-button-response.md index a7e07d6e57..b73fc6b7cb 100644 --- a/docs/plugins/audio-button-response.md +++ b/docs/plugins/audio-button-response.md @@ -26,6 +26,7 @@ In addition to the [parameters available in all plugins](../overview/plugins.md# | response_ends_trial | boolean | true | If true, then the trial will end whenever the participant makes a response (assuming they make their response before the cutoff specified by the `trial_duration` parameter). If false, then the trial will continue until the value for `trial_duration` is reached. You can set this parameter to `false` to force the participant to listen to the stimulus for a fixed amount of time, even if they respond before the time is complete. | | trial_ends_after_audio | boolean | false | If true, then the trial will end as soon as the audio file finishes playing. | | response_allowed_while_playing | boolean | true | If true, then responses are allowed while the audio is playing. If false, then the audio must finish playing before the button choices are enabled and a response is accepted. Once the audio has played all the way through, the buttons are enabled and a response is allowed (including while the audio is being re-played via on-screen playback controls). | +| enable_button_after | numeric | 0 | How long the button will delay enabling in milliseconds. If `response_allowed_while_playing` is `true`, the timer will start immediately. If it is `false`, the timer will start at the end of the audio. | ## Data Generated diff --git a/docs/plugins/html-button-response.md b/docs/plugins/html-button-response.md index 69f9978b01..5953a19925 100644 --- a/docs/plugins/html-button-response.md +++ b/docs/plugins/html-button-response.md @@ -19,6 +19,7 @@ stimulus_duration | numeric | null | How long to display the stimulus in millise margin_vertical | string | '0px' | Vertical margin of the button(s). margin_horizontal | string | '8px' | Horizontal margin of the button(s). response_ends_trial | boolean | true | If true, then the trial will end whenever the participant makes a response (assuming they make their response before the cutoff specified by the `trial_duration` parameter). If false, then the trial will continue until the value for `trial_duration` is reached. You can set this parameter to `false` to force the participant to view a stimulus for a fixed amount of time, even if they respond before the time is complete. +enable_button_after | numeric | 0 | How long the button will delay enabling in milliseconds. ## Data Generated diff --git a/docs/plugins/image-button-response.md b/docs/plugins/image-button-response.md index 2060b461ec..e01c15c5dd 100644 --- a/docs/plugins/image-button-response.md +++ b/docs/plugins/image-button-response.md @@ -25,6 +25,7 @@ margin_vertical | string | '0px' | Vertical margin of the button(s). margin_horizontal | string | '8px' | Horizontal margin of the button(s). response_ends_trial | boolean | true | If true, then the trial will end whenever the participant makes a response (assuming they make their response before the cutoff specified by the `trial_duration` parameter). If false, then the trial will continue until the value for `trial_duration` is reached. You can set this parameter to `false` to force the participant to view a stimulus for a fixed amount of time, even if they respond before the time is complete. render_on_canvas | boolean | true | If true, the image will be drawn onto a canvas element. This prevents a blank screen (white flash) between consecutive image trials in some browsers, like Firefox and Edge. If false, the image will be shown via an img element, as in previous versions of jsPsych. If the stimulus is an **animated gif**, you must set this parameter to false, because the canvas rendering method will only present static images. +enable_button_after | numeric | 0 | How long the button will delay enabling in milliseconds. ## Data Generated diff --git a/docs/plugins/video-button-response.md b/docs/plugins/video-button-response.md index 3aa9dc27dc..f88c9ffb07 100644 --- a/docs/plugins/video-button-response.md +++ b/docs/plugins/video-button-response.md @@ -29,6 +29,7 @@ trial_ends_after_video | bool | false | If true, then the trial will end as soon trial_duration | numeric | null | How long to wait for the participant to make a response before ending the trial in milliseconds. If the participant fails to make a response before this timer is reached, the participant's response will be recorded as null for the trial and the trial will end. If the value of this parameter is null, then the trial will wait for a response indefinitely. response_ends_trial | boolean | true | If true, then the trial will end whenever the participant makes a response (assuming they make their response before the cutoff specified by the `trial_duration` parameter). If false, then the trial will continue until the value for `trial_duration` is reached. You can set this parameter to `false` to force the participant to view a stimulus for a fixed amount of time, even if they respond before the time is complete. response_allowed_while_playing | boolean | true | If true, then responses are allowed while the video is playing. If false, then the video must finish playing before the button choices are enabled and a response is accepted. Once the video has played all the way through, the buttons are enabled and a response is allowed (including while the video is being re-played via on-screen playback controls). +enable_button_after | numeric | 0 | How long the button will delay enabling in milliseconds. If `response_allowed_while_playing` is `true`, the timer will start immediately. If it is `false`, the timer will start at the end of the video. ## Data Generated diff --git a/examples/jspsych-audio-button-response.html b/examples/jspsych-audio-button-response.html index d42de17549..8f99a5146d 100644 --- a/examples/jspsych-audio-button-response.html +++ b/examples/jspsych-audio-button-response.html @@ -55,6 +55,24 @@ response_allowed_while_playing: false }) + timeline.push({ + type: jsPsychAudioButtonResponse, + stimulus: 'sound/speech_joke.mp3', + choices: ['Not funny', 'Funny'], + prompt: '
Is the joke funny?
Click a button to end the trial.
Response buttons are disabled for the first 2 seconds of playing.
', + response_allowed_while_playing: true, + enable_button_after: 2000 + }) + + timeline.push({ + type: jsPsychAudioButtonResponse, + stimulus: 'sound/speech_joke.mp3', + choices: ['Not funny', 'Funny'], + prompt: 'Is the joke funny?
When the audio stops, click a button to end the trial.
Response buttons are enabled 2 seconds after the end of playing.
', + response_allowed_while_playing: false, + enable_button_after: 2000 + }) + jsPsych.run(timeline); diff --git a/examples/jspsych-html-button-response.html b/examples/jspsych-html-button-response.html index 6cce713788..e681fb5cb0 100644 --- a/examples/jspsych-html-button-response.html +++ b/examples/jspsych-html-button-response.html @@ -40,6 +40,14 @@ prompt: "What color is this word? (trial ends after 2s)
" }); + timeline.push({ + type: jsPsychHtmlButtonResponse, + stimulus: 'GREEN
', + choices: ['Green', 'Blue', 'Red'], + enable_button_after: 2000, + prompt: "What color is this word? (button enable after 2s)
" + }); + jsPsych.run(timeline); diff --git a/examples/jspsych-image-button-response.html b/examples/jspsych-image-button-response.html index 0c7762d49a..57c046e5dd 100644 --- a/examples/jspsych-image-button-response.html +++ b/examples/jspsych-image-button-response.html @@ -88,6 +88,15 @@ post_trial_gap: 500 }); + timeline.push({ + type: jsPsychImageButtonResponse, + stimulus: 'img/happy_face_1.jpg', + choices: ['Happy', 'Sad'], + enable_button_after: 2000, + prompt: "What emotion is this person showing? (button enable after 2s)
", + post_trial_gap: 500 + }); + jsPsych.run(timeline); diff --git a/examples/jspsych-video-button-response.html b/examples/jspsych-video-button-response.html index 2e57464df7..335eb0ec37 100644 --- a/examples/jspsych-video-button-response.html +++ b/examples/jspsych-video-button-response.html @@ -62,7 +62,22 @@ response_allowed_while_playing: false }; - jsPsych.run([preload, pre_trial, trial_1, trial_2]); + var trail_3 = { + type: jsPsychVideoButtonResponse, + stimulus: ['video/sample_video.mp4'], + choices: ['😄','😁','🥱','😣','🤯'], + button_html: 'Click the emoji that best represents your reaction to the video
Click a button to end the trial.
Response buttons are disabled for the first 2 seconds of playing.
', + width: 600, + autoplay: true, + response_ends_trial: true, + response_allowed_while_playing: true, + enable_button_after: 2000 + } + + jsPsych.run([preload, pre_trial, trial_1, trial_2, trail_3]);