Skip to content

Commit 4425aab

Browse files
committed
Added value_display parameter to all *-slider-response plugins and Updated docs
Added `value_display` parameter to all `slider_response` plugins and updated docs: if the parameter value_display is set as true, the slider's value will be displayed in real-time below the slider as participants adjust it. Before participants adjust the slider, the displayed value will be the slider_start value
1 parent 87cf4bf commit 4425aab

File tree

10 files changed

+72
-5
lines changed

10 files changed

+72
-5
lines changed

docs/plugins/audio-slider-response.md

+1
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ In addition to the [parameters available in all plugins](../overview/plugins.md#
2929
| 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. |
3030
| 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. |
3131
| 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). |
32+
| 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. |
3233

3334
## Data Generated
3435

docs/plugins/canvas-slider-response.md

+1
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ prompt | string | null | This string can contain HTML markup. Any content here w
2424
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.
2525
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.
2626
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.
27+
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.
2728

2829
## Data Generated
2930

docs/plugins/html-slider-response.md

+1
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ prompt | string | null | This string can contain HTML markup. Any content here w
2323
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.
2424
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.
2525
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.
26+
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.
2627

2728
## Data Generated
2829

docs/plugins/image-slider-response.md

+1
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ stimulus_duration | numeric | null | How long to show the stimulus for in millis
2929
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.
3030
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.
3131
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.
32+
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.
3233

3334
## Data Generated
3435

docs/plugins/video-slider-response.md

+1
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ trial_ends_after_video | bool | false | If true, then the trial will end as soon
3333
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.
3434
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.
3535
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).
36+
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.
3637

3738

3839
## Data Generated

packages/plugin-audio-slider-response/src/index.ts

+15-1
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,11 @@ const info = <const>{
9696
type: ParameterType.BOOL,
9797
default: true,
9898
},
99+
/** If true, the slider's value will be displayed in real time below the slider. */
100+
value_display: {
101+
type: ParameterType.BOOL,
102+
default: false,
103+
},
99104
},
100105
data: {
101106
/** The numeric value of the slider. */
@@ -223,7 +228,16 @@ class AudioSliderResponsePlugin implements JsPsychPlugin<Info> {
223228
if (!this.params.response_allowed_while_playing) {
224229
html += " disabled";
225230
}
226-
html += "></input><div>";
231+
232+
// Add real-time value display if enabled
233+
if (this.params.value_display) {
234+
html += ' oninput="this.nextElementSibling.value = this.value"></input>';
235+
html += "<output>" + this.params.slider_start + "</output>";
236+
}else{
237+
html += "></input>";
238+
}
239+
html += "<div>";
240+
227241
for (var j = 0; j < this.params.labels.length; j++) {
228242
var label_width_perc = 100 / (this.params.labels.length - 1);
229243
var percent_of_range = j * (100 / (this.params.labels.length - 1));

packages/plugin-canvas-slider-response/src/index.ts

+12-1
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,11 @@ const info = <const>{
7979
array: true,
8080
default: [500, 500],
8181
},
82+
/** If true, the slider's value will be displayed in real time below the slider. */
83+
value_display: {
84+
type: ParameterType.BOOL,
85+
default: false,
86+
},
8287
},
8388
data: {
8489
/** 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. */
@@ -132,7 +137,13 @@ class CanvasSliderResponsePlugin implements JsPsychPlugin<Info> {
132137
trial.max +
133138
'" step="' +
134139
trial.step +
135-
'" style="width: 100%;" id="jspsych-canvas-slider-response-response"></input>';
140+
'" style="width: 100%;" id="jspsych-canvas-slider-response-response"> ';
141+
if (trial.value_display) {
142+
html += 'oninput="this.nextElementSibling.value = this.value"></input>';
143+
html += "<output>" + trial.slider_start + "</output>";
144+
}else{
145+
html += "></input>";
146+
}
136147
html += "<div>";
137148
for (var j = 0; j < trial.labels.length; j++) {
138149
var width = 100 / (trial.labels.length - 1);

packages/plugin-html-slider-response/src/index.ts

+13-1
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,12 @@ const info = <const>{
7373
type: ParameterType.BOOL,
7474
default: true,
7575
},
76+
/** If true, the slider's value will be displayed in real time below the slider. */
77+
value_display: {
78+
type: ParameterType.BOOL,
79+
default: false,
80+
},
81+
7682
},
7783
data: {
7884
/** 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. */
@@ -129,7 +135,13 @@ class HtmlSliderResponsePlugin implements JsPsychPlugin<Info> {
129135
trial.max +
130136
'" step="' +
131137
trial.step +
132-
'" id="jspsych-html-slider-response-response"></input>';
138+
'" id="jspsych-html-slider-response-response" ';
139+
if (trial.value_display) {
140+
html += 'oninput="this.nextElementSibling.value = this.value"></input>';
141+
html += "<output>" + trial.slider_start + "</output>";
142+
}else{
143+
html += "></input>";
144+
}
133145
html += "<div>";
134146
for (var j = 0; j < trial.labels.length; j++) {
135147
var label_width_perc = 100 / (trial.labels.length - 1);

packages/plugin-image-slider-response/src/index.ts

+12-1
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,11 @@ const info = <const>{
108108
type: ParameterType.BOOL,
109109
default: true,
110110
},
111+
/** If true, the slider's value will be displayed in real time below the slider. */
112+
value_display: {
113+
type: ParameterType.BOOL,
114+
default: false,
115+
},
111116
},
112117
data: {
113118
/** The path of the image that was displayed. */
@@ -222,7 +227,13 @@ class ImageSliderResponsePlugin implements JsPsychPlugin<Info> {
222227
trial.max +
223228
'" step="' +
224229
trial.step +
225-
'" id="jspsych-image-slider-response-response"></input>';
230+
'" id="jspsych-image-slider-response-response"> ';
231+
if (trial.value_display) {
232+
html += 'oninput="this.nextElementSibling.value = this.value"></input>';
233+
html += "<output>" + trial.slider_start + "</output>";
234+
}else{
235+
html += "></input>";
236+
}
226237
html += "<div>";
227238
for (var j = 0; j < trial.labels.length; j++) {
228239
var label_width_perc = 100 / (trial.labels.length - 1);

packages/plugin-video-slider-response/src/index.ts

+15-1
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,11 @@ const info = <const>{
140140
type: ParameterType.BOOL,
141141
default: true,
142142
},
143+
/** If true, the slider's value will be displayed in real time below the slider. */
144+
value_display: {
145+
type: ParameterType.BOOL,
146+
default: false,
147+
},
143148
},
144149
data: {
145150
/** The numeric value of the slider. */
@@ -265,7 +270,16 @@ class VideoSliderResponsePlugin implements JsPsychPlugin<Info> {
265270
if (!trial.response_allowed_while_playing) {
266271
html += " disabled";
267272
}
268-
html += "></input><div>";
273+
274+
// Add real-time value display if enabled
275+
if (trial.value_display) {
276+
html += ' oninput="this.nextElementSibling.value = this.value"></input>';
277+
html += "<output>" + trial.slider_start + "</output>";
278+
}else{
279+
html += "></input>";
280+
}
281+
html += "<div>";
282+
269283
for (var j = 0; j < trial.labels.length; j++) {
270284
var label_width_perc = 100 / (trial.labels.length - 1);
271285
var percent_of_range = j * (100 / (trial.labels.length - 1));

0 commit comments

Comments
 (0)