-
Notifications
You must be signed in to change notification settings - Fork 0
/
WFjudges.html
384 lines (339 loc) · 15 KB
/
WFjudges.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
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>exp</title>
<script src="jsPsych-6.1.0/jspsych.js"></script>
<script src="jsPsych-6.1.0/plugins/jspsych-fullscreen.js"></script>
<script src="jsPsych-6.1.0/plugins/jspsych-html-button-response.js"></script>
<script src="jsPsych-6.1.0/plugins/jspsych-survey-likert.js"></script>
<script src="jsPsych-6.1.0/plugins/jspsych-survey-multi-choice.js"></script>
<script src="jsPsych-6.1.0/plugins/jspsych-survey-text.js"></script>
<script src="js/jquery.min.js"></script>
<script src="js/lodash.min.js"></script>
<script src="js/firebase.js"></script>
<link href="jsPsych-6.1.0/css/jspsych.css" rel="stylesheet" type="text/css">
<style>
body {
cursor: default;
}
.jspsych-content-wrapper {
width: 800px;
height: 600px;
}
.imgJudge {
width: 200px;
margin: 20px 10px 10px 140px;
padding: 0px;
}
.displayCI {
width: 100px;
margin: 10px;
padding: 0px;
}
.scaleInfo {
margin-bottom: 20px;
color: steelblue;
font-style: italic;
}
</style>
</head>
<body></body>
<script>
// Parameters
var n = 10; // number of pairs of CIs (Walloon + Fleming) randomly sampled (default: 10)
var CIsPath = 'WFcis/'; // CIs' path
var prolificLink = "https://app.prolific.co/submissions/complete?cc=73561B39";
// Initial variables
var timeline = [];
var preloadimages = [];
var id = jsPsych.data.getURLVariable("id"); // Need to add ?id={{%PROLIFIC_PID%}} at the end of the prolific survey link!
if (id == null) { id = jsPsych.randomization.randomID(15) };
// Creators IDs
var creators_ids = [
'v1xtmb6drnu5hrl', 'e6op563uq4g2w2k', 'z4sfdbsjfngessw', 'k1m856nl8rpa9be',
'8erglqb2zkwb6ef', 'pq14ohmhhbwp3op', 'r9bplx8rufycbcc', 'r2cadhv30gt0xr7',
'68cbeqd8916jmhy', 'fr7orot5hen3elx', 'e4w87oslxzgensy', 'vytle6fbc0vw70a',
'1hrcql49jsa0vf2', '7svsmx9s3vyup8c', '75bq5eorsu87h7g', 'ahv4ono0mconwhx',
'8m1ruwb7e80u2pc', 'rwesvqm1x1krks8', 'wmvyof6b8c57u47', 'womh49tkhokwulr',
'socagxd09ysrssr', 'h3l7yahskn1le96', 'lxv5rg6lmt3awmb', 'ejp0kca99zq4uz3',
'ejxfyrsalerj60t', 'bbanvd6o2pbp9qz', 'k2as8u5um1tklgs', '413mum4p9lhhfsy',
't7utj8juxv9x4mg', 'yqbozd45g4vt7ld', 'xeq29nygwh1djg1', 'f62sb97pldjfnr3',
'ujk2onwyge4mwd5', 'hpkce3jm9se0bdu', '94xf1rxt72jbv20', 'ro4pujv195dbfwf',
'7j2cqaf1hjlaaxk', 'xc9hsr49dvcyph0', 'hklbubz6ogo3qg3', 'olxvzqfrs549bgd',
'4ob1rh1va5qb06a', '73wvjnaobfjng7n', '25nv3nc56wr611w', 'j5zpv1qw1glcm3a',
'rjnurg1q1hnsm63', 'bfm1564ohktu75l', '1dtyaytmx978jc0', 'toov0q2v4tfg3z8',
'bkd1yb0ncsguc3v', '1ved7usv0qwhuhc', 'rvnr91bmwmngccv', 'rv5pzg6zk9ypa18',
'scqucck5fhula4c', 'rf1r18nab27v1bb', 'aq0lmpb0mdgaw90', 'zzqpakqs0xwurgz',
'48gw1s7p5rdrkcc', '3zhsm9p7getd7jq', '05xvrsxkexrpcmf', '9ykuyalylq22shb',
'e3cfyyjzjftsgfv', 'g6yxl0hmuafyjzk', 'lmfzp125c09j6vz', 'jzkn238dto3occp',
'dz2k4y1l6nsc1a9', 'zl09f3vhdl9g8nc', '3h76y9yaw3kfwqa', '2c6odomkjtkea4k',
'tnfepojwaqhembo', 'sqjq8p3vhj5os0f', 'bx81rlbancqzqq2', '05qjeb2vbv8y9en'
];
var sampled_creators_ids = _.sampleSize(creators_ids, n);
// Individual CIs
var CIsIndStims = [];
sampled_creators_ids.map(function (e) {
CIsIndStims.push(CIsPath + 'ind_Wallon_' + e + '.png');
CIsIndStims.push(CIsPath + 'ind_Flamand_' + e + '.png');
});
CIsIndStims = _.flattenDeep(CIsIndStims);
preloadimages.push(CIsIndStims);
CIsIndStims = CIsIndStims.map(function (e) { return { imgHtml: "<img class='imgJudge' src='" + e + "'>" } }); // add img html format
CIsIndStims = _.flattenDeep(CIsIndStims);
CIsIndStims = _.shuffle(CIsIndStims); // randomize order
// Average CIs
var cis_avg = ["avg_Flamand.png", "avg_Wallon.png"];
var CIsAvgStims = cis_avg.map(function (e) { return CIsPath + e }); // add URL path
preloadimages.push(CIsAvgStims);
CIsAvgStims = CIsAvgStims.map(function (e) { return { imgHtml: "<img class='imgJudge' src='" + e + "'>" } });
CIsAvgStims = _.shuffle(CIsAvgStims); // randomize order
// EXPERIMENT --------------------------------------------------------------------------------------------------------
/* Consent */
var fullScreenConsent = {
button_label: "I accept to participate in this study",
type: 'fullscreen',
fullscreen_mode: true,
delay_after: 200,
message: function () {
html = "";
html += "<h1>Informed Consent</h1>";
html += "<p class='justify'>In this study about face perception you will be asked to rate several faces. ";
html += "It is important that you remain <b>concentrated throughout the task</b>.</br></br>";
html += "Your participation is voluntary, does not imply any risks, your answers will be ";
html += "anonymous, and you are free to withdraw from the study at any moment. After full completion, ";
html += "you will receive a <b>monetary compensation</b> as stated in the Prolific ";
html += "description of this experiment.</br></br>";
html += "This study is administrated by Mathias Schmitz, PhD student at the UCLouvain (Belgium).</br></br>";
html += "If you have any questions or comments please contact me at ";
html += "[email protected]</p>";
return html;
},
};
/* Ind CIs instructions */
var rateIndInst = {
type: "html-button-response",
post_trial_gap: 300,
choices: ['Start'],
stimulus: function () {
var html = "";
html += "<h1>Instructions</h1>";
html += "<p class='justify'>In this first task, we will present you 20 faces, one at a time. ";
html += "Your task is to rate each face on 12 traits. ";
html += "To do so, use the following scale: from <span class='scaleInfo'>1 = Not at all</span> to <span class='scaleInfo'>7 = Very much</span>.</br></br>";
html += "Try to be as <b>spontaneous</b> as possible and try to rely on your <b>first impression</b>.</br></br>";
html += "Notice that these faces have been blurred in order to make the task a bit more challenging and to preserve the anonimity of the person. ";
html += "Below are displayed some of the faces you will have to rate for you to better gauge the differences.</br></br>";
html += "<img class='displayCI' src='WFcis/ind_Wallon_8erglqb2zkwb6ef.png'>";
html += "<img class='displayCI' src='WFcis/ind_Flamand_73wvjnaobfjng7n.png'>";
html += "<img class='displayCI' src='WFcis/ind_Wallon_rf1r18nab27v1bb.png'>";
html += "<img class='displayCI' src='WFcis/ind_Flamand_hpkce3jm9se0bdu.png'>";
html += "<img class='displayCI' src='WFcis/ind_Wallon_womh49tkhokwulr.png'>";
html += "<img class='displayCI' src='WFcis/ind_Flamand_ahv4ono0mconwhx.png'>";
html += "</br>Please remain <b>concentrated</b>.</p>";
return html;
},
};
/* Ind CIs ratings */
var scaleInfo = "</br><span class='scaleInfo'>" +
"                  " +
"           " +
"Not at all " +
"                  " +
"                  " +
"                  " +
"          " +
"Very much</span>"
var scale = ["1", "2", "3", "4", "5", "6", "7"];
var itemsTraits = ['Warm', 'Sociable', 'Friendly', 'Competent', 'Efficient', 'Hard-working', 'Trustworthy', 'Reliable', 'Honest', 'Dominant', 'Physically strong', 'Masculine'];
var traitList = [];
itemsTraits.map(function (item) { traitList.push({ prompt: item, labels: scale, required: true }); });
var rateIndCIs = [];
CIsIndStims.map(function (ciImg) {
var likert_trial = {
type: 'survey-likert',
scale_width: 500,
preamble: ciImg.imgHtml + scaleInfo,
questions: traitList,
randomize_question_order: true,
button_label: 'Continue',
on_load: function () {
$(".jspsych-content-wrapper").css("height", "auto");
$(".jspsych-content-wrapper").scrollTop(0);
$(".jspsych-survey-likert-statement").css("margin", "0");
$(".jspsych-survey-likert-statement").css("padding", "0");
$(".jspsych-survey-likert-statement").css("float", "left");
$(".jspsych-survey-likert-opts").css("padding", "0 0 10px");
$(".jspsych-survey-likert-opts").css("margin", "0 0 0 130px");
$("li").css("width", "60px");
$("#jspsych-survey-likert-next").css("margin", "10px 0 20px 0");
},
on_finish: function (data) {
$(".jspsych-content-wrapper").css("height", "600px");
$(".jspsych-survey-likert-statement").css("margin", "auto");
data.ci = ciImg.imgHtml;
var parsed_response = JSON.parse(data.responses);
data.W_warm = parsed_response.Q0 + 1;
data.W_sociable = parsed_response.Q1 + 1;
data.W_friendly = parsed_response.Q2 + 1;
data.C_competent = parsed_response.Q3 + 1;
data.C_efficient = parsed_response.Q4 + 1;
data.C_hardworking = parsed_response.Q5 + 1;
data.T_trustworthy = parsed_response.Q6 + 1;
data.T_reliable = parsed_response.Q7 + 1;
data.T_honest = parsed_response.Q8 + 1;
data.D_dominant = parsed_response.Q9 + 1;
data.D_strong = parsed_response.Q10 + 1;
data.D_masculine = parsed_response.Q11 + 1;
console.log(data);
},
};
rateIndCIs.push(likert_trial);
});
var rateAvgInst = {
type: "html-button-response",
post_trial_gap: 300,
choices: ['Start'],
stimulus: function () {
var html = "";
html += "<h1>Instructions</h1>";
html += "<p class='justify'>In thi last task, we will present you another set of two faces that are shown below.</br></br>";
html += "Your task is the same: rate each of these two face on the 12 traits.</p>";
html += "<img class='displayCI' src='WFcis/avg_Wallon.png'>";
html += "<img class='displayCI' src='WFcis/avg_Flamand.png'>";
return html;
},
};
var rateAvgCIs = [];
CIsAvgStims.map(function (ciImg) {
var likert_trial = {
type: 'survey-likert',
scale_width: 500,
preamble: ciImg.imgHtml + scaleInfo,
questions: traitList,
randomize_question_order: true,
button_label: 'Continue',
on_load: function () {
$(".jspsych-content-wrapper").css("height", "auto");
$(".jspsych-content-wrapper").scrollTop(0);
$(".jspsych-survey-likert-statement").css("margin", "0");
$(".jspsych-survey-likert-statement").css("padding", "0");
$(".jspsych-survey-likert-statement").css("float", "left");
$(".jspsych-survey-likert-opts").css("padding", "0 0 10px");
$(".jspsych-survey-likert-opts").css("margin", "0 0 0 130px");
$("li").css("width", "60px");
$("#jspsych-survey-likert-next").css("margin", "10px 0 20px 0");
},
on_finish: function (data) {
$(".jspsych-content-wrapper").css("height", "600px");
$(".jspsych-survey-likert-statement").css("margin", "auto");
data.ci = ciImg.imgHtml;
var parsed_response = JSON.parse(data.responses);
data.W_warm = parsed_response.Q0 + 1;
data.W_sociable = parsed_response.Q1 + 1;
data.W_friendly = parsed_response.Q2 + 1;
data.C_competent = parsed_response.Q3 + 1;
data.C_efficient = parsed_response.Q4 + 1;
data.C_hardworking = parsed_response.Q5 + 1;
data.T_trustworthy = parsed_response.Q6 + 1;
data.T_reliable = parsed_response.Q7 + 1;
data.T_honest = parsed_response.Q8 + 1;
data.D_dominant = parsed_response.Q9 + 1;
data.D_strong = parsed_response.Q10 + 1;
data.D_masculine = parsed_response.Q11 + 1;
console.log(data);
},
};
rateAvgCIs.push(likert_trial);
});
/* Demographics */
var age = {
timeline: [{
type: 'survey-text',
questions: [{ prompt: "Indicate your age:", rows: 1, columns: 10 }],
button_label: "Continue",
}],
loop_function: function (data) {
var age = data.values()[0].responses;
var age = JSON.parse(age).Q0;
if (age == "") {
alert("Please answer this question");
return true;
}
},
on_finish: function (data) {
jsPsych.data.addProperties({
age: JSON.parse(data.responses)["Q0"],
});
},
};
var genderOptions = ['Male', 'Female', 'Other'];
var gender = {
type: 'survey-multi-choice',
questions: [{ prompt: "Please indicate your gender :", options: genderOptions, required: true }],
button_label: "Continue",
on_finish: function (data) {
jsPsych.data.addProperties({
gender: JSON.parse(data.responses)["Q0"],
});
},
};
/* Debriefing */
var debriefing = {
type: "html-button-response",
post_trial_gap: 300,
choices: ['continue'],
stimulus: function () {
var html = "";
html += "<h1>Debriefing</h1>";
html += "<p class='justify'>Thank you for taking part in this study!</br></br>";
html += "The aim of this research was to simply asses participant's perception of these faces.</br></br>";
html += 'Feel free to contact me if you have any question or comment regarding this study.</br></br></br>';
html += "<u>Please click on the button <i>continue</i> to validate your participation on prolific.</u></p>";
return html;
}
};
preloadimages = _.flattenDeep(preloadimages);
// TIMELINE ----------------------------------------------------------------------------------------------------------
timeline.push(fullScreenConsent);
timeline.push(rateIndInst);
timeline.push(rateIndCIs);
timeline.push(rateAvgInst);
timeline.push(rateAvgCIs);
timeline.push(age);
timeline.push(gender);
timeline.push(debriefing);
timeline = _.flattenDeep(timeline);
// INITIALISE EXP ----------------------------------------------------------------------------------------------------
jsPsych.init({
timeline: timeline,
preload_images: preloadimages,
max_load_time: 500 * 1000,
exclusions: {
min_width: 800,
min_height: 600,
},
on_finish: function (data) {
$("#jspsych-content").html("<img src='https://i.gifer.com/4V0b.gif'>");
/* Initialize Firebase */
var config = {
apiKey: "AIzaSyD4r9uWI4icto61fm2tC9neKdEiOUWzMJ8",
databaseURL: "https://biatw-68fe6.firebaseio.com/"
};
firebase.initializeApp(config);
var database = firebase.database();
/* jsPsych: add data to every trial */
jsPsych.data.addProperties({
id: id,
totalTime: jsPsych.totalTime()
});
var subdata = data.filter({ trial_type: 'survey-likert' }).csv();
/* Send data to Firebase and redirect to Qualtrics */
database.ref("WFjudges/" + id + "/").update({ subdata }).then(function () {
console.log("data sent!");
window.location = prolificLink; // Validate Prolific participation
});
}
});
</script>
</html>