-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathjspsych-replay.html
60 lines (50 loc) · 1.44 KB
/
jspsych-replay.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
<!DOCTYPE html>
<html>
<head>
<title>jsPsych Replay</title>
<script src="dist/jspsych.js"></script>
<script src="dist/plugin-html-keyboard-response.js"></script>
<script src="dist/plugin-html-button-response.js"></script>
<script src="dist/plugin-survey-text.js"></script>
<link href="dist/jspsych.css" rel="stylesheet" type="text/css"></link>
<script src="cryo-0.0.6.js"></script>
</head>
<body>
</body>
<script>
let timeline = []
var trial1 = {
type: jsPsychHtmlKeyboardResponse,
stimulus: function() {return `timeline var var1: ${jsPsych.timelineVariable('var1', true)}`},
choices: ' '
};
var trial2 = {
type: jsPsychHtmlButtonResponse,
stimulus: 'trial2',
choices: ['button1', 'button2'],
on_start: function(trial) {
// this and the above stimulus function are both evidence that retriving the stringified timeline works like a charm!
trial.stimulus = `timeline variable var2: ${jsPsych.timelineVariable('var2', true)}`
}
};
var trial3 = {
type: jsPsychHtmlKeyboardResponse,
stimulus: 'trial 3',
choices: 'a'
};
timeline.push({timeline: [trial1, trial2, trial3],
timeline_variables: [{var1: 'a', var2: 'b'}]})
let jsPsych = initJsPsych({
log_data_for_replay: false,
data_for_replay_local_save: true,
on_finish: function() {
jsPsych.data.displayData('json');
}
})
if (jsPsych.opts.log_data_for_replay) {
jsPsych.run(timeline)
} else {
jsPsych.replay('data_for_replay.txt')
}
</script>
</html>