-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdata_submission.html
79 lines (54 loc) · 3.26 KB
/
data_submission.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
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="user-scalable=no, width=device-width, initial-scale=1.0">
<title>Data Submission</title>
<script src="jspsych-6.1.0/jspsych.js" ></script>
<script src='./extra_functions/helper_functions.js'></script>
<script src="jatos.js"></script>
<link rel="stylesheet" href="jspsych-6.1.0/css/jspsych.css" type="text/css"></link>
</head>
<body>
<script>
//'use strict';
//start timeline
jatos.onLoad(function() {
// What phase is this?
[curr_phase,phase_string,curr_session,curr_global_trial] = getPhaseAndSession()
var redirect_fn = function () {return window.location.replace(jatos.studySessionData.outputData.redirect_url);};
// end study function
var end_study_fn = function() {
// If failed at the practice trials
if (jatos.studySessionData.qc_status.practice_pass == false){
// Redirection URL with the code saying how many sessions they completed
jatos.studySessionData.outputData.redirect_url = 'https://app.prolific.co/submissions/complete?cc=PRACTICE_FAILED_' + phase_string;
jatos.endStudyAjax(true, 'PRACTICE_FAILED_' + phase_string + '_' + jatos.studySessionData.prolific_ID, redirect_fn);
// If failed the instructions
} else if (jatos.studySessionData.qc_status.min_time_instruct_pass == false){
// Redirection URL with the code saying how many sessions they completed
jatos.studySessionData.outputData.redirect_url = 'https://app.prolific.co/submissions/complete?cc=INSTR_FAILED_' + phase_string;
jatos.endStudyAjax(true, 'INSTR_FAILED_' + phase_string + '_' + jatos.studySessionData.prolific_ID, redirect_fn);
// If failed main sessions qc
} else if (jatos.studySessionData.qc_status.global_pass == false){
// Redirection URL with the code saying which phase and how many sessions they completed
jatos.studySessionData.outputData.redirect_url = 'https://app.prolific.co/submissions/complete?cc=QC_fail_p_'+curr_phase+'_s_'+curr_session;
// Create an error text
var err = deepCopy(jatos.studySessionData.qc_status);
jatos.endStudyAjax(true, "QC_FAILED_" +
jatos.studySessionData.prolific_ID + '_' + JSON.stringify(Object.values(err)), redirect_fn)
} else {
// So everything's good. Finished properly
// Redirection URL with correct completion code
jatos.studySessionData.outputData.redirect_url = jatos.componentJsonInput.url;
jatos.endStudyAjax(true, "REDIRECTED_"+ jatos.studySessionData.prolific_ID, redirect_fn);
};
} // end_study_fn
jatos.submitResultData("[data_submission_start---" +
JSON.stringify(jatos.studySessionData) +
"---data_submission_end]", end_study_fn);
// jsPsych.data.displayData();
}); // on_load_function
</script>
</body>
</html>