@jspsych/plugin-survey-likert 1.1.3 → 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.browser.js +230 -226
- package/dist/index.browser.js.map +1 -1
- package/dist/index.browser.min.js +2 -2
- package/dist/index.browser.min.js.map +1 -1
- package/dist/index.cjs +228 -224
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +55 -26
- package/dist/index.js +228 -224
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
- package/src/index.spec.ts +1 -1
- package/src/index.ts +34 -16
package/dist/index.js
CHANGED
|
@@ -1,246 +1,250 @@
|
|
|
1
1
|
import { ParameterType } from 'jspsych';
|
|
2
2
|
|
|
3
|
+
var _package = {
|
|
4
|
+
name: "@jspsych/plugin-survey-likert",
|
|
5
|
+
version: "2.0.0",
|
|
6
|
+
description: "a jspsych plugin for measuring items on a likert scale",
|
|
7
|
+
type: "module",
|
|
8
|
+
main: "dist/index.cjs",
|
|
9
|
+
exports: {
|
|
10
|
+
import: "./dist/index.js",
|
|
11
|
+
require: "./dist/index.cjs"
|
|
12
|
+
},
|
|
13
|
+
typings: "dist/index.d.ts",
|
|
14
|
+
unpkg: "dist/index.browser.min.js",
|
|
15
|
+
files: [
|
|
16
|
+
"src",
|
|
17
|
+
"dist"
|
|
18
|
+
],
|
|
19
|
+
source: "src/index.ts",
|
|
20
|
+
scripts: {
|
|
21
|
+
test: "jest",
|
|
22
|
+
"test:watch": "npm test -- --watch",
|
|
23
|
+
tsc: "tsc",
|
|
24
|
+
build: "rollup --config",
|
|
25
|
+
"build:watch": "npm run build -- --watch"
|
|
26
|
+
},
|
|
27
|
+
repository: {
|
|
28
|
+
type: "git",
|
|
29
|
+
url: "git+https://github.com/jspsych/jsPsych.git",
|
|
30
|
+
directory: "packages/plugin-survey-likert"
|
|
31
|
+
},
|
|
32
|
+
author: "Josh de Leeuw",
|
|
33
|
+
license: "MIT",
|
|
34
|
+
bugs: {
|
|
35
|
+
url: "https://github.com/jspsych/jsPsych/issues"
|
|
36
|
+
},
|
|
37
|
+
homepage: "https://www.jspsych.org/latest/plugins/survey-likert",
|
|
38
|
+
peerDependencies: {
|
|
39
|
+
jspsych: ">=7.1.0"
|
|
40
|
+
},
|
|
41
|
+
devDependencies: {
|
|
42
|
+
"@jspsych/config": "^3.0.0",
|
|
43
|
+
"@jspsych/test-utils": "^1.2.0"
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
|
|
3
47
|
const info = {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
type: ParameterType.HTML_STRING,
|
|
15
|
-
pretty_name: "Prompt",
|
|
16
|
-
default: undefined,
|
|
17
|
-
},
|
|
18
|
-
/** Array of likert labels to display for this question. */
|
|
19
|
-
labels: {
|
|
20
|
-
type: ParameterType.STRING,
|
|
21
|
-
array: true,
|
|
22
|
-
pretty_name: "Labels",
|
|
23
|
-
default: undefined,
|
|
24
|
-
},
|
|
25
|
-
/** Whether or not a response to this question must be given in order to continue. */
|
|
26
|
-
required: {
|
|
27
|
-
type: ParameterType.BOOL,
|
|
28
|
-
pretty_name: "Required",
|
|
29
|
-
default: false,
|
|
30
|
-
},
|
|
31
|
-
/** Name of the question in the trial data. If no name is given, the questions are named Q0, Q1, etc. */
|
|
32
|
-
name: {
|
|
33
|
-
type: ParameterType.STRING,
|
|
34
|
-
pretty_name: "Question Name",
|
|
35
|
-
default: "",
|
|
36
|
-
},
|
|
37
|
-
},
|
|
38
|
-
},
|
|
39
|
-
/** If true, the order of the questions in the 'questions' array will be randomized. */
|
|
40
|
-
randomize_question_order: {
|
|
41
|
-
type: ParameterType.BOOL,
|
|
42
|
-
pretty_name: "Randomize Question Order",
|
|
43
|
-
default: false,
|
|
44
|
-
},
|
|
45
|
-
/** HTML-formatted string to display at top of the page above all of the questions. */
|
|
46
|
-
preamble: {
|
|
47
|
-
type: ParameterType.HTML_STRING,
|
|
48
|
-
pretty_name: "Preamble",
|
|
49
|
-
default: null,
|
|
48
|
+
name: "survey-likert",
|
|
49
|
+
version: _package.version,
|
|
50
|
+
parameters: {
|
|
51
|
+
questions: {
|
|
52
|
+
type: ParameterType.COMPLEX,
|
|
53
|
+
array: true,
|
|
54
|
+
nested: {
|
|
55
|
+
prompt: {
|
|
56
|
+
type: ParameterType.HTML_STRING,
|
|
57
|
+
default: void 0
|
|
50
58
|
},
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
default: null,
|
|
59
|
+
labels: {
|
|
60
|
+
type: ParameterType.STRING,
|
|
61
|
+
array: true,
|
|
62
|
+
default: void 0
|
|
56
63
|
},
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
pretty_name: "Button label",
|
|
61
|
-
default: "Continue",
|
|
64
|
+
required: {
|
|
65
|
+
type: ParameterType.BOOL,
|
|
66
|
+
default: false
|
|
62
67
|
},
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
+
name: {
|
|
69
|
+
type: ParameterType.STRING,
|
|
70
|
+
default: ""
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
},
|
|
74
|
+
randomize_question_order: {
|
|
75
|
+
type: ParameterType.BOOL,
|
|
76
|
+
default: false
|
|
77
|
+
},
|
|
78
|
+
preamble: {
|
|
79
|
+
type: ParameterType.HTML_STRING,
|
|
80
|
+
default: null
|
|
81
|
+
},
|
|
82
|
+
scale_width: {
|
|
83
|
+
type: ParameterType.INT,
|
|
84
|
+
default: null
|
|
85
|
+
},
|
|
86
|
+
button_label: {
|
|
87
|
+
type: ParameterType.STRING,
|
|
88
|
+
default: "Continue"
|
|
89
|
+
},
|
|
90
|
+
autocomplete: {
|
|
91
|
+
type: ParameterType.BOOL,
|
|
92
|
+
default: false
|
|
93
|
+
}
|
|
94
|
+
},
|
|
95
|
+
data: {
|
|
96
|
+
response: {
|
|
97
|
+
type: ParameterType.COMPLEX,
|
|
98
|
+
nested: {
|
|
99
|
+
identifier: {
|
|
100
|
+
type: ParameterType.STRING
|
|
68
101
|
},
|
|
102
|
+
response: {
|
|
103
|
+
type: ParameterType.STRING | ParameterType.INT | ParameterType.FLOAT | ParameterType.BOOL | ParameterType.OBJECT
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
},
|
|
107
|
+
rt: {
|
|
108
|
+
type: ParameterType.INT
|
|
69
109
|
},
|
|
110
|
+
question_order: {
|
|
111
|
+
type: ParameterType.INT,
|
|
112
|
+
array: true
|
|
113
|
+
}
|
|
114
|
+
}
|
|
70
115
|
};
|
|
71
|
-
/**
|
|
72
|
-
* **survey-likert**
|
|
73
|
-
*
|
|
74
|
-
* jsPsych plugin for gathering responses to questions on a likert scale
|
|
75
|
-
*
|
|
76
|
-
* @author Josh de Leeuw
|
|
77
|
-
* @see {@link https://www.jspsych.org/plugins/jspsych-survey-likert/ survey-likert plugin documentation on jspsych.org}
|
|
78
|
-
*/
|
|
79
116
|
class SurveyLikertPlugin {
|
|
80
|
-
|
|
81
|
-
|
|
117
|
+
constructor(jsPsych) {
|
|
118
|
+
this.jsPsych = jsPsych;
|
|
119
|
+
}
|
|
120
|
+
trial(display_element, trial) {
|
|
121
|
+
if (trial.scale_width !== null) {
|
|
122
|
+
var w = trial.scale_width + "px";
|
|
123
|
+
} else {
|
|
124
|
+
var w = "100%";
|
|
82
125
|
}
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
if (trial.autocomplete) {
|
|
112
|
-
html += '<form id="jspsych-survey-likert-form">';
|
|
113
|
-
}
|
|
114
|
-
else {
|
|
115
|
-
html += '<form id="jspsych-survey-likert-form" autocomplete="off">';
|
|
116
|
-
}
|
|
117
|
-
// add likert scale questions ///
|
|
118
|
-
// generate question order. this is randomized here as opposed to randomizing the order of trial.questions
|
|
119
|
-
// so that the data are always associated with the same question regardless of order
|
|
120
|
-
var question_order = [];
|
|
121
|
-
for (var i = 0; i < trial.questions.length; i++) {
|
|
122
|
-
question_order.push(i);
|
|
123
|
-
}
|
|
124
|
-
if (trial.randomize_question_order) {
|
|
125
|
-
question_order = this.jsPsych.randomization.shuffle(question_order);
|
|
126
|
-
}
|
|
127
|
-
for (var i = 0; i < trial.questions.length; i++) {
|
|
128
|
-
var question = trial.questions[question_order[i]];
|
|
129
|
-
// add question
|
|
130
|
-
html += '<label class="jspsych-survey-likert-statement">' + question.prompt + "</label>";
|
|
131
|
-
// add options
|
|
132
|
-
var width = 100 / question.labels.length;
|
|
133
|
-
var options_string = '<ul class="jspsych-survey-likert-opts" data-name="' +
|
|
134
|
-
question.name +
|
|
135
|
-
'" data-radio-group="Q' +
|
|
136
|
-
question_order[i] +
|
|
137
|
-
'">';
|
|
138
|
-
for (var j = 0; j < question.labels.length; j++) {
|
|
139
|
-
options_string +=
|
|
140
|
-
'<li style="width:' +
|
|
141
|
-
width +
|
|
142
|
-
'%"><label class="jspsych-survey-likert-opt-label"><input type="radio" name="Q' +
|
|
143
|
-
question_order[i] +
|
|
144
|
-
'" value="' +
|
|
145
|
-
j +
|
|
146
|
-
'"';
|
|
147
|
-
if (question.required) {
|
|
148
|
-
options_string += " required";
|
|
149
|
-
}
|
|
150
|
-
options_string += ">" + question.labels[j] + "</label></li>";
|
|
151
|
-
}
|
|
152
|
-
options_string += "</ul>";
|
|
153
|
-
html += options_string;
|
|
126
|
+
var html = "";
|
|
127
|
+
html += '<style id="jspsych-survey-likert-css">';
|
|
128
|
+
html += ".jspsych-survey-likert-statement { display:block; font-size: 16px; padding-top: 40px; margin-bottom:10px; }.jspsych-survey-likert-opts { list-style:none; width:" + w + "; margin:auto; padding:0 0 35px; display:block; font-size: 14px; line-height:1.1em; }.jspsych-survey-likert-opt-label { line-height: 1.1em; color: #444; }.jspsych-survey-likert-opts:before { content: ''; position:relative; top:11px; /*left:9.5%;*/ display:block; background-color:#efefef; height:4px; width:100%; }.jspsych-survey-likert-opts:last-of-type { border-bottom: 0; }.jspsych-survey-likert-opts li { display:inline-block; /*width:19%;*/ text-align:center; vertical-align: top; }.jspsych-survey-likert-opts li input[type=radio] { display:block; position:relative; top:0; left:50%; margin-left:-6px; }";
|
|
129
|
+
html += "</style>";
|
|
130
|
+
if (trial.preamble !== null) {
|
|
131
|
+
html += '<div id="jspsych-survey-likert-preamble" class="jspsych-survey-likert-preamble">' + trial.preamble + "</div>";
|
|
132
|
+
}
|
|
133
|
+
if (trial.autocomplete) {
|
|
134
|
+
html += '<form id="jspsych-survey-likert-form">';
|
|
135
|
+
} else {
|
|
136
|
+
html += '<form id="jspsych-survey-likert-form" autocomplete="off">';
|
|
137
|
+
}
|
|
138
|
+
var question_order = [];
|
|
139
|
+
for (var i = 0; i < trial.questions.length; i++) {
|
|
140
|
+
question_order.push(i);
|
|
141
|
+
}
|
|
142
|
+
if (trial.randomize_question_order) {
|
|
143
|
+
question_order = this.jsPsych.randomization.shuffle(question_order);
|
|
144
|
+
}
|
|
145
|
+
for (var i = 0; i < trial.questions.length; i++) {
|
|
146
|
+
var question = trial.questions[question_order[i]];
|
|
147
|
+
html += '<label class="jspsych-survey-likert-statement">' + question.prompt + "</label>";
|
|
148
|
+
var width = 100 / question.labels.length;
|
|
149
|
+
var options_string = '<ul class="jspsych-survey-likert-opts" data-name="' + question.name + '" data-radio-group="Q' + question_order[i] + '">';
|
|
150
|
+
for (var j = 0; j < question.labels.length; j++) {
|
|
151
|
+
options_string += '<li style="width:' + width + '%"><label class="jspsych-survey-likert-opt-label"><input type="radio" name="Q' + question_order[i] + '" value="' + j + '"';
|
|
152
|
+
if (question.required) {
|
|
153
|
+
options_string += " required";
|
|
154
154
|
}
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
'"></input>';
|
|
160
|
-
html += "</form>";
|
|
161
|
-
display_element.innerHTML = html;
|
|
162
|
-
display_element.querySelector("#jspsych-survey-likert-form").addEventListener("submit", (e) => {
|
|
163
|
-
e.preventDefault();
|
|
164
|
-
// measure response time
|
|
165
|
-
var endTime = performance.now();
|
|
166
|
-
var response_time = Math.round(endTime - startTime);
|
|
167
|
-
// create object to hold responses
|
|
168
|
-
var question_data = {};
|
|
169
|
-
var matches = display_element.querySelectorAll("#jspsych-survey-likert-form .jspsych-survey-likert-opts");
|
|
170
|
-
for (var index = 0; index < matches.length; index++) {
|
|
171
|
-
var id = matches[index].dataset["radioGroup"];
|
|
172
|
-
var el = display_element.querySelector('input[name="' + id + '"]:checked');
|
|
173
|
-
if (el === null) {
|
|
174
|
-
var response = "";
|
|
175
|
-
}
|
|
176
|
-
else {
|
|
177
|
-
var response = parseInt(el.value);
|
|
178
|
-
}
|
|
179
|
-
var obje = {};
|
|
180
|
-
if (matches[index].attributes["data-name"].value !== "") {
|
|
181
|
-
var name = matches[index].attributes["data-name"].value;
|
|
182
|
-
}
|
|
183
|
-
else {
|
|
184
|
-
var name = id;
|
|
185
|
-
}
|
|
186
|
-
obje[name] = response;
|
|
187
|
-
Object.assign(question_data, obje);
|
|
188
|
-
}
|
|
189
|
-
// save data
|
|
190
|
-
var trial_data = {
|
|
191
|
-
rt: response_time,
|
|
192
|
-
response: question_data,
|
|
193
|
-
question_order: question_order,
|
|
194
|
-
};
|
|
195
|
-
display_element.innerHTML = "";
|
|
196
|
-
// next trial
|
|
197
|
-
this.jsPsych.finishTrial(trial_data);
|
|
198
|
-
});
|
|
199
|
-
var startTime = performance.now();
|
|
155
|
+
options_string += ">" + question.labels[j] + "</label></li>";
|
|
156
|
+
}
|
|
157
|
+
options_string += "</ul>";
|
|
158
|
+
html += options_string;
|
|
200
159
|
}
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
160
|
+
html += '<input type="submit" id="jspsych-survey-likert-next" class="jspsych-survey-likert jspsych-btn" value="' + trial.button_label + '"></input>';
|
|
161
|
+
html += "</form>";
|
|
162
|
+
display_element.innerHTML = html;
|
|
163
|
+
display_element.querySelector("#jspsych-survey-likert-form").addEventListener("submit", (e) => {
|
|
164
|
+
e.preventDefault();
|
|
165
|
+
var endTime = performance.now();
|
|
166
|
+
var response_time = Math.round(endTime - startTime);
|
|
167
|
+
var question_data = {};
|
|
168
|
+
var matches = display_element.querySelectorAll(
|
|
169
|
+
"#jspsych-survey-likert-form .jspsych-survey-likert-opts"
|
|
170
|
+
);
|
|
171
|
+
for (var index = 0; index < matches.length; index++) {
|
|
172
|
+
var id = matches[index].dataset["radioGroup"];
|
|
173
|
+
var el = display_element.querySelector(
|
|
174
|
+
'input[name="' + id + '"]:checked'
|
|
175
|
+
);
|
|
176
|
+
if (el === null) {
|
|
177
|
+
var response = "";
|
|
178
|
+
} else {
|
|
179
|
+
var response = parseInt(el.value);
|
|
205
180
|
}
|
|
206
|
-
|
|
207
|
-
|
|
181
|
+
var obje = {};
|
|
182
|
+
if (matches[index].attributes["data-name"].value !== "") {
|
|
183
|
+
var name = matches[index].attributes["data-name"].value;
|
|
184
|
+
} else {
|
|
185
|
+
var name = id;
|
|
208
186
|
}
|
|
187
|
+
obje[name] = response;
|
|
188
|
+
Object.assign(question_data, obje);
|
|
189
|
+
}
|
|
190
|
+
var trial_data = {
|
|
191
|
+
rt: response_time,
|
|
192
|
+
response: question_data,
|
|
193
|
+
question_order
|
|
194
|
+
};
|
|
195
|
+
this.jsPsych.finishTrial(trial_data);
|
|
196
|
+
});
|
|
197
|
+
var startTime = performance.now();
|
|
198
|
+
}
|
|
199
|
+
simulate(trial, simulation_mode, simulation_options, load_callback) {
|
|
200
|
+
if (simulation_mode == "data-only") {
|
|
201
|
+
load_callback();
|
|
202
|
+
this.simulate_data_only(trial, simulation_options);
|
|
209
203
|
}
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
let rt = 1000;
|
|
213
|
-
for (const q of trial.questions) {
|
|
214
|
-
const name = q.name ? q.name : `Q${trial.questions.indexOf(q)}`;
|
|
215
|
-
question_data[name] = this.jsPsych.randomization.randomInt(0, q.labels.length - 1);
|
|
216
|
-
rt += this.jsPsych.randomization.sampleExGaussian(1500, 400, 1 / 200, true);
|
|
217
|
-
}
|
|
218
|
-
const default_data = {
|
|
219
|
-
response: question_data,
|
|
220
|
-
rt: rt,
|
|
221
|
-
question_order: trial.randomize_question_order
|
|
222
|
-
? this.jsPsych.randomization.shuffle([...Array(trial.questions.length).keys()])
|
|
223
|
-
: [...Array(trial.questions.length).keys()],
|
|
224
|
-
};
|
|
225
|
-
const data = this.jsPsych.pluginAPI.mergeSimulationData(default_data, simulation_options);
|
|
226
|
-
this.jsPsych.pluginAPI.ensureSimulationDataConsistency(trial, data);
|
|
227
|
-
return data;
|
|
204
|
+
if (simulation_mode == "visual") {
|
|
205
|
+
this.simulate_visual(trial, simulation_options, load_callback);
|
|
228
206
|
}
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
207
|
+
}
|
|
208
|
+
create_simulation_data(trial, simulation_options) {
|
|
209
|
+
const question_data = {};
|
|
210
|
+
let rt = 1e3;
|
|
211
|
+
for (const q of trial.questions) {
|
|
212
|
+
const name = q.name ? q.name : `Q${trial.questions.indexOf(q)}`;
|
|
213
|
+
question_data[name] = this.jsPsych.randomization.randomInt(0, q.labels.length - 1);
|
|
214
|
+
rt += this.jsPsych.randomization.sampleExGaussian(1500, 400, 1 / 200, true);
|
|
232
215
|
}
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
216
|
+
const default_data = {
|
|
217
|
+
response: question_data,
|
|
218
|
+
rt,
|
|
219
|
+
question_order: trial.randomize_question_order ? this.jsPsych.randomization.shuffle([...Array(trial.questions.length).keys()]) : [...Array(trial.questions.length).keys()]
|
|
220
|
+
};
|
|
221
|
+
const data = this.jsPsych.pluginAPI.mergeSimulationData(default_data, simulation_options);
|
|
222
|
+
this.jsPsych.pluginAPI.ensureSimulationDataConsistency(trial, data);
|
|
223
|
+
return data;
|
|
224
|
+
}
|
|
225
|
+
simulate_data_only(trial, simulation_options) {
|
|
226
|
+
const data = this.create_simulation_data(trial, simulation_options);
|
|
227
|
+
this.jsPsych.finishTrial(data);
|
|
228
|
+
}
|
|
229
|
+
simulate_visual(trial, simulation_options, load_callback) {
|
|
230
|
+
const data = this.create_simulation_data(trial, simulation_options);
|
|
231
|
+
const display_element = this.jsPsych.getDisplayElement();
|
|
232
|
+
this.trial(display_element, trial);
|
|
233
|
+
load_callback();
|
|
234
|
+
const answers = Object.entries(data.response);
|
|
235
|
+
for (let i = 0; i < answers.length; i++) {
|
|
236
|
+
this.jsPsych.pluginAPI.clickTarget(
|
|
237
|
+
display_element.querySelector(
|
|
238
|
+
`input[type="radio"][name="${answers[i][0]}"][value="${answers[i][1]}"]`
|
|
239
|
+
),
|
|
240
|
+
(data.rt - 1e3) / answers.length * (i + 1)
|
|
241
|
+
);
|
|
243
242
|
}
|
|
243
|
+
this.jsPsych.pluginAPI.clickTarget(
|
|
244
|
+
display_element.querySelector("#jspsych-survey-likert-next"),
|
|
245
|
+
data.rt
|
|
246
|
+
);
|
|
247
|
+
}
|
|
244
248
|
}
|
|
245
249
|
SurveyLikertPlugin.info = info;
|
|
246
250
|
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../src/index.ts"],"sourcesContent":["import { JsPsych, JsPsychPlugin, ParameterType, TrialType } from \"jspsych\";\n\nconst info = <const>{\n name: \"survey-likert\",\n parameters: {\n /** Array containing one or more objects with parameters for the question(s) that should be shown on the page. */\n questions: {\n type: ParameterType.COMPLEX,\n array: true,\n pretty_name: \"Questions\",\n nested: {\n /** Question prompt. */\n prompt: {\n type: ParameterType.HTML_STRING,\n pretty_name: \"Prompt\",\n default: undefined,\n },\n /** Array of likert labels to display for this question. */\n labels: {\n type: ParameterType.STRING,\n array: true,\n pretty_name: \"Labels\",\n default: undefined,\n },\n /** Whether or not a response to this question must be given in order to continue. */\n required: {\n type: ParameterType.BOOL,\n pretty_name: \"Required\",\n default: false,\n },\n /** Name of the question in the trial data. If no name is given, the questions are named Q0, Q1, etc. */\n name: {\n type: ParameterType.STRING,\n pretty_name: \"Question Name\",\n default: \"\",\n },\n },\n },\n /** If true, the order of the questions in the 'questions' array will be randomized. */\n randomize_question_order: {\n type: ParameterType.BOOL,\n pretty_name: \"Randomize Question Order\",\n default: false,\n },\n /** HTML-formatted string to display at top of the page above all of the questions. */\n preamble: {\n type: ParameterType.HTML_STRING,\n pretty_name: \"Preamble\",\n default: null,\n },\n /** Width of the likert scales in pixels. */\n scale_width: {\n type: ParameterType.INT,\n pretty_name: \"Scale width\",\n default: null,\n },\n /** Label of the button to submit responses. */\n button_label: {\n type: ParameterType.STRING,\n pretty_name: \"Button label\",\n default: \"Continue\",\n },\n /** Setting this to true will enable browser auto-complete or auto-fill for the form. */\n autocomplete: {\n type: ParameterType.BOOL,\n pretty_name: \"Allow autocomplete\",\n default: false,\n },\n },\n};\n\ntype Info = typeof info;\n\n/**\n * **survey-likert**\n *\n * jsPsych plugin for gathering responses to questions on a likert scale\n *\n * @author Josh de Leeuw\n * @see {@link https://www.jspsych.org/plugins/jspsych-survey-likert/ survey-likert plugin documentation on jspsych.org}\n */\nclass SurveyLikertPlugin implements JsPsychPlugin<Info> {\n static info = info;\n\n constructor(private jsPsych: JsPsych) {}\n\n trial(display_element: HTMLElement, trial: TrialType<Info>) {\n if (trial.scale_width !== null) {\n var w = trial.scale_width + \"px\";\n } else {\n var w = \"100%\";\n }\n\n var html = \"\";\n // inject CSS for trial\n html += '<style id=\"jspsych-survey-likert-css\">';\n html +=\n \".jspsych-survey-likert-statement { display:block; font-size: 16px; padding-top: 40px; margin-bottom:10px; }\" +\n \".jspsych-survey-likert-opts { list-style:none; width:\" +\n w +\n \"; margin:auto; padding:0 0 35px; display:block; font-size: 14px; line-height:1.1em; }\" +\n \".jspsych-survey-likert-opt-label { line-height: 1.1em; color: #444; }\" +\n \".jspsych-survey-likert-opts:before { content: ''; position:relative; top:11px; /*left:9.5%;*/ display:block; background-color:#efefef; height:4px; width:100%; }\" +\n \".jspsych-survey-likert-opts:last-of-type { border-bottom: 0; }\" +\n \".jspsych-survey-likert-opts li { display:inline-block; /*width:19%;*/ text-align:center; vertical-align: top; }\" +\n \".jspsych-survey-likert-opts li input[type=radio] { display:block; position:relative; top:0; left:50%; margin-left:-6px; }\";\n html += \"</style>\";\n\n // show preamble text\n if (trial.preamble !== null) {\n html +=\n '<div id=\"jspsych-survey-likert-preamble\" class=\"jspsych-survey-likert-preamble\">' +\n trial.preamble +\n \"</div>\";\n }\n\n if (trial.autocomplete) {\n html += '<form id=\"jspsych-survey-likert-form\">';\n } else {\n html += '<form id=\"jspsych-survey-likert-form\" autocomplete=\"off\">';\n }\n\n // add likert scale questions ///\n // generate question order. this is randomized here as opposed to randomizing the order of trial.questions\n // so that the data are always associated with the same question regardless of order\n var question_order = [];\n for (var i = 0; i < trial.questions.length; i++) {\n question_order.push(i);\n }\n if (trial.randomize_question_order) {\n question_order = this.jsPsych.randomization.shuffle(question_order);\n }\n\n for (var i = 0; i < trial.questions.length; i++) {\n var question = trial.questions[question_order[i]];\n // add question\n html += '<label class=\"jspsych-survey-likert-statement\">' + question.prompt + \"</label>\";\n // add options\n var width = 100 / question.labels.length;\n var options_string =\n '<ul class=\"jspsych-survey-likert-opts\" data-name=\"' +\n question.name +\n '\" data-radio-group=\"Q' +\n question_order[i] +\n '\">';\n for (var j = 0; j < question.labels.length; j++) {\n options_string +=\n '<li style=\"width:' +\n width +\n '%\"><label class=\"jspsych-survey-likert-opt-label\"><input type=\"radio\" name=\"Q' +\n question_order[i] +\n '\" value=\"' +\n j +\n '\"';\n if (question.required) {\n options_string += \" required\";\n }\n options_string += \">\" + question.labels[j] + \"</label></li>\";\n }\n options_string += \"</ul>\";\n html += options_string;\n }\n\n // add submit button\n html +=\n '<input type=\"submit\" id=\"jspsych-survey-likert-next\" class=\"jspsych-survey-likert jspsych-btn\" value=\"' +\n trial.button_label +\n '\"></input>';\n\n html += \"</form>\";\n\n display_element.innerHTML = html;\n\n display_element.querySelector(\"#jspsych-survey-likert-form\").addEventListener(\"submit\", (e) => {\n e.preventDefault();\n // measure response time\n var endTime = performance.now();\n var response_time = Math.round(endTime - startTime);\n\n // create object to hold responses\n var question_data = {};\n var matches = display_element.querySelectorAll<HTMLFormElement>(\n \"#jspsych-survey-likert-form .jspsych-survey-likert-opts\"\n );\n for (var index = 0; index < matches.length; index++) {\n var id = matches[index].dataset[\"radioGroup\"];\n var el = display_element.querySelector<HTMLInputElement>(\n 'input[name=\"' + id + '\"]:checked'\n );\n if (el === null) {\n var response: string | number = \"\";\n } else {\n var response: string | number = parseInt(el.value);\n }\n var obje = {};\n if (matches[index].attributes[\"data-name\"].value !== \"\") {\n var name = matches[index].attributes[\"data-name\"].value;\n } else {\n var name = id;\n }\n obje[name] = response;\n Object.assign(question_data, obje);\n }\n\n // save data\n var trial_data = {\n rt: response_time,\n response: question_data,\n question_order: question_order,\n };\n\n display_element.innerHTML = \"\";\n\n // next trial\n this.jsPsych.finishTrial(trial_data);\n });\n\n var startTime = performance.now();\n }\n\n simulate(\n trial: TrialType<Info>,\n simulation_mode,\n simulation_options: any,\n load_callback: () => void\n ) {\n if (simulation_mode == \"data-only\") {\n load_callback();\n this.simulate_data_only(trial, simulation_options);\n }\n if (simulation_mode == \"visual\") {\n this.simulate_visual(trial, simulation_options, load_callback);\n }\n }\n\n private create_simulation_data(trial: TrialType<Info>, simulation_options) {\n const question_data = {};\n let rt = 1000;\n\n for (const q of trial.questions) {\n const name = q.name ? q.name : `Q${trial.questions.indexOf(q)}`;\n question_data[name] = this.jsPsych.randomization.randomInt(0, q.labels.length - 1);\n rt += this.jsPsych.randomization.sampleExGaussian(1500, 400, 1 / 200, true);\n }\n\n const default_data = {\n response: question_data,\n rt: rt,\n question_order: trial.randomize_question_order\n ? this.jsPsych.randomization.shuffle([...Array(trial.questions.length).keys()])\n : [...Array(trial.questions.length).keys()],\n };\n\n const data = this.jsPsych.pluginAPI.mergeSimulationData(default_data, simulation_options);\n\n this.jsPsych.pluginAPI.ensureSimulationDataConsistency(trial, data);\n\n return data;\n }\n\n private simulate_data_only(trial: TrialType<Info>, simulation_options) {\n const data = this.create_simulation_data(trial, simulation_options);\n\n this.jsPsych.finishTrial(data);\n }\n\n private simulate_visual(trial: TrialType<Info>, simulation_options, load_callback: () => void) {\n const data = this.create_simulation_data(trial, simulation_options);\n\n const display_element = this.jsPsych.getDisplayElement();\n\n this.trial(display_element, trial);\n load_callback();\n\n const answers = Object.entries(data.response);\n for (let i = 0; i < answers.length; i++) {\n this.jsPsych.pluginAPI.clickTarget(\n display_element.querySelector(\n `input[type=\"radio\"][name=\"${answers[i][0]}\"][value=\"${answers[i][1]}\"]`\n ),\n ((data.rt - 1000) / answers.length) * (i + 1)\n );\n }\n\n this.jsPsych.pluginAPI.clickTarget(\n display_element.querySelector(\"#jspsych-survey-likert-next\"),\n data.rt\n );\n }\n}\n\nexport default SurveyLikertPlugin;\n"],"names":[],"mappings":";;AAEA,MAAM,IAAI,GAAU;AAClB,IAAA,IAAI,EAAE,eAAe;AACrB,IAAA,UAAU,EAAE;;AAEV,QAAA,SAAS,EAAE;YACT,IAAI,EAAE,aAAa,CAAC,OAAO;AAC3B,YAAA,KAAK,EAAE,IAAI;AACX,YAAA,WAAW,EAAE,WAAW;AACxB,YAAA,MAAM,EAA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,CAAC,OAAO,CAAC,iBAAiB,EAAE,CAAC;AAEzD,QAAA,IAAI,CAAC,KAAK,CAAC,eAAe,EAAE,KAAK,CAAC,CAAC;AACnC,QAAA,aAAa,EAAE,CAAC;QAEhB,MAAM,OAAO,GAAG,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;AAC9C,QAAA,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;YACvC,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC,WAAW,CAChC,eAAe,CAAC,aAAa,CAC3B,6BAA6B,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAa,UAAA,EAAA,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA,EAAA,CAAI,CACzE,EACD,CAAC,CAAC,IAAI,CAAC,EAAE,GAAG,IAAI,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC,GAAG,CAAC,CAAC,CAC9C,CAAC;AACH,SAAA;AAED,QAAA,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC,WAAW,CAChC,eAAe,CAAC,aAAa,CAAC,6BAA6B,CAAC,EAC5D,IAAI,CAAC,EAAE,CACR,CAAC;KACH;;AA9MM,kBAAI,CAAA,IAAA,GAAG,IAAI;;;;"}
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../src/index.ts"],"sourcesContent":["import { JsPsych, JsPsychPlugin, ParameterType, TrialType } from \"jspsych\";\n\nimport { version } from \"../package.json\";\n\nconst info = <const>{\n name: \"survey-likert\",\n version: version,\n parameters: {\n /** Array containing one or more objects with parameters for the question(s) that should be shown on the page. */\n questions: {\n type: ParameterType.COMPLEX,\n array: true,\n nested: {\n /** Question prompt. */\n prompt: {\n type: ParameterType.HTML_STRING,\n default: undefined,\n },\n /** Array of likert labels to display for this question. */\n labels: {\n type: ParameterType.STRING,\n array: true,\n default: undefined,\n },\n /** Whether or not a response to this question must be given in order to continue. */\n required: {\n type: ParameterType.BOOL,\n default: false,\n },\n /** Name of the question in the trial data. If no name is given, the questions are named Q0, Q1, etc. */\n name: {\n type: ParameterType.STRING,\n default: \"\",\n },\n },\n },\n /** If true, the order of the questions in the 'questions' array will be randomized. */\n randomize_question_order: {\n type: ParameterType.BOOL,\n default: false,\n },\n /** HTML-formatted string to display at top of the page above all of the questions. */\n preamble: {\n type: ParameterType.HTML_STRING,\n default: null,\n },\n /** Width of the likert scales in pixels. */\n scale_width: {\n type: ParameterType.INT,\n default: null,\n },\n /** Label of the button to submit responses. */\n button_label: {\n type: ParameterType.STRING,\n default: \"Continue\",\n },\n /** Setting this to true will enable browser auto-complete or auto-fill for the form. */\n autocomplete: {\n type: ParameterType.BOOL,\n default: false,\n },\n },\n data: {\n /** 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. */\n response: {\n type: ParameterType.COMPLEX,\n nested: {\n identifier: {\n type: ParameterType.STRING,\n },\n response: {\n type:\n ParameterType.STRING |\n ParameterType.INT |\n ParameterType.FLOAT |\n ParameterType.BOOL |\n ParameterType.OBJECT,\n },\n },\n },\n /** 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. */\n rt: {\n type: ParameterType.INT,\n },\n /** 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. */\n question_order: {\n type: ParameterType.INT,\n array: true,\n },\n },\n};\n\ntype Info = typeof info;\n\n/**\n * The survey-likert plugin displays a set of questions with Likert scale responses. The participant responds\n * by selecting a radio button.\n *\n * @author Josh de Leeuw\n * @see {@link https://www.jspsych.org/latest/plugins/survey-likert/ survey-likert plugin documentation on jspsych.org}\n */\nclass SurveyLikertPlugin implements JsPsychPlugin<Info> {\n static info = info;\n\n constructor(private jsPsych: JsPsych) {}\n\n trial(display_element: HTMLElement, trial: TrialType<Info>) {\n if (trial.scale_width !== null) {\n var w = trial.scale_width + \"px\";\n } else {\n var w = \"100%\";\n }\n\n var html = \"\";\n // inject CSS for trial\n html += '<style id=\"jspsych-survey-likert-css\">';\n html +=\n \".jspsych-survey-likert-statement { display:block; font-size: 16px; padding-top: 40px; margin-bottom:10px; }\" +\n \".jspsych-survey-likert-opts { list-style:none; width:\" +\n w +\n \"; margin:auto; padding:0 0 35px; display:block; font-size: 14px; line-height:1.1em; }\" +\n \".jspsych-survey-likert-opt-label { line-height: 1.1em; color: #444; }\" +\n \".jspsych-survey-likert-opts:before { content: ''; position:relative; top:11px; /*left:9.5%;*/ display:block; background-color:#efefef; height:4px; width:100%; }\" +\n \".jspsych-survey-likert-opts:last-of-type { border-bottom: 0; }\" +\n \".jspsych-survey-likert-opts li { display:inline-block; /*width:19%;*/ text-align:center; vertical-align: top; }\" +\n \".jspsych-survey-likert-opts li input[type=radio] { display:block; position:relative; top:0; left:50%; margin-left:-6px; }\";\n html += \"</style>\";\n\n // show preamble text\n if (trial.preamble !== null) {\n html +=\n '<div id=\"jspsych-survey-likert-preamble\" class=\"jspsych-survey-likert-preamble\">' +\n trial.preamble +\n \"</div>\";\n }\n\n if (trial.autocomplete) {\n html += '<form id=\"jspsych-survey-likert-form\">';\n } else {\n html += '<form id=\"jspsych-survey-likert-form\" autocomplete=\"off\">';\n }\n\n // add likert scale questions ///\n // generate question order. this is randomized here as opposed to randomizing the order of trial.questions\n // so that the data are always associated with the same question regardless of order\n var question_order = [];\n for (var i = 0; i < trial.questions.length; i++) {\n question_order.push(i);\n }\n if (trial.randomize_question_order) {\n question_order = this.jsPsych.randomization.shuffle(question_order);\n }\n\n for (var i = 0; i < trial.questions.length; i++) {\n var question = trial.questions[question_order[i]];\n // add question\n html += '<label class=\"jspsych-survey-likert-statement\">' + question.prompt + \"</label>\";\n // add options\n var width = 100 / question.labels.length;\n var options_string =\n '<ul class=\"jspsych-survey-likert-opts\" data-name=\"' +\n question.name +\n '\" data-radio-group=\"Q' +\n question_order[i] +\n '\">';\n for (var j = 0; j < question.labels.length; j++) {\n options_string +=\n '<li style=\"width:' +\n width +\n '%\"><label class=\"jspsych-survey-likert-opt-label\"><input type=\"radio\" name=\"Q' +\n question_order[i] +\n '\" value=\"' +\n j +\n '\"';\n if (question.required) {\n options_string += \" required\";\n }\n options_string += \">\" + question.labels[j] + \"</label></li>\";\n }\n options_string += \"</ul>\";\n html += options_string;\n }\n\n // add submit button\n html +=\n '<input type=\"submit\" id=\"jspsych-survey-likert-next\" class=\"jspsych-survey-likert jspsych-btn\" value=\"' +\n trial.button_label +\n '\"></input>';\n\n html += \"</form>\";\n\n display_element.innerHTML = html;\n\n display_element.querySelector(\"#jspsych-survey-likert-form\").addEventListener(\"submit\", (e) => {\n e.preventDefault();\n // measure response time\n var endTime = performance.now();\n var response_time = Math.round(endTime - startTime);\n\n // create object to hold responses\n var question_data = {};\n var matches = display_element.querySelectorAll<HTMLFormElement>(\n \"#jspsych-survey-likert-form .jspsych-survey-likert-opts\"\n );\n for (var index = 0; index < matches.length; index++) {\n var id = matches[index].dataset[\"radioGroup\"];\n var el = display_element.querySelector<HTMLInputElement>(\n 'input[name=\"' + id + '\"]:checked'\n );\n if (el === null) {\n var response: string | number = \"\";\n } else {\n var response: string | number = parseInt(el.value);\n }\n var obje = {};\n if (matches[index].attributes[\"data-name\"].value !== \"\") {\n var name = matches[index].attributes[\"data-name\"].value;\n } else {\n var name = id;\n }\n obje[name] = response;\n Object.assign(question_data, obje);\n }\n\n // save data\n var trial_data = {\n rt: response_time,\n response: question_data,\n question_order: question_order,\n };\n\n // next trial\n this.jsPsych.finishTrial(trial_data);\n });\n\n var startTime = performance.now();\n }\n\n simulate(\n trial: TrialType<Info>,\n simulation_mode,\n simulation_options: any,\n load_callback: () => void\n ) {\n if (simulation_mode == \"data-only\") {\n load_callback();\n this.simulate_data_only(trial, simulation_options);\n }\n if (simulation_mode == \"visual\") {\n this.simulate_visual(trial, simulation_options, load_callback);\n }\n }\n\n private create_simulation_data(trial: TrialType<Info>, simulation_options) {\n const question_data = {};\n let rt = 1000;\n\n for (const q of trial.questions) {\n const name = q.name ? q.name : `Q${trial.questions.indexOf(q)}`;\n question_data[name] = this.jsPsych.randomization.randomInt(0, q.labels.length - 1);\n rt += this.jsPsych.randomization.sampleExGaussian(1500, 400, 1 / 200, true);\n }\n\n const default_data = {\n response: question_data,\n rt: rt,\n question_order: trial.randomize_question_order\n ? this.jsPsych.randomization.shuffle([...Array(trial.questions.length).keys()])\n : [...Array(trial.questions.length).keys()],\n };\n\n const data = this.jsPsych.pluginAPI.mergeSimulationData(default_data, simulation_options);\n\n this.jsPsych.pluginAPI.ensureSimulationDataConsistency(trial, data);\n\n return data;\n }\n\n private simulate_data_only(trial: TrialType<Info>, simulation_options) {\n const data = this.create_simulation_data(trial, simulation_options);\n\n this.jsPsych.finishTrial(data);\n }\n\n private simulate_visual(trial: TrialType<Info>, simulation_options, load_callback: () => void) {\n const data = this.create_simulation_data(trial, simulation_options);\n\n const display_element = this.jsPsych.getDisplayElement();\n\n this.trial(display_element, trial);\n load_callback();\n\n const answers = Object.entries(data.response);\n for (let i = 0; i < answers.length; i++) {\n this.jsPsych.pluginAPI.clickTarget(\n display_element.querySelector(\n `input[type=\"radio\"][name=\"${answers[i][0]}\"][value=\"${answers[i][1]}\"]`\n ),\n ((data.rt - 1000) / answers.length) * (i + 1)\n );\n }\n\n this.jsPsych.pluginAPI.clickTarget(\n display_element.querySelector(\"#jspsych-survey-likert-next\"),\n data.rt\n );\n }\n}\n\nexport default SurveyLikertPlugin;\n"],"names":["version"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAIA,MAAM,IAAc,GA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AAC7F,IAAA,MAAM,IAAO,GAAA,IAAA,CAAK,sBAAuB,CAAA,KAAA,EAAO,kBAAkB,CAAA,CAAA;AAElE,IAAM,MAAA,eAAA,GAAkB,IAAK,CAAA,OAAA,CAAQ,iBAAkB,EAAA,CAAA;AAEvD,IAAK,IAAA,CAAA,KAAA,CAAM,iBAAiB,KAAK,CAAA,CAAA;AACjC,IAAc,aAAA,EAAA,CAAA;AAEd,IAAA,MAAM,OAAU,GAAA,MAAA,CAAO,OAAQ,CAAA,IAAA,CAAK,QAAQ,CAAA,CAAA;AAC5C,IAAA,KAAA,IAAS,CAAI,GAAA,CAAA,EAAG,CAAI,GAAA,OAAA,CAAQ,QAAQ,CAAK,EAAA,EAAA;AACvC,MAAA,IAAA,CAAK,QAAQ,SAAU,CAAA,WAAA;AAAA,QACrB,eAAgB,CAAA,aAAA;AAAA,UACd,CAA6B,0BAAA,EAAA,OAAA,CAAQ,CAAG,CAAA,CAAA,CAAA,CAAA,CAAA,UAAA,EAAe,QAAQ,CAAG,CAAA,CAAA,CAAA,CAAA,CAAA,EAAA,CAAA;AAAA,SACpE;AAAA,QAAA,CACE,IAAK,CAAA,EAAA,GAAK,GAAQ,IAAA,OAAA,CAAQ,UAAW,CAAI,GAAA,CAAA,CAAA;AAAA,OAC7C,CAAA;AAAA,KACF;AAEA,IAAA,IAAA,CAAK,QAAQ,SAAU,CAAA,WAAA;AAAA,MACrB,eAAA,CAAgB,cAAc,6BAA6B,CAAA;AAAA,MAC3D,IAAK,CAAA,EAAA;AAAA,KACP,CAAA;AAAA,GACF;AACF,CAAA;AA9MM,kBAAA,CACG,IAAO,GAAA,IAAA;;;;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jspsych/plugin-survey-likert",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.0",
|
|
4
4
|
"description": "a jspsych plugin for measuring items on a likert scale",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.cjs",
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
"jspsych": ">=7.1.0"
|
|
38
38
|
},
|
|
39
39
|
"devDependencies": {
|
|
40
|
-
"@jspsych/config": "^
|
|
41
|
-
"@jspsych/test-utils": "^1.
|
|
40
|
+
"@jspsych/config": "^3.0.0",
|
|
41
|
+
"@jspsych/test-utils": "^1.2.0"
|
|
42
42
|
}
|
|
43
43
|
}
|
package/src/index.spec.ts
CHANGED
|
@@ -30,7 +30,7 @@ describe("survey-likert plugin", () => {
|
|
|
30
30
|
selectInput("Q3", "3").checked = true;
|
|
31
31
|
selectInput("Q4", "4").checked = true;
|
|
32
32
|
|
|
33
|
-
clickTarget(document.querySelector("#jspsych-survey-likert-next"));
|
|
33
|
+
await clickTarget(document.querySelector("#jspsych-survey-likert-next"));
|
|
34
34
|
|
|
35
35
|
await expectFinished();
|
|
36
36
|
|