-
Notifications
You must be signed in to change notification settings - Fork 0
/
runLocally.html
89 lines (78 loc) · 2.98 KB
/
runLocally.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
<!DOCTYPE html>
<html>
<head>
<!-- Load in the required jsPsych library and plugins-->
<script src="js/jspsych/jspsych.js"></script>
<script src="js/jspsych-psychophysics-3.6.0/jspsych-psychophysics.js"></script>
<script src="js/jspsych/plugin-preload.js"></script>
<script src="js/jspsych/plugin-html-button-response.js"></script>
<script src="js/jspsych/plugin-instructions.js"></script>
<script src="js/jspsych/plugin-call-function.js"></script>
<script src="js/jspsych/plugin-survey-text.js"></script>
<script src="js/jspsych/plugin-survey.js"></script>
<!-- Load in additional functions, instructions,
and the experiment configs -->
<script src="js/functions/shared_func.js"></script>
<script src="js/functions/image_func.js"></script>
<script src="js/functions/position_func.js"></script>
<script src="config/survey_config.js"></script>
<script src="config/expt1_config.js"></script>
<script src="config/expt2_config.js"></script>
<script src="config/expt3_config.js"></script>
<script src="config/expt4_config.js"></script>
<script src="config/instructions.js"></script>
<!-- Load in the CSS -->
<link href="js/jspsych/jspsych.css" rel="stylesheet" type="text/css" />
<link href="css/custom-style.css" rel="stylesheet" type="text/css" />
</head>
<body>
<canvas id="canvas" width="800" height="600"></canvas>
<script>
const jsPsych = initJsPsych({
on_finish: function() {
// When the experiment is done generate a filename based on
// Particpant ID and date, then save the data locally as a csv file
const d = new Date();
const dateString = d.toISOString().split(".")[0].replaceAll(":", "");
const ID = jsPsych.data.get().
filter({trial_type: 'survey-text'}).
select("response").
values[0].ID;
var filename = ID + "_" + dateString + ".csv";
jsPsych.data.get().localSave('csv', filename);
}
});
var jspRand = jsPsych.randomization
const enter_ID = {
type: jsPsychSurveyText,
questions: [
{
prompt: "Please enter the participant ID",
required: true,
name: "ID"
}
]
}
const canvas = document.getElementById("canvas");
const imgSize = [96, 96];
const mainTimeline = [];
mainTimeline.push(enter_ID)
</script>
<script src="js/preloadImgs.js"></script>
<script src="js/survey.js"></script>
<script src="js/Experiment1.js"></script>
<script src="js/Experiment2.js"></script>
<script src="js/Experiment3.js"></script>
<script src="js/Experiment4.js"></script>
<script>
var expt_complete = {
type: jsPsychHtmlButtonResponse,
stimulus: '<p>All Done</p>',
choices: "",
trial_duration: 1500,
}
mainTimeline.push(expt_complete);
jsPsych.run(mainTimeline)
</script>
</body>
</html>