-
Notifications
You must be signed in to change notification settings - Fork 1
/
Week7-Dynamic Trials.html
executable file
·87 lines (62 loc) · 2.4 KB
/
Week7-Dynamic Trials.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
<!DOCTYPE html>
<html>
<head>
<title>Week 7: Dynamic Trials</title>
<!-- Load JS psych -->
<script src="jspsych-7.2/jspsych.js"></script>
<!-- Load all the plugins we will be using today -->
<script src="jspsych-7.2/plugin-html-keyboard-response.js"></script>
<script src="jspsych-7.2/plugin-html-button-response.js"></script>
<!-- Load jspsych's default CSS -->
<link href="jspsych-7.2/jspsych.css" rel="stylesheet" type="text/css"></link>
</head>
<body>
</body>
<script>
// Documentation: https://www.jspsych.org/plugins/overview/
/*/ Last week's Homework /*/
// Choose three different plugins that we did not cover and use them to make a mini "experiment"
// First we have to initialize jsPsych. We can do this using the initJsPsych() function, and saving the result to a variable called jsPsych.
var jsPsych = initJsPsych();
// Define an empty timeline array
var timeline = [];
/*/ Define the trial variables /*/
var welcome = {
type: jsPsychHtmlKeyboardResponse,
stimulus: 'Welcome to my study!<p> We are interested in your tea preferences.<p> Press enter to begin.',
choices: ['enter']
};
var fixation = {
type: jsPsychHtmlKeyboardResponse,
stimulus: '<p style="font-size: 30px;">+</p>',
choices: "NO_KEYS",
trial_duration: 1000,
};
timeline.push(welcome)
// Problem:
// A Python script runs essentially in sequence; when one line of code is called the script waits for that line to finish and then the next lines begins. JavaScript is designed to be asynchronous; all parts of your web page should load at once.
// Initialize counter variable
var count = 0
var timeLimit = 5000
// Array of stimuli
var bbt_options = ["taro milk","earl grey","brown sugar","wintermelon","cacao barry"]
var bubble_tea = {
type: jsPsychHtmlButtonResponse,
stimulus: function() {
current_tea = bbt_options[count]
count++
return current_tea+'<p>'
},
choices: ['Like', 'Neutral','Dislike'],
trial_duration: timeLimit // why doesn't this need to be wrapped in a function?
};
// push bbt trials into timeline
for (i=0; i < bbt_options.length; i++) {
timeline.push(bubble_tea)
timeline.push(fixation)
}
// Can we make the bbt text bigger?
/*/ Run the timeline /*/
jsPsych.run(timeline);
</script>
</html>