Skip to content

Commit ee981ba

Browse files
committed
fix create_consent
1 parent cb80389 commit ee981ba

File tree

14 files changed

+60
-43
lines changed

14 files changed

+60
-43
lines changed

libraries/utils.js

+6-4
Original file line numberDiff line numberDiff line change
@@ -368,11 +368,11 @@ function white_on_black() {
368368

369369
// add consent to timeline
370370
function create_consent(timeline, taskinfo) {
371-
if (taskinfo.uniquestudyid.includes("consent.html")) {
371+
if (typeof taskinfo == 'string' && taskinfo.includes("consent.html")) {
372372
// for backwards compatibility: we use to accept only the html path
373373
var html_path = taskinfo;
374-
} else {
375-
// construct path to consent.html
374+
console.error("Use this intead! timeline = create_consent(timeline, taskinfo)");
375+
} else if (typeof taskinfo == 'object' && taskinfo.uniquestudyid) { // construct path to consent.html using taskinfo object
376376
var directory = '';
377377
if (taskinfo.type == "task") {
378378
directory = 'tasks';
@@ -382,7 +382,9 @@ function create_consent(timeline, taskinfo) {
382382
directory = "studies";
383383
}
384384
var html_path = "../../" + directory + "/" + taskinfo.uniquestudyid + "/consent.html";
385-
console.log("Consent form path generated from uniquestudyid")
385+
console.log("Consent form path generated from taskinfo.type and taskinfo.uniquestudyid")
386+
} else {
387+
console.error("Check input to create_consent")
386388
}
387389
console.log("Consent form path: " + html_path);
388390
globalThis.html_path = html_path; // global variable required by all consent.html

surveys/bigfiveaspect/task.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -105,11 +105,11 @@ var procedure = {
105105

106106

107107

108-
// create timeline (order of events)
109-
108+
// create timeline and events/objects for study (the first next lines are always the same! consent then check whether it's same person)
110109
var timeline = [];
111-
timeline = create_consent(timeline, taskinfo); // always add consent first
112-
timeline = check_same_different_person(timeline); // check AFTER consent!!!
110+
timeline = create_consent(timeline, taskinfo);
111+
timeline = check_same_different_person(timeline);
112+
113113
timeline.push(instructions);
114114
timeline.push(procedure);
115115
timeline = create_demographics(timeline);

surveys/brs1/task.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -103,11 +103,11 @@ var procedure = {
103103

104104

105105

106-
// create timeline (order of events)
106+
// create timeline and events/objects for study (the first next lines are always the same! consent then check whether it's same person)
107107
var timeline = [];
108-
var html_path = "../../surveys/brs1/consent.html"; // make it a global variable
109-
timeline = create_consent(timeline, html_path);
108+
timeline = create_consent(timeline, taskinfo);
110109
timeline = check_same_different_person(timeline);
110+
111111
timeline.push(instructions);
112112
timeline.push(procedure);
113113
timeline = create_demographics(timeline);

surveys/crt/task.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -78,11 +78,11 @@ var procedure = {
7878

7979

8080

81-
// create timeline (order of events)
82-
var timeline = []
83-
const html_path = "../../surveys/crt/consent.html";
84-
timeline = create_consent(timeline, html_path);
81+
// create timeline and events/objects for study (the first next lines are always the same! consent then check whether it's same person)
82+
var timeline = [];
83+
timeline = create_consent(timeline, taskinfo);
8584
timeline = check_same_different_person(timeline);
85+
8686
timeline.push(instructions);
8787
timeline.push(procedure);
8888
timeline = create_demographics(timeline);

surveys/gritshort/task.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -98,11 +98,11 @@ var procedure = {
9898

9999

100100

101-
// create timeline (order of events)
101+
// create timeline and events/objects for study (the first next lines are always the same! consent then check whether it's same person)
102102
var timeline = [];
103-
var html_path = "../../surveys/gritshort/consent.html"; // make it a global variable
104-
timeline = create_consent(timeline, html_path);
103+
timeline = create_consent(timeline, taskinfo);
105104
timeline = check_same_different_person(timeline);
105+
106106
timeline.push(instructions);
107107
timeline.push(procedure);
108108
timeline = create_demographics(timeline);

surveys/schulzvalues2019/task.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -103,11 +103,11 @@ var procedure = {
103103

104104

105105

106-
// create timeline (order of events)
106+
// create timeline and events/objects for study (the first next lines are always the same! consent then check whether it's same person)
107107
var timeline = [];
108-
var html_path = "../../surveys/schulzvalues2019/consent.html"; // make it a global variable
109-
timeline = create_consent(timeline, html_path);
108+
timeline = create_consent(timeline, taskinfo);
110109
timeline = check_same_different_person(timeline);
110+
111111
timeline.push(instructions);
112112
timeline.push(procedure);
113113
timeline = create_demographics(timeline);

tasks/delaydiscount/task.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -168,11 +168,11 @@ var practice_end_instructions = {
168168

169169

170170

171-
// create timeline (order of events)
171+
// create timeline and events/objects for study (the first next lines are always the same! consent then check whether it's same person)
172172
var timeline = [];
173-
const html_path = "../../tasks/delaydiscount/consent.html";
174-
timeline = create_consent(timeline, html_path);
173+
timeline = create_consent(timeline, taskinfo);
175174
timeline = check_same_different_person(timeline);
175+
176176
timeline.push(instructions);
177177
timeline.push(practice_trial);
178178
timeline.push(practice_end_instructions);

tasks/flanker/task.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -201,11 +201,11 @@ var practice_trial_sequence = {
201201
timeline_variables: practice_stimuli_shuffled, // the above timeline/trial is repeated stimuli_shuffled.length times
202202
};
203203

204-
// create experiment timeline
204+
// create timeline and events/objects for study (the first next lines are always the same! consent then check whether it's same person)
205205
var timeline = [];
206-
const html_path = "../../tasks/flanker/consent.html";
207-
timeline = create_consent(timeline, html_path);
206+
timeline = create_consent(timeline, taskinfo);
208207
timeline = check_same_different_person(timeline);
208+
209209
timeline.push(instructions, practice_trial_sequence, instructions2, trial_sequence);
210210
timeline = create_demographics(timeline);
211211

tasks/letternumber/task.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -128,11 +128,11 @@ var feedback = {
128128
show_clickable_nav: true
129129
}
130130

131-
// create timeline (order of events)
131+
// create timeline and events/objects for study (the first next lines are always the same! consent then check whether it's same person)
132132
var timeline = [];
133-
const html_path = "../../tasks/letternumber/consent.html";
134-
timeline = create_consent(timeline, html_path);
133+
timeline = create_consent(timeline, taskinfo);
135134
timeline = check_same_different_person(timeline);
135+
136136
timeline = [instructions, trial, feedback]
137137
timeline = create_demographics(timeline);
138138

tasks/stroop/task.js

+9-5
Original file line numberDiff line numberDiff line change
@@ -134,10 +134,6 @@ jsPsych.data.addProperties({
134134
info_: info_,
135135
});
136136

137-
// create experiment timeline
138-
var timeline = [];
139-
const html_path = "../../tasks/stroop/consent.html";
140-
timeline = create_consent(timeline, html_path);
141137

142138
var n_trial = 0; // stroop trial number counter
143139
var instructions = {
@@ -302,8 +298,16 @@ var practice_trial_sequence = {
302298
timeline_variables: practice_stimuli_shuffled, // the above timeline/trial is repeated stimuli_shuffled.length times
303299
};
304300

305-
// create task timeline
301+
302+
303+
304+
305+
306+
// create timeline and events/objects for study (the first next lines are always the same! consent then check whether it's same person)
307+
var timeline = [];
308+
timeline = create_consent(timeline, taskinfo);
306309
timeline = check_same_different_person(timeline);
310+
307311
timeline.push(instructions, practice_trial_sequence, instructions2, trial_sequence);
308312
timeline = create_demographics(timeline);
309313

tasks/symbolcount/task.js

+2-3
Original file line numberDiff line numberDiff line change
@@ -324,10 +324,9 @@ practice_trial.repetitions = practice_trials
324324

325325

326326

327-
// create timeline (order of events)
327+
// create timeline and events/objects for study (the first next lines are always the same! consent then check whether it's same person)
328328
var timeline = [];
329-
const html_path = "../../tasks/delaydiscount/consent.html";
330-
timeline = create_consent(timeline, html_path);
329+
timeline = create_consent(timeline, taskinfo);
331330
timeline = check_same_different_person(timeline);
332331

333332
timeline.push(instructions);

tasks/updatemath/task.js

+5-2
Original file line numberDiff line numberDiff line change
@@ -294,9 +294,12 @@ for (i = 0; i < practice_sequence.timeline.length; i++) {
294294
practice_sequence.timeline[i].data = { event: "practice" }
295295
}
296296

297+
298+
// create timeline and events/objects for study (the first next lines are always the same!)
297299
var timeline = [];
298-
timeline = create_consent(timeline, taskinfo.uniquestudyid);
299-
timeline = check_same_different_person(timeline); // check AFTER consent!!!
300+
timeline = create_consent(timeline, taskinfo);
301+
timeline = check_same_different_person(timeline);
302+
300303
timeline.push(instructions);
301304
if (n_practice_trial > 0) {
302305
timeline.push(practice_sequence, instructions2);

tasks/updatemath2/task.js

+12-3
Original file line numberDiff line numberDiff line change
@@ -310,10 +310,19 @@ for (i=0; i<practice_sequence.timeline.length; i++) {
310310
practice_sequence.timeline[i].data = { event: "practice" }
311311
}
312312

313-
var timeline = [instructions];
314-
const html_path = "../../tasks/updatemath2/consent.html";
315-
timeline = create_consent(timeline, html_path);
313+
314+
315+
316+
317+
318+
319+
320+
// create timeline and events/objects for study (the first next lines are always the same! consent then check whether it's same person)
321+
var timeline = [];
322+
timeline = create_consent(timeline, taskinfo);
316323
timeline = check_same_different_person(timeline);
324+
325+
317326
if (n_practice_trial > 0) {
318327
timeline.push(practice_sequence, instructions2);
319328
}

0 commit comments

Comments
 (0)