-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtext_estimation.html
More file actions
310 lines (277 loc) · 12.2 KB
/
text_estimation.html
File metadata and controls
310 lines (277 loc) · 12.2 KB
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
<!DOCTYPE html>
<html>
<head>
<title>sequenccollective_emotion_estimation_task</title>
<script src="jspsych-6.0.5/jspsych.js"></script>
<script src="jspsych-6.0.5/plugins/jspsych-image-button-response.js"></script>
<script src="jspsych-6.0.5/plugins/jspsych-survey-text.js"></script>
<script src="jspsych-6.0.5/plugins/jspsych-call-function.js"></script>
<script src="jspsych-6.0.5/plugins/jspsych-html-keyboard-response.js"></script>
<script src="jspsych-6.0.5/plugins/jspsych-html-button-response.js"></script>
<script src="jspsych-6.0.5/plugins/jspsych-survey-likert.js"></script>
<script src="jspsych-6.0.5/plugins/jspsych-image-keyboard-response.js"></script>
<script src="jspsych-6.0.5/plugins/jspsych-external-html.js"></script>
<script src="functions/text_estimation_functions.js"></script>
<script src="instructions/text_estimation_instructions.js"></script>
<script src="jspsych-6.0.5/plugins/jspsych-vsl-grid-scene1.js"></script>
<script src="jquery-3.3.1.min.js"></script>
<script src="textbase/word_list_positive.js"></script>
<script src="textbase/word_list_negative.js"></script>
<script src="https://sdk.amazonaws.com/js/aws-sdk-2.713.0.min.js"></script>
<link href="jspsych-6.0.5/css/jspsych.css" rel="stylesheet" type="text/css"></link>
</head>
<body>
<script>
/* ************************************* */
/* Set up jsPsych blocks - static */
/* ************************************ */
var taskNumber_sequential = 50; //must be mutiples of 5. The real trial number will have one extra due to attention check trial
var taskNumber_memory = 20; //must be mutiples of 5. The real trial number will have one extra due to attention check trial
var attentionCheckInterval = 5; //there will be an attention check every this number of trials
var practiceNumber = 1;
var attentionStimulus = loadStimulus(2); //preload 2 images for attention check
var Face = {}; //create Face dictionary to (1) record fixation time, (2)make face sample and scale have the same person and valence in every trial
Face.facePool = [ ]; //record face data
Face.wordList = ['but','rock','sky','our','course','we','table','house','here','mouth','tree', 'hello']; //word list for attention check
var imageTestDescription = attentionStimulus; //designed for the image test
var falseAnswer = 0; var falseAllowance = 4; //attention check - the amount of time participants rate the same picture before they get an alert
var repeatAlert = 0; var repeatAllowance = 2; //how many times they can get alerts before they are cicked out
//var facesPerSequence = 8;
var trial = 0; //Trial Counter
var trial_sequential = 0; //Trial Counter
var trial_memory = 0; //Trial Counter
var Response_Delay = [];
var wordsPerSequence = 2; // Difficulty of memory task
var vHeight = $(document).height();
var lineSlice = $(document).width();
/******************************************/
/* Start Experiment - trial by trial */
/******************************************/
var consent = {
type:'external-html',
url: "external_page.html",
cont_btn: "start",
check_fn: check_consent
};
var phone = {
type: 'image-button-response',
stimulus: '',
choices: ['Phone','Computer'],
prompt: "Are you using a mobile phone or computer to conduct the experiment?",
data: {Name:'phone'}
};
var checkPhone = { //to check if participant is using phone. If it's 'No', the experiment will be terminated
timeline: [phone],
loop_function: checkPhone
};
var enter_id = {
type: 'survey-text',
questions: [{prompt: 'Please enter your prolific id (this is important for your validation)'}],
on_finish: function(data){
Face.ID = JSON.parse(data.responses).Q0; //save id as global variable
jsPsych.data.addProperties({participant_id: Face.ID});} //record participant id
};
var participant_id = { //to check if participants have entered ID (number/character, no punctuation allowed)
timeline: [enter_id],
loop_function: checkID,
//loop_function: checkUser
};
var imageDescription = {
type: 'survey-text',
questions: [{prompt: "Please describe the picture in your own words"}],
preamble: function() {
var curr_stim = imageTestDescription.shift()
return '<img src='+curr_stim+'></img>';
},
on_finish: function(data){
saveDataToS3()
Face.description = JSON.parse(data.responses).Q0; } //save description
};
var fixationGetFace = { //getting new fixation time and face
type: 'html-keyboard-response',
stimulus: '<p style="font-size: 48px;">+</p>',
trial_duration: getTimeAndFace, //random select fixation time
data: {Name:'fixation'}
};
var fixation = { //only get new fixation time without changing face - in one series of face, there're different fixation time
type: 'html-keyboard-response',
stimulus: '<p style="font-size: 48px;">+</p>',
trial_duration: getFixationTime, //random select fixation time
data: {Name:'fixation'}
};
var face = { //there is an array of randomly selected pictures//
type: 'html-keyboard-response',
stimulus: getFaceSample,
trial_duration: 1000, //display faces for 0.5 second
choices: jsPsych.NO_KEYS,
data: function(){
Face.sum = parseInt(Face.sum) + parseInt(Face.emotionality);
return{
Name:'singleWord',
trial: trial,
emotionality: Face.emotionality,
valence: Face.valence,
valenceAlternative:Face.valence2,
word: Face.word,
wordNumber: Face.number,
wordRarety: Face.rarety
}},
};
/******************************************************************************
ERQ
*****************************************************************************/
const scale1 = [ // Scale for ERQ
"0 - Not at all Emotional",
"1",
"2",
"3",
"4",
"5",
"6",
"7",
"8",
"9 Very Emotional"
];
const response = {
type: 'survey-likert',
on_load: textbox,
questions: [{prompt: "Please rate the average emotionality of the words in the sequence (0: Not at all Emotional; 9: Very Emotional). </p>", labels: scale1, required:true}], //Q0
data: function(){ //we save all the data here to make it easy to analyze and process the data.
trial = trial + 1;
trial_memory = trial_sequential + 1;
return {
Name: 'response',
fixationTime: Face.fixationTime,
emotionCategory: Face.emotionX,
description: Face.description,
trial: trial,
emotionalitySum: Face.sum,
emotionalityMean: Face.sum / Face.number,
wordNumber: Face.number
}}
};
var memory = {
type: 'html-button-response',
stimulus: memoryWord,
choices: ['it was','it was NOT'],
prompt: "<p> Decide if this word <strong> was</strong> in the sequence or <strong>NOT</strong> </p>",
button_html: '<button class="jspsych-btn-jonas">%choice%</button>',
data: function(){ //we save all the data here to make it easy to analyze and process the data.
trial = trial + 1;
trial_memory = trial_memory + 1;
return {
Name: 'memory',
CorrectFaces: Face.facePool,
trial: trial,
trial_memory: trial_memory,
shownWords: Face.shownWords,
wordInSequence: Face.wordInSequence
}}
};
var askTypeWord = { //attention check - participants are asked to copy a word that appears on the screen
type: 'survey-text',
questions: function (){return [{prompt:'Please type the word: '+ getWord().bold() + ' (pay attention to capital letters)'}]},
};
var attentionCheck = { //function for the attention check
timeline: [askTypeWord],
loop_function: checkTyping,
on_start: function(data){
saveDataToS3()},
on_finish: function(data){
saveDataToS3()}
};
var connectSurvey = {
type: 'image-button-response',
stimulus: "",
choices: ['Begin Survey'],
on_finish: function(data){
saveDataToS3()}
};
/* create general instruction definition array */
var general_instruction_start = [];
//general_instruction_start.push(consent);
//general_instruction_start.push(checkPhone, imageDescription, participant_id, instruction_welcome_page);
/* create face average task definition array */
var collective_emotion_estimation = instruction_sequence; //display instructions
collective_emotion_estimation.push(fixationGetFace,attentionCheck);//attention check before practice task
for (var i = 0; i < practiceNumber; i++) { //practice trials
faceNumber = getWordnumber();;
for (var t = 0; t < faceNumber; t++) {
collective_emotion_estimation.push(fixation,face);}
collective_emotion_estimation.push(response); //response is main slide for amplification result, while memory is ending each trail and contains all information about memory task
};
collective_emotion_estimation.push(instruction_seq_MainTaskTransition); //move on to real task
for (var i = 0; i < taskNumber_sequential/attentionCheckInterval; i++) {
collective_emotion_estimation.push(fixation,attentionCheck); //attention check before real task
faceNumber = getWordnumber(); //trial out of attention check loop
collective_emotion_estimation.push(fixationGetFace);
for (var t = 0; t < faceNumber; t++) {
collective_emotion_estimation.push(fixation,face);}
collective_emotion_estimation.push(response);
var k = 0;
while (k < (attentionCheckInterval-1)){
faceNumber = getWordnumber();;
collective_emotion_estimation.push(fixationGetFace);
for (var t = 0; t < faceNumber; t++) {//one trial (different numbers of faces with one reponse)
collective_emotion_estimation.push(fixation,face);}
collective_emotion_estimation.push(response);
k ++;
}
}
/* create memory task definition array */
var memory_task = [] //display instructions
//memory_task.push(consent);
memory_task.push(fixationGetFace,attentionCheck);//attention check before practice task
for (var i = 0; i < practiceNumber; i++) { //practice trials
wordNumber = wordsPerSequence;
for (var t = 0; t < wordNumber; t++) {
memory_task.push(fixation,face);}
memory_task.push(memory); //response is main slide for amplification result, while memory is ending each trail and contains all information about memory task
};
//memory_task.push(instruction_mem_MainTaskTransition); //move on to real task
for (var i = 0; i < taskNumber_memory/attentionCheckInterval; i++) {
memory_task.push(fixation,attentionCheck); //attention check before real task
wordNumber = wordsPerSequence; //trial out of attention check loop
memory_task.push(fixationGetFace);
for (var t = 0; t < wordNumber; t++) {
memory_task.push(fixation,face);}
memory_task.push(memory);
var k = 0;
while (k < (attentionCheckInterval-1)){
wordNumber = wordsPerSequence;
memory_task.push(fixationGetFace);
for (var t = 0; t < wordNumber; t++) {//one trial (different numbers of faces with one reponse)
memory_task.push(fixation,face);}
memory_task.push(memory);
k ++;
}
/*Order of main task. In the commented part is the option to randomize */
var main_tasks = [];
var order = 0; //order = shuffle(); If we want to randomize
if (order == 1){
main_tasks = collective_emotion_estimation.concat(memory_task);
} else {
main_tasks = memory_task.concat(collective_emotion_estimation);
}
}
/* Create the full experiment definition array */
var experiment = general_instruction_start;
experiment = experiment.concat(main_tasks, attentionCheck, imageDescription,connectSurvey);
/******************************************/
/* run the study */
/******************************************/
jsPsych.init({
preload_images: attentionStimulus,
timeline: experiment,
on_start: function(data){
saveDataToS3()},
on_close: function(data){
saveDataToS3()},
on_finish: function(data){
saveDataToS3(),
window.location = "https://oxfordxpsy.az1.qualtrics.com/jfe/form/SV_3QX0NgroyPyvOku" //redirect to Qualtrics survey
}
})
</script>
</body>
</html>