-
Notifications
You must be signed in to change notification settings - Fork 0
/
eng4objects.html
249 lines (213 loc) · 8.53 KB
/
eng4objects.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
<!DOCTYPE html>
<html>
<head>
<title>Alien lost and found game</title>
<script src="jspsych-6.2.0/jspsych.js"></script>
<script src="jspsych-6.2.0/plugins/jspsych-html-button-response.js"></script>
<script src="jspsych-6.2.0/plugins/jspsych-survey-text.js"></script>
<script src="jspsych-6.2.0/plugins/jspsych-external-html.js"></script>
<script src="consent/consent.js"></script>
<script src="mmturkey-0.6.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
<link rel="stylesheet" href="jspsych-6.2.0/css/jspsych.css"></link>
<script src="https://www.google.com/recaptcha/api.js" async defer></script>
</head>
<script>
/* get info from turk */
var turkInfo = jsPsych.turk.turkInfo();
/* create timeline */
var timeline = [];
// images
var images = [];
//var box = jsPsych.randomization.sampleWithoutReplacement(["img/novelbox4a.png", "img/novelbox4b.png", "img/novelbox4c.png",
//"img/novelbox4d.png"], 1)
//images.push(box)
var aliens = jsPsych.randomization.repeat(["img/lostalien1.png", "img/lostalien2.png"], 1)
var alien_1 = aliens[0]
var alien_2 = aliens[1]
images.push([alien_1, alien_2])
var box = "img/familiarbox.png"
images.push(box)
var bottle = jsPsych.randomization.sampleWithoutReplacement(["img/bottle1", "img/bottle2", "img/bottle3"], 1)
var test_box = bottle[0] + "_box.png"
var test_cue = bottle[0] + "_test.png"
images.push([test_box, test_cue])
var beanie = "img/beanie_test.png"
images.push(beanie)
var utts = jsPsych.randomization.repeat(["complex_utt", "simple_utt"], 1)
var utt_1 = utts[0]
var utt_2 = utts[1]
var check_1 = "img/bottle1.png"
var check_2 = "img/bottle4.png"
var check_3 = "img/bottle2.png"
images.push([check_1, check_2, check_3])
function get_utt(utt_type) {
if (utt_type == "simple_utt") {
return("<i>\"Bidaku zem toba.\"</i>")
} else {
return("<i>\"Bidaku zem modi osh gipu.\"</i>")
}
}
// reCAPTCHA object
var recaptcha = {
type: "external-html",
url: "recaptcha.html",
cont_btn: "submit_button",
execute_script: true
};
timeline.push(recaptcha);
var consent = {
type:'external-html',
url: "consent/consent.html",
cont_btn: "start"
};
timeline.push(consent);
/* define instructions trial */
var instructions = {
type: "html-button-response",
stimulus: "<p>In this experiment, you will see some aliens talk " +
"and make judgments about what they are talking about.",
choices: ['Start'],
data: {test_part: 'setup'},
post_trial_gap: 1000
};
timeline.push(instructions);
var intro = {
type: 'html-button-response',
stimulus: "<p>You work at the Alien Lost and Found." +
'<br><br>Here is a box of lost objects.</i><br>' +
"<div style='width: 300px;'>"+
"<div style='float: center;'><img src ='" + box + "' height = '300'></img></div>" +
"</div><br>",
choices: ['Continue'],
data: {test_part: 'setup'},
post_trial_gap: 500
}
var show_aliens = {
type: 'html-button-response',
stimulus: function() { return "<p>Two aliens come in and each look into the box.<br>" +
"<div style='width: 700px;'>" +
"<div style='float: left;'><img src='" + alien_1 + "' height='200'></img></div>" +
"<div style='float: right;'><img src='" + alien_2 + "' height='200'></img></div>"+
"<br><div style='float: center;'><img src='" + box + "' height='300'></img></div>" +
"</div><br>";
},
choices: ['Continue'],
data: {test_part: 'setup'},
post_trial_gap: 500
}
var alien_talk1 = {
type: 'html-button-response',
stimulus: function() { return "<p>Both aliens say which object they lost.</p>" +
"<p>This one says, " + get_utt(utt_1) + "</p>" +
"<div style='width: 700px;'>" +
"<div style='float: left;'><img src='" + alien_1 + "' height='200'></img></div><br><br>"+
"<div style='float: center;'><img src='" + box + "' height='300'></img></div>" +
"</div><br>";
},
choices: ['Continue'],
data: {test_part: 'setup', utt: utt_1, box: box},
post_trial_gap: 500
}
var alien_talk2 = {
type: 'html-button-response',
stimulus: function(){ return "<p>The other one says, " + get_utt(utt_2) + "</p>" +
"<div style='width: 700px;'>"+
"<div style='float: right;'><img src='" + alien_2 + "' height='200'></img></div><br><br>"+
"<div style='float: center;'><img src='" + box + "' height='300' height='210'></img></div>" +
"</div><br>";
},
choices: ['Continue'],
data: {test_part: 'setup', utt: utt_2, box: box},
post_trial_gap: 500
}
var test_setup = {
type: 'html-button-response',
stimulus: function(){ return "<p>Here are the two objects that the aliens lost.</p>" +
"<div style='width: 700px;'>"+
"<div style='float: center;'><img src='" + test_box + "' height='300'></img></div>"+
"</div><br>";
},
choices: ['Continue'],
data: {test_part: 'setup', test_box: test_box},
post_trial_gap: 500
}
var test_1 = {
type: 'html-button-response',
stimulus: function(){ return "<p>Which alien lost this object?</p>" +
"<div style='width: 700px; text-align: center'>"+
"<div style='float: center;'><img src = '" + test_cue + "' height = '300'></img></div><br>"+
"<div style='width: 350px; display: inline-block;'><p>" + get_utt(utt_1) + "</p></div>" +
"<div style='width: 350px; display: inline-block;'><p>" + get_utt(utt_2) + "</p></div><br>" +
"</div>";
},
choices: [alien_1, alien_2],
post_trial_gap: 500,
data: {utt_1: utt_1, utt_2: utt_2, cue: test_cue, alien_1: alien_1, alien_2: alien_2, test_part: "obj_selection"},
button_html: '<button style="border:none; background-color:#ffffff"> <img height="150px" src = %choice%> </img> </button>',
margin_horizontal: '60px'
}
var test_2 = {
type: 'html-button-response',
stimulus: function(){ return "<p>Which alien lost this object?</p>" +
"<div style='width: 700px; text-align: center'>"+
"<div style='float: center;'><img src = '" + beanie + "' height = '300'></img></div><br>"+
"<div style='width: 350px; display: inline-block;'><p>" + get_utt(utt_1) + "</p></div>" +
"<div style='width: 350px; display: inline-block;'><p>" + get_utt(utt_2) + "</p></div><br>" +
"</div>";
},
choices: [alien_1, alien_2],
post_trial_gap: 500,
data: {utt_1: utt_1, utt_2: utt_2, cue: beanie, alien_1: alien_1, alien_2: alien_2, test_part: "obj_selection"},
button_html: '<button style="border:none; background-color:#ffffff; float:center"><img height="150px" src = %choice%> </img> </button>',
margin_horizontal: '60px'
}
var test_procedure = {
timeline: [intro, show_aliens, alien_talk1, alien_talk2, test_setup, test_1, test_2],
sample: {
type: 'without-replacement',
size: 1
}
}
timeline.push(test_procedure);
var comment_trial = {
type: 'survey-text',
questions: [
{prompt: "Briefly, why did you choose the aliens you chose?"}
],
data: {test_part: 'comment'}
}
timeline.push(comment_trial);
var check_trial = {
type: 'html-button-response',
stimulus: "<p>Which of the following items did you NOT see during this study?</p>",
choices: [check_1, check_2, check_3],
post_trial_gap: 500,
data: {test_part: "check"},
button_html: '<button style="border:none; background-color:#ffffff"> <img height="120px" src = %choice%> </img> </button>',
margin_horizontal: '20px'
}
timeline.push(check_trial);
function saveData(name, data) {
var xhr = new XMLHttpRequest();
xhr.open('POST', 'write_data.php');
xhr.setRequestHeader('Content-Type', 'application/json');
xhr.send(JSON.stringify({filename: name, filedata: data}));
}
var endscreen = {
type: 'html-button-response',
stimulus: "<p>This is the end of the study. Thank you for participating!</p>",
choices: ['Finish']
};
timeline.push(endscreen);
/* start the experiment */
jsPsych.init({
timeline: timeline,
preload_images: images,
on_finish: function() {
var data = jsPsych.data.get().last(5).csv();
turk.submit(data);
}
});
</script>
</html>