mirror of
https://github.com/jspsych/jsPsych.git
synced 2025-05-10 11:10:54 +00:00
53 lines
1.7 KiB
HTML
53 lines
1.7 KiB
HTML
<!DOCTYPE html>
|
|
<html>
|
|
<head>
|
|
<script src="../packages/jspsych/dist/index.browser.js"></script>
|
|
<script src="../packages/plugin-cloze/dist/index.browser.js"></script>
|
|
<link rel="stylesheet" href="../packages/jspsych/css/jspsych.css" />
|
|
</head>
|
|
<body></body>
|
|
<script>
|
|
|
|
var jsPsych = initJsPsych({
|
|
on_finish: function() {
|
|
jsPsych.data.displayData();
|
|
}
|
|
});
|
|
|
|
var timeline = [];
|
|
|
|
// simple example using default settings (no check against correct solution, no custom button text)
|
|
timeline.push({
|
|
type: jsPsychCloze,
|
|
text: 'The %% is the largest terrestrial mammal. It lives in both %% and %%.'
|
|
});
|
|
|
|
// an example that allows the user to input a solution that doesn't require case sensitivity, and allows multiple responses
|
|
timeline.push({
|
|
type: jsPsychCloze,
|
|
text: 'The %CASE/door/EyE% is closed.',
|
|
check_answers: true,
|
|
case_sensitivity: false,
|
|
})
|
|
|
|
// another example with checking if all the blanks are filled in
|
|
timeline.push({
|
|
type: jsPsychCloze,
|
|
text: 'Science notebooks have a %%-colored front cover. Math notebooks have a %%-colored front cover.',
|
|
allow_blanks: false,
|
|
mistake_fn: function () { alert("You have not filled in all the blanks!"); }
|
|
});
|
|
|
|
// more elaborate example (with check against correct solution, custom error handling and modified button text)
|
|
timeline.push({
|
|
type: jsPsychCloze,
|
|
text: 'A rectangle has % 4 % corners and a triangle has % 3 %.',
|
|
check_answers: true,
|
|
button_text: 'Next',
|
|
mistake_fn: function () { alert("Wrong answer. Please check again.") }
|
|
});
|
|
|
|
jsPsych.run(timeline);
|
|
</script>
|
|
</html>
|