@jspsych/plugin-survey-multi-choice 1.1.2 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -1,156 +1,220 @@
1
- import { JsPsych, JsPsychPlugin, ParameterType, TrialType } from "jspsych";
2
- declare const info: {
3
- readonly name: "survey-multi-choice";
4
- readonly parameters: {
5
- /** Array containing one or more objects with parameters for the question(s) that should be shown on the page. */
6
- readonly questions: {
7
- readonly type: ParameterType.COMPLEX;
8
- readonly array: true;
9
- readonly pretty_name: "Questions";
10
- readonly nested: {
11
- /** Question prompt. */
12
- readonly prompt: {
13
- readonly type: ParameterType.HTML_STRING;
14
- readonly pretty_name: "Prompt";
15
- readonly default: any;
16
- };
17
- /** Array of multiple choice options for this question. */
18
- readonly options: {
19
- readonly type: ParameterType.STRING;
20
- readonly pretty_name: "Options";
21
- readonly array: true;
22
- readonly default: any;
23
- };
24
- /** Whether or not a response to this question must be given in order to continue. */
25
- readonly required: {
26
- readonly type: ParameterType.BOOL;
27
- readonly pretty_name: "Required";
28
- readonly default: false;
29
- };
30
- /** If true, then the question will be centered and options will be displayed horizontally. */
31
- readonly horizontal: {
32
- readonly type: ParameterType.BOOL;
33
- readonly pretty_name: "Horizontal";
34
- readonly default: false;
35
- };
36
- /** Name of the question in the trial data. If no name is given, the questions are named Q0, Q1, etc. */
37
- readonly name: {
38
- readonly type: ParameterType.STRING;
39
- readonly pretty_name: "Question Name";
40
- readonly default: "";
41
- };
42
- };
43
- };
44
- /** If true, the order of the questions in the 'questions' array will be randomized. */
45
- readonly randomize_question_order: {
46
- readonly type: ParameterType.BOOL;
47
- readonly pretty_name: "Randomize Question Order";
48
- readonly default: false;
49
- };
50
- /** HTML-formatted string to display at top of the page above all of the questions. */
51
- readonly preamble: {
52
- readonly type: ParameterType.HTML_STRING;
53
- readonly pretty_name: "Preamble";
54
- readonly default: any;
55
- };
56
- /** Label of the button to submit responses. */
57
- readonly button_label: {
58
- readonly type: ParameterType.STRING;
59
- readonly pretty_name: "Button label";
60
- readonly default: "Continue";
61
- };
62
- /** Setting this to true will enable browser auto-complete or auto-fill for the form. */
63
- readonly autocomplete: {
64
- readonly type: ParameterType.BOOL;
65
- readonly pretty_name: "Allow autocomplete";
66
- readonly default: false;
67
- };
68
- };
69
- };
70
- declare type Info = typeof info;
71
- /**
72
- * **survey-multi-choice**
73
- *
74
- * jsPsych plugin for presenting multiple choice survey questions
75
- *
76
- * @author Shane Martin
77
- * @see {@link https://www.jspsych.org/plugins/jspsych-survey-multi-choice/ survey-multi-choice plugin documentation on jspsych.org}
78
- */
79
- declare class SurveyMultiChoicePlugin implements JsPsychPlugin<Info> {
80
- private jsPsych;
81
- static info: {
82
- readonly name: "survey-multi-choice";
83
- readonly parameters: {
84
- /** Array containing one or more objects with parameters for the question(s) that should be shown on the page. */
85
- readonly questions: {
86
- readonly type: ParameterType.COMPLEX;
87
- readonly array: true;
88
- readonly pretty_name: "Questions";
89
- readonly nested: {
90
- /** Question prompt. */
91
- readonly prompt: {
92
- readonly type: ParameterType.HTML_STRING;
93
- readonly pretty_name: "Prompt";
94
- readonly default: any;
95
- };
96
- /** Array of multiple choice options for this question. */
97
- readonly options: {
98
- readonly type: ParameterType.STRING;
99
- readonly pretty_name: "Options";
100
- readonly array: true;
101
- readonly default: any;
102
- };
103
- /** Whether or not a response to this question must be given in order to continue. */
104
- readonly required: {
105
- readonly type: ParameterType.BOOL;
106
- readonly pretty_name: "Required";
107
- readonly default: false;
108
- };
109
- /** If true, then the question will be centered and options will be displayed horizontally. */
110
- readonly horizontal: {
111
- readonly type: ParameterType.BOOL;
112
- readonly pretty_name: "Horizontal";
113
- readonly default: false;
114
- };
115
- /** Name of the question in the trial data. If no name is given, the questions are named Q0, Q1, etc. */
116
- readonly name: {
117
- readonly type: ParameterType.STRING;
118
- readonly pretty_name: "Question Name";
119
- readonly default: "";
120
- };
121
- };
122
- };
123
- /** If true, the order of the questions in the 'questions' array will be randomized. */
124
- readonly randomize_question_order: {
125
- readonly type: ParameterType.BOOL;
126
- readonly pretty_name: "Randomize Question Order";
127
- readonly default: false;
128
- };
129
- /** HTML-formatted string to display at top of the page above all of the questions. */
130
- readonly preamble: {
131
- readonly type: ParameterType.HTML_STRING;
132
- readonly pretty_name: "Preamble";
133
- readonly default: any;
134
- };
135
- /** Label of the button to submit responses. */
136
- readonly button_label: {
137
- readonly type: ParameterType.STRING;
138
- readonly pretty_name: "Button label";
139
- readonly default: "Continue";
140
- };
141
- /** Setting this to true will enable browser auto-complete or auto-fill for the form. */
142
- readonly autocomplete: {
143
- readonly type: ParameterType.BOOL;
144
- readonly pretty_name: "Allow autocomplete";
145
- readonly default: false;
146
- };
147
- };
148
- };
149
- constructor(jsPsych: JsPsych);
150
- trial(display_element: HTMLElement, trial: TrialType<Info>): void;
151
- simulate(trial: TrialType<Info>, simulation_mode: any, simulation_options: any, load_callback: () => void): void;
152
- private create_simulation_data;
153
- private simulate_data_only;
154
- private simulate_visual;
155
- }
156
- export default SurveyMultiChoicePlugin;
1
+ import { JsPsychPlugin, ParameterType, JsPsych, TrialType } from 'jspsych';
2
+
3
+ declare const info: {
4
+ readonly name: "survey-multi-choice";
5
+ readonly version: string;
6
+ readonly parameters: {
7
+ /**
8
+ * An array of objects, each object represents a question that appears on the screen. Each object contains a prompt,
9
+ * options, required, and horizontal parameter that will be applied to the question. See examples below for further
10
+ * clarification.`prompt`: Type string, default value is *undefined*. The string is prompt/question that will be
11
+ * associated with a group of options (radio buttons). All questions will get presented on the same page (trial).
12
+ * `options`: Type array, defualt value is *undefined*. An array of strings. The array contains a set of options to
13
+ * display for an individual question.`required`: Type boolean, default value is null. The boolean value indicates
14
+ * if a question is required('true') or not ('false'), using the HTML5 `required` attribute. If this parameter is
15
+ * undefined, the question will be optional. `horizontal`:Type boolean, default value is false. If true, then the
16
+ * question is centered and the options are displayed horizontally. `name`: Name of the question. Used for storing
17
+ * data. If left undefined then default names (`Q0`, `Q1`, `...`) will be used for the questions.
18
+ */
19
+ readonly questions: {
20
+ readonly type: ParameterType.COMPLEX;
21
+ readonly array: true;
22
+ readonly nested: {
23
+ /** Question prompt. */
24
+ readonly prompt: {
25
+ readonly type: ParameterType.HTML_STRING;
26
+ readonly default: any;
27
+ };
28
+ /** Array of multiple choice options for this question. */
29
+ readonly options: {
30
+ readonly type: ParameterType.STRING;
31
+ readonly array: true;
32
+ readonly default: any;
33
+ };
34
+ /** Whether or not a response to this question must be given in order to continue. */
35
+ readonly required: {
36
+ readonly type: ParameterType.BOOL;
37
+ readonly default: false;
38
+ };
39
+ /** If true, then the question will be centered and options will be displayed horizontally. */
40
+ readonly horizontal: {
41
+ readonly type: ParameterType.BOOL;
42
+ readonly default: false;
43
+ };
44
+ /** Name of the question in the trial data. If no name is given, the questions are named Q0, Q1, etc. */
45
+ readonly name: {
46
+ readonly type: ParameterType.STRING;
47
+ readonly default: "";
48
+ };
49
+ };
50
+ };
51
+ /**
52
+ * If true, the display order of `questions` is randomly determined at the start of the trial. In the data object,
53
+ * `Q0` will still refer to the first question in the array, regardless of where it was presented visually.
54
+ */
55
+ readonly randomize_question_order: {
56
+ readonly type: ParameterType.BOOL;
57
+ readonly default: false;
58
+ };
59
+ /** HTML formatted string to display at the top of the page above all the questions. */
60
+ readonly preamble: {
61
+ readonly type: ParameterType.HTML_STRING;
62
+ readonly default: any;
63
+ };
64
+ /** Label of the button. */
65
+ readonly button_label: {
66
+ readonly type: ParameterType.STRING;
67
+ readonly default: "Continue";
68
+ };
69
+ /**
70
+ * This determines whether or not all of the input elements on the page should allow autocomplete. Setting
71
+ * this to true will enable autocomplete or auto-fill for the form.
72
+ */
73
+ readonly autocomplete: {
74
+ readonly type: ParameterType.BOOL;
75
+ readonly default: false;
76
+ };
77
+ };
78
+ readonly data: {
79
+ /** An object containing the response for each question. The object will have a separate key (variable) for each question, with the first question in the trial being recorded in `Q0`, the second in `Q1`, and so on. The responses are recorded as integers, representing the position selected on the likert scale for that question. If the `name` parameter is defined for the question, then the response object will use the value of `name` as the key for each question. This will be encoded as a JSON string when data is saved using the `.json()` or `.csv()` functions. */
80
+ readonly response: {
81
+ readonly type: ParameterType.COMPLEX;
82
+ readonly nested: {
83
+ readonly identifier: {
84
+ readonly type: ParameterType.STRING;
85
+ };
86
+ readonly response: {
87
+ readonly type: number;
88
+ };
89
+ };
90
+ };
91
+ /** The response time in milliseconds for the participant to make a response. The time is measured from when the questions first appear on the screen until the participant's response(s) are submitted. */
92
+ readonly rt: {
93
+ readonly type: ParameterType.INT;
94
+ };
95
+ /** An array with the order of questions. For example `[2,0,1]` would indicate that the first question was `trial.questions[2]` (the third item in the `questions` parameter), the second question was `trial.questions[0]`, and the final question was `trial.questions[1]`. This will be encoded as a JSON string when data is saved using the `.json()` or `.csv()` functions. */
96
+ readonly question_order: {
97
+ readonly type: ParameterType.INT;
98
+ readonly array: true;
99
+ };
100
+ };
101
+ };
102
+ type Info = typeof info;
103
+ /**
104
+ * **survey-multi-choice**
105
+ *
106
+ * The survey-multi-choice plugin displays a set of questions with multiple choice response fields. The participant selects a single answer.
107
+ *
108
+ * @author Shane Martin
109
+ * @see {@link https://www.jspsych.org/latest/plugins/survey-multi-choice/ survey-multi-choice plugin documentation on jspsych.org}
110
+ */
111
+ declare class SurveyMultiChoicePlugin implements JsPsychPlugin<Info> {
112
+ private jsPsych;
113
+ static info: {
114
+ readonly name: "survey-multi-choice";
115
+ readonly version: string;
116
+ readonly parameters: {
117
+ /**
118
+ * An array of objects, each object represents a question that appears on the screen. Each object contains a prompt,
119
+ * options, required, and horizontal parameter that will be applied to the question. See examples below for further
120
+ * clarification.`prompt`: Type string, default value is *undefined*. The string is prompt/question that will be
121
+ * associated with a group of options (radio buttons). All questions will get presented on the same page (trial).
122
+ * `options`: Type array, defualt value is *undefined*. An array of strings. The array contains a set of options to
123
+ * display for an individual question.`required`: Type boolean, default value is null. The boolean value indicates
124
+ * if a question is required('true') or not ('false'), using the HTML5 `required` attribute. If this parameter is
125
+ * undefined, the question will be optional. `horizontal`:Type boolean, default value is false. If true, then the
126
+ * question is centered and the options are displayed horizontally. `name`: Name of the question. Used for storing
127
+ * data. If left undefined then default names (`Q0`, `Q1`, `...`) will be used for the questions.
128
+ */
129
+ readonly questions: {
130
+ readonly type: ParameterType.COMPLEX;
131
+ readonly array: true;
132
+ readonly nested: {
133
+ /** Question prompt. */
134
+ readonly prompt: {
135
+ readonly type: ParameterType.HTML_STRING;
136
+ readonly default: any;
137
+ };
138
+ /** Array of multiple choice options for this question. */
139
+ readonly options: {
140
+ readonly type: ParameterType.STRING;
141
+ readonly array: true;
142
+ readonly default: any;
143
+ };
144
+ /** Whether or not a response to this question must be given in order to continue. */
145
+ readonly required: {
146
+ readonly type: ParameterType.BOOL;
147
+ readonly default: false;
148
+ };
149
+ /** If true, then the question will be centered and options will be displayed horizontally. */
150
+ readonly horizontal: {
151
+ readonly type: ParameterType.BOOL;
152
+ readonly default: false;
153
+ };
154
+ /** Name of the question in the trial data. If no name is given, the questions are named Q0, Q1, etc. */
155
+ readonly name: {
156
+ readonly type: ParameterType.STRING;
157
+ readonly default: "";
158
+ };
159
+ };
160
+ };
161
+ /**
162
+ * If true, the display order of `questions` is randomly determined at the start of the trial. In the data object,
163
+ * `Q0` will still refer to the first question in the array, regardless of where it was presented visually.
164
+ */
165
+ readonly randomize_question_order: {
166
+ readonly type: ParameterType.BOOL;
167
+ readonly default: false;
168
+ };
169
+ /** HTML formatted string to display at the top of the page above all the questions. */
170
+ readonly preamble: {
171
+ readonly type: ParameterType.HTML_STRING;
172
+ readonly default: any;
173
+ };
174
+ /** Label of the button. */
175
+ readonly button_label: {
176
+ readonly type: ParameterType.STRING;
177
+ readonly default: "Continue";
178
+ };
179
+ /**
180
+ * This determines whether or not all of the input elements on the page should allow autocomplete. Setting
181
+ * this to true will enable autocomplete or auto-fill for the form.
182
+ */
183
+ readonly autocomplete: {
184
+ readonly type: ParameterType.BOOL;
185
+ readonly default: false;
186
+ };
187
+ };
188
+ readonly data: {
189
+ /** An object containing the response for each question. The object will have a separate key (variable) for each question, with the first question in the trial being recorded in `Q0`, the second in `Q1`, and so on. The responses are recorded as integers, representing the position selected on the likert scale for that question. If the `name` parameter is defined for the question, then the response object will use the value of `name` as the key for each question. This will be encoded as a JSON string when data is saved using the `.json()` or `.csv()` functions. */
190
+ readonly response: {
191
+ readonly type: ParameterType.COMPLEX;
192
+ readonly nested: {
193
+ readonly identifier: {
194
+ readonly type: ParameterType.STRING;
195
+ };
196
+ readonly response: {
197
+ readonly type: number;
198
+ };
199
+ };
200
+ };
201
+ /** The response time in milliseconds for the participant to make a response. The time is measured from when the questions first appear on the screen until the participant's response(s) are submitted. */
202
+ readonly rt: {
203
+ readonly type: ParameterType.INT;
204
+ };
205
+ /** An array with the order of questions. For example `[2,0,1]` would indicate that the first question was `trial.questions[2]` (the third item in the `questions` parameter), the second question was `trial.questions[0]`, and the final question was `trial.questions[1]`. This will be encoded as a JSON string when data is saved using the `.json()` or `.csv()` functions. */
206
+ readonly question_order: {
207
+ readonly type: ParameterType.INT;
208
+ readonly array: true;
209
+ };
210
+ };
211
+ };
212
+ constructor(jsPsych: JsPsych);
213
+ trial(display_element: HTMLElement, trial: TrialType<Info>): void;
214
+ simulate(trial: TrialType<Info>, simulation_mode: any, simulation_options: any, load_callback: () => void): void;
215
+ private create_simulation_data;
216
+ private simulate_data_only;
217
+ private simulate_visual;
218
+ }
219
+
220
+ export { SurveyMultiChoicePlugin as default };