/
index.html
354 lines (278 loc) · 10.7 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
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
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
<!doctype html>
<!-- prosodylab-jspsych-experimenter Michael Wagner chael@mcgill.ca-->
<html>
<head>
<title>prosodylab</title>
<meta charset="utf-8">
<script src="prosodylab/setupHead.js"></script>
</head>
<body></body>
<script>
// ---- settings ----
// path and study file:
let study = {
path: 'experiment', // contains folders with audio/images if applicable
stimulusFile: 'rhymeShortest.tsv'
};
// other settings for study:
study = {...study,
//
testRun: true, // **if true, no data will be recorded**
//
align: true,
//
language: 'en', // set which language interaction will be in
//
logFile: `${study.path}/studyLog.json`, // this is where log will be saved
soundCheckFile: `prosodylab/soundcheck_da.mp3`,// file played for soundcheck
recordingTimeOut: 10000, // audio recording stops after x ms; default: 20000
//
// completion code and completionLink are used,
completionLink: "", // link to send participant after end, e.g. for Prolific studies
completionCode: "", // not necessary unless it will be displayed at the end
//
//
pListMethod: 'log',/* Some designs (Blocked, Between, LatinSquare, Within)
assign different types of playlists to different participants.
-- 'log' = use log to count which playlist has been run least
-- 'random' (assigns pList randomly)
-- or set an integer (like '1') to hardcode the pList here
*/
participantCodeMethod: 'randomAndDisplay', /* alternative methods to determine participant ID. Options:
* SESSION_ID // default for prolific prosodylab, more confidential than PID
* PROLIFIC_PID
* random
* randomAndDisplay // default in prosody for amazon
PROLIFIC_SESSION_ID and PROLIFIC_PID requires passing urlparams from prolific
*/
//
// Various options settings:
displayDataAfterFinish: false, // shows collected data in json format after
showProgressBar: true, // shows progress to participant during study
fullScreen: false, // doesn't work with IE, but will simply proceed anyway
//
// Switch certain components of study on or off
hello: true,
consent: true,
languageQuestionnaire: true,
soundCheck: false,
micCheck: true,
headphoneScreener: {
includeHeadphoneScreener: false,
stimuli: 'original', // options: ['short','original'],
numberChances: 1, // how many attempts do participants get?
threshold: 5/6, // if equal or higher, participant passes,
// exclude participant on fail?
excludeOnFail: false, // end experiment if participant fails after last attempt
// set link if participant should be redirected:
completionFailLink: "",
// set fail message here, other default from prosodylab/messages.tsv will be used
failMessage: ""
},
experimentSessions: true,
postExperimentQuestionnaire: true,
musicQuestionnaire: false,
goodbye: false,
thankYou: true,
experimentOnly: false // excludes pre- and post-experiment parts, overrides prior flags, useful for testing
//
};
// contact Email in case of problem with urlparameter transmission of participant info
const contactEmail = ''
// load messages for country and region dropdown in correct language
setup.loadGeoDataMessages('en');
Promise.all(setup.scriptPromises(study.language))
.then(function () {
// load messages for interaction with participant:
messages = prosodylab.getMessages(study.language);
// Get urlParams if there are any
let urlParams = prosodylab.getURLParameters();
let participantCode = prosodylab.assignParticipantcode(study.participantCodeMethod,urlParams)
// ---- set-up timeline for experiment ----
let timeline = []; // this is where experiment will be stored
let mdFile = []; // used for filenames of .md files
// files that should be preloaded
preload = { images: [],
audio: []
};
// Only continue if participantCode is defined
if (!participantCode) {
// urlParams weren't properly transmitted, throw error to participant
timeline.push(prosodylab.screen(`<em>Something didn't work! Contact: ${contactEmail}
</em>`,'noSessionIdError','Click here to leave experiment','center'));
} else {
// load spreadsheet with all experiments, global variable
stimuli = prosodylab.loadCSV(`${study.path}/${study.stimulusFile}`);
// console.log('stimuli',stimuli);
// set experiment mode if specified in urlParams
let mode = [];
if(urlParams.get('mode')) {
mode = urlParams.get('mode');
if (mode=='test') {
study.testRun = true;
} else if (mode=='experiment'){
study.experimentOnly = true;
study.fullScreen = false;
} else if (mode=='finalPart'){
study.experimentOnly = true;
}
}
let selectSession = 'all';
if(urlParams.get('session')) {
selectSession = urlParams.get('session');
study.experimentOnly = true;
study.fullScreen = false;
}
// set recordOption if specified in urlParams
if(urlParams.get('recordOption')) {
let recordOption = urlParams.get('recordOption');
if(recordOption=='rerecord'){
stimuli = stimuli.map(obj=> ({ ...obj, recordOption: 'rerecord'}));
} else if (recordOption=='play'){
stimuli = stimuli.map(obj=> ({ ...obj, recordOption: 'play'}));
}
}
// Set name for response file with participant code
const dataFilename = `data_${participantCode}`;
// add experiment settings to experiment data json
timeline.push(prosodylab.storeExperimentSettings(study));
// ---- hello page ----
if (study.hello&!study.experimentOnly){
mdFile = [];
if (!stimuli[0].hello) {
mdFile = `${study.path}/hello.md`;
} else {
mdFile = `${study.path}/${stimuli[0].hello}`;
}
timeline.push(prosodylab.screenFromMD(mdFile,'hello','left'));
}
// ----- warning flag if no data is recorded
if (study.testRun){
timeline.push(prosodylab.noDataRecordedFlag());
}
// ---- sound check (if audio is involved)
if (study.soundCheck&!study.experimentOnly){
preload.audio.push(study.soundCheckFile);
preload.images.push('prosodylab/headphones_frieda.jpg');
timeline = [...timeline, ...prosodylab.soundCheck(study.soundCheckFile)];
}
// ---- mic check (should be done if recording is involved)
// you can pass sentence that participant should produce as argument
if (study.micCheck&!study.experimentOnly){
prosodylab.audioRecorder(study.testRun,true);
soundFilePath = `${study.path}/dataSound/`;
soundFileName = `miccheck_${participantCode}`;
timeline = [...timeline, ...prosodylab.micCheck(soundFileName,soundFilePath,study.recordingTimeOut)];
}
// ---- consent page ----
// The last paragraph of the consent form will be the consent button
// and will be stored with the participant's data:
if (study.consent&!study.experimentOnly){
mdFile = [];
if (!stimuli[0].consent) {
mdFile = `${study.path}/consent.md`;
} else {
mdFile = `${study.path}/${stimuli[0].consent}`;
}
timeline.push(prosodylab.screenFromMD(mdFile,'consent','left'));
}
// ---- head phone screener ----
if (study.headphoneScreener.includeHeadphoneScreener&!study.experimentOnly){
timeline = [...timeline, ...headphoneScreener(study.headphoneScreener)];
}
// ---- language questionnaire ---
if (study.languageQuestionnaire&!study.experimentOnly){
timeline.push(prosodylab.languageQuestionnaire(study.language));
}
// ---- full screen mode if applicable --
if (study.fullScreen&!study.experimentOnly) {
timeline.push(prosodylab.fullScreenOn());
}
//
// ---- build sessions of experiment trials and add to timeline ----
//
if((study.experimentSessions||experimentOnly)&!(mode=='finalPart')){
experiment =
prosodylab.createSessions(stimuli,study,participantCode,messages,selectSession);
timeline = [...timeline, ...experiment.timeline];
}
// Post Experiment
// ---- post-experiment questionnaire ---
if (study.postExperimentQuestionnaire&(!study.experimentOnly||mode=='finalPart')){
timeline.push(prosodylab.postExperimentQuestionnaire(study.language));
}
// ---- music questionnaire ---
if (study.musicQuestionnaire&(!study.experimentOnly||mode=='finalPart')){
timeline.push(prosodylab.musicQuestionnaire('MusicianShip'));
}
// ---- save data ----
if(!study.testRun) {
// use 'csv' as second argument if you want to save as .csv instead of json
timeline.push(prosodylab.saveData(`${study.path}/data/${dataFilename}`,'json'));
if (mode!='finalPart') {
timeline.push(prosodylab.appendJsonCallFunction(
experiment.newStudyLogEntries,study.logFile));
}
}
// exit full screen
if ((study.fullScreen&!study.experimentOnly)) {
timeline.push({
type: 'fullscreen',
fullscreen_mode: false
});
}
// ---- goodbye screen (with completion code if applicable )----
if (study.goodbye&(!study.experimentOnly||mode=='finalPart')){
if (study.participantCodeMethod == 'randomAndDisplay') {
mdFile = [];
if (!stimuli[0].goodbye) {
mdFile = `${study.path}/goodbye.md`;
} else {
mdFile = `${study.path}/${stimuli[0].goodbye}`;
}
timeline.push(prosodylab.screenFromMD(mdFile,'goodbye','center',participantCode));
} else if (study.completionCode) {
timeline.push(prosodylab.screenFromMD(mdFile, 'goodBye','center', completionCode));
} else {
timeline.push(prosodylab.screenFromMD(mdFile,'goodBye','center'));
}
}
// ---- thank you message
if (study.thankYou&(!study.experimentOnly||mode=='finalPart')){
timeline.push(prosodylab.thankYouFlag());
}
}
// ---- general settings ----
if (preload.images.length!=0){
console.log('Number of images to preload: ',preload.images.length);
}
if (preload.audio.length!=0){
console.log('Number of soundfiles to preload: ',preload.audio.length);
}
jsPsych.init({
timeline: timeline,
preload_audio: preload.audio,
preload_images: preload.images,
//// uncomment to save data on close (but closing the tab could mean wihdrawn consent!)
//on_close: function(){
// prosodylab.saveData(`${study.path}/data/${dataFilename}.json, jsPsych.data.get().json());
// prosodylab.saveData(`${study.path}/data/${dataFilename}.csv, jsPsych.data.get().csv());
//},
show_progress_bar: study.showProgressBar,
on_finish: function(){
if (study.displayDataAfterFinish) {
// output full data to tab
jsPsych.data.displayData();
}
if (study.completionLink&&participantCode) {
if (study.completionLink.length>0){
location.href=study.completionLink
}
}
}
})
}).catch((reason) => {
console.log(reason);
});
</script>
</html>