Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added value_display parameter to all *-slider-response plugins and Updated docs #3376

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/plugins/audio-slider-response.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ In addition to the [parameters available in all plugins](../overview/plugins.md#
| 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 listen to the 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 audio is playing. If false, then the audio must finish playing before the slider is enabled and the trial can end via the next button click. Once the audio has played all the way through, the slider is enabled and a response is allowed (including while the audio is being re-played via on-screen playback controls). |
| value_display | boolean | false | If true, the slider's real-time value will be displayed below the slider. The initial value will be specified by the `slider_start` parameter. |

## Data Generated

Expand Down
1 change: 1 addition & 0 deletions docs/plugins/canvas-slider-response.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ prompt | string | null | This string can contain HTML markup. Any content here w
stimulus_duration | numeric | null | How long to display the stimulus in milliseconds. The visibility CSS property of the stimulus will be set to `hidden` after this time has elapsed. If this is null, then the stimulus will remain visible until the trial ends.
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 use this parameter to force the participant to view a stimulus for a fixed amount of time, even if they respond before the time is complete.
value_display | boolean | false | If true, the slider's real-time value will be displayed below the slider. The initial value will be specified by the `slider_start` parameter.

## Data Generated

Expand Down
1 change: 1 addition & 0 deletions docs/plugins/html-slider-response.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ prompt | string | null | This string can contain HTML markup. Any content here w
stimulus_duration | numeric | null | How long to display the stimulus in milliseconds. The visibility CSS property of the stimulus will be set to `hidden` after this time has elapsed. If this is null, then the stimulus will remain visible until the trial ends.
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.
value_display | boolean | false | If true, the slider's real-time value will be displayed below the slider. The initial value will be specified by the `slider_start` parameter.

## Data Generated

Expand Down
1 change: 1 addition & 0 deletions docs/plugins/image-slider-response.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ stimulus_duration | numeric | null | How long to show the stimulus for in millis
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.
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.
value_display | boolean | false | If true, the slider's real-time value will be displayed below the slider. The initial value will be specified by the `slider_start` parameter.

## Data Generated

Expand Down
1 change: 1 addition & 0 deletions docs/plugins/video-slider-response.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,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 slider is enabled and the trial can end via the next button click. Once the video has played all the way through, the slider is enabled and a response is allowed (including while the video is being re-played via on-screen playback controls).
value_display | boolean | false | If true, the slider's real-time value will be displayed below the slider. The initial value will be specified by the `slider_start` parameter.


## Data Generated
Expand Down
16 changes: 15 additions & 1 deletion packages/plugin-audio-slider-response/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,11 @@ const info = <const>{
type: ParameterType.BOOL,
default: true,
},
/** If true, the slider's value will be displayed in real time below the slider. */
value_display: {
type: ParameterType.BOOL,
default: false,
},
},
data: {
/** The numeric value of the slider. */
Expand Down Expand Up @@ -223,7 +228,16 @@ class AudioSliderResponsePlugin implements JsPsychPlugin<Info> {
if (!this.params.response_allowed_while_playing) {
html += " disabled";
}
html += "></input><div>";

// Add real-time value display if enabled
if (this.params.value_display) {
html += ' oninput="this.nextElementSibling.value = this.value"></input>';
html += "<output>" + this.params.slider_start + "</output>";
}else{
html += "></input>";
}
html += "<div>";

for (var j = 0; j < this.params.labels.length; j++) {
var label_width_perc = 100 / (this.params.labels.length - 1);
var percent_of_range = j * (100 / (this.params.labels.length - 1));
Expand Down
13 changes: 12 additions & 1 deletion packages/plugin-canvas-slider-response/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,11 @@ const info = <const>{
array: true,
default: [500, 500],
},
/** If true, the slider's value will be displayed in real time below the slider. */
value_display: {
type: ParameterType.BOOL,
default: false,
},
},
data: {
/** The response time in milliseconds for the participant to make a response. The time is measured from when the stimulus first appears on the screen until the participant's response. */
Expand Down Expand Up @@ -132,7 +137,13 @@ class CanvasSliderResponsePlugin implements JsPsychPlugin<Info> {
trial.max +
'" step="' +
trial.step +
'" style="width: 100%;" id="jspsych-canvas-slider-response-response"></input>';
'" style="width: 100%;" id="jspsych-canvas-slider-response-response"> ';
if (trial.value_display) {
html += 'oninput="this.nextElementSibling.value = this.value"></input>';
html += "<output>" + trial.slider_start + "</output>";
}else{
html += "></input>";
}
html += "<div>";
for (var j = 0; j < trial.labels.length; j++) {
var width = 100 / (trial.labels.length - 1);
Expand Down
14 changes: 13 additions & 1 deletion packages/plugin-html-slider-response/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,12 @@ const info = <const>{
type: ParameterType.BOOL,
default: true,
},
/** If true, the slider's value will be displayed in real time below the slider. */
value_display: {
type: ParameterType.BOOL,
default: false,
},

},
data: {
/** The time in milliseconds for the participant to make a response. The time is measured from when the stimulus first appears on the screen until the participant's response. */
Expand Down Expand Up @@ -129,7 +135,13 @@ class HtmlSliderResponsePlugin implements JsPsychPlugin<Info> {
trial.max +
'" step="' +
trial.step +
'" id="jspsych-html-slider-response-response"></input>';
'" id="jspsych-html-slider-response-response" ';
if (trial.value_display) {
html += 'oninput="this.nextElementSibling.value = this.value"></input>';
html += "<output>" + trial.slider_start + "</output>";
}else{
html += "></input>";
}
html += "<div>";
for (var j = 0; j < trial.labels.length; j++) {
var label_width_perc = 100 / (trial.labels.length - 1);
Expand Down
13 changes: 12 additions & 1 deletion packages/plugin-image-slider-response/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,11 @@ const info = <const>{
type: ParameterType.BOOL,
default: true,
},
/** If true, the slider's value will be displayed in real time below the slider. */
value_display: {
type: ParameterType.BOOL,
default: false,
},
},
data: {
/** The path of the image that was displayed. */
Expand Down Expand Up @@ -222,7 +227,13 @@ class ImageSliderResponsePlugin implements JsPsychPlugin<Info> {
trial.max +
'" step="' +
trial.step +
'" id="jspsych-image-slider-response-response"></input>';
'" id="jspsych-image-slider-response-response"> ';
if (trial.value_display) {
html += 'oninput="this.nextElementSibling.value = this.value"></input>';
html += "<output>" + trial.slider_start + "</output>";
}else{
html += "></input>";
}
html += "<div>";
for (var j = 0; j < trial.labels.length; j++) {
var label_width_perc = 100 / (trial.labels.length - 1);
Expand Down
16 changes: 15 additions & 1 deletion packages/plugin-video-slider-response/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,11 @@ const info = <const>{
type: ParameterType.BOOL,
default: true,
},
/** If true, the slider's value will be displayed in real time below the slider. */
value_display: {
type: ParameterType.BOOL,
default: false,
},
},
data: {
/** The numeric value of the slider. */
Expand Down Expand Up @@ -265,7 +270,16 @@ class VideoSliderResponsePlugin implements JsPsychPlugin<Info> {
if (!trial.response_allowed_while_playing) {
html += " disabled";
}
html += "></input><div>";

// Add real-time value display if enabled
if (trial.value_display) {
html += ' oninput="this.nextElementSibling.value = this.value"></input>';
html += "<output>" + trial.slider_start + "</output>";
}else{
html += "></input>";
}
html += "<div>";

for (var j = 0; j < trial.labels.length; j++) {
var label_width_perc = 100 / (trial.labels.length - 1);
var percent_of_range = j * (100 / (trial.labels.length - 1));
Expand Down