-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlexical_decision.html
88 lines (79 loc) · 3.67 KB
/
lexical_decision.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
<!DOCTYPE html>
<html>
<head>
<title>Lexical decision</title>
<script src="jsPsych/jspsych.js"></script>
<script src="jsPsych/plugins/jspsych-html-keyboard-response.js"></script>
<script src="jsPsych/plugins/jspsych-instructions.js"></script>
<link href="jsPsych/css/jspsych.css" rel="stylesheet">
</head>
<body></body>
<script>
var timeline = [];
var instructions = {
type: 'instructions',
pages: ['Welcome!', '<p>Press the N key when you see a nonword.</p><p>Press the W key when you see a word.</p><p> Click the NEXT button to start.</p>'],
show_clickable_nav: true
};
timeline.push(instructions)
var fixation = {
type: 'html-keyboard-response',
stimulus: '<span style="font-size:40px;">+</span>',
choices: jsPsych.NO_KEYS,
trial_duration: 1000
}
var lexical_decision_trial = {
type: 'html-keyboard-response',
stimulus: jsPsych.timelineVariable('stimulus'),
choices: ['w', 'n'],
stimulus_duration: 2000,
data: {
condition: jsPsych.timelineVariable('condition'),
correct_response: jsPsych.timelineVariable('correct_response')
},
post_trial_gap: 1000,
on_finish: function(data) {
var accuracy = false;
if (data.correct_response == jsPsych.pluginAPI.convertKeyCodeToKeyCharacter(data.key_press)) {
accuracy = true;
}
data.accuracy = accuracy;
}
};
var feedback = {
type: 'html-keyboard-response',
stimulus: function() {
var feedback_text = '<span style="font-size:30px;color:red">Incorrect! <p>:(</p></span>';
var last_trial_accuracy = jsPsych.data.getLastTrialData().values()[0].accuracy;
if (last_trial_accuracy == true) {
feedback_text = '<span style="font-size:30px;color:green">Correct! <p>:)</p></span>'
}
return feedback_text
},
choices: jsPsych.NO_KEYS,
trial_duration: 2000
}
var trial_info = [
{stimulus: '<span style="font-size:40px;">apple</span>', condition: 'word', correct_response: 'w'},
{stimulus: '<span style="font-size:40px;">tree</span>', condition: 'word', correct_response: 'w'},
{stimulus: '<span style="font-size:40px;">leak</span>', condition: 'word', correct_response: 'w'},
{stimulus: '<span style="font-size:40px;">clean</span>', condition: 'word', correct_response: 'w'},
{stimulus: '<span style="font-size:40px;">orap</span>', condition: 'nonword', correct_response: 'n'},
{stimulus: '<span style="font-size:40px;">moxid</span>', condition: 'nonword', correct_response: 'n'},
{stimulus: '<span style="font-size:40px;">prege</span>', condition: 'nonword', correct_response: 'n'},
{stimulus: '<span style="font-size:40px;">glif</span>', condition: 'nonword', correct_response: 'n'},
];
var lexical_decision_procedure = {
timeline: [fixation, lexical_decision_trial, feedback],
timeline_variables: trial_info,
randomize_order: true
}
timeline.push(lexical_decision_procedure);
jsPsych.init({
timeline: timeline,
on_finish: function() {
jsPsych.data.displayData();
}
})
</script>
</html>