jsPsych/examples/data-as-function.html

33 lines
703 B
HTML

<!DOCTYPE html>
<html>
<head>
<script src="../jspsych.js"></script>
<script src="../plugins/jspsych-image-keyboard-response.js"></script>
<link rel="stylesheet" href="../css/jspsych.css">
</head>
<body></body>
<script>
var block_1 = {
type: 'image-keyboard-response',
stimulus: 'img/happy_face_1.jpg',
choices: ['y','n'],
prompt: '<p>Data should have a random int 0-19 on next page. Press "y" or "n".</p>',
stimulus_width: 300,
data: function() {
return {
random_number: Math.floor(Math.random() * 20)
}
}
}
jsPsych.init({
timeline: [block_1],
on_finish: function() {
jsPsych.data.displayData();
}
});
</script>
</html>