added documentation info

This commit is contained in:
jadeddelta 2022-09-22 14:00:22 -04:00
parent 890c9bd563
commit 8c77b43a7c
2 changed files with 50 additions and 1 deletions

View File

@ -0,0 +1,31 @@
<!DOCTYPE html>
<html>
<head>
<script src="docs-demo-timeline.js"></script>
<script src="https://unpkg.com/jspsych@7.3.0"></script>
<script src="https://unpkg.com/@jspsych/plugin-cloze@1.1.1"></script>
<script src="https://unpkg.com/@jspsych/plugin-html-button-response@1.1.1"></script>
<link rel="stylesheet" href="https://unpkg.com/jspsych@7.3.0/css/jspsych.css" />
<link rel="stylesheet" href="docs-demo.css" type="text/css">
</head>
<body></body>
<script>
const jsPsych = initJsPsych();
var trial = {
type: jsPsychCloze,
text: 'Science notebooks have a %%-colored front cover. Math notebooks have a %%-colored front cover.',
check_blanks: true,
mistake_fn: function() { alert('Please fill in all blanks.'); }
};
const timeline = [trial];
if (typeof jsPsych !== "undefined") {
jsPsych.run(generateDocsDemoTimeline(timeline));
} else {
document.body.innerHTML = '<div style="text-align:center; margin-top:50%; transform:translate(0,-50%);">You must be online to view the plugin demo.</div>';
}
</script>
</html>

View File

@ -13,6 +13,7 @@ In addition to the [parameters available in all plugins](../overview/plugins.md#
| text | string | *undefined* | The cloze text to be displayed. Blanks are indicated by %% signs and automatically replaced by input fields. If there is a correct answer you want the system to check against, it must be typed between the two percentage signs (i.e. % correct solution %). |
| button_text | string | OK | Text of the button participants have to press for finishing the cloze test. |
| check_answers | boolean | false | Boolean value indicating if the answers given by participants should be compared against a correct solution given in the text (between % signs) after the button was clicked. If ```true```, answers are checked and in case of differences, the ```mistake_fn``` is called. In this case, the trial does not automatically finish. If ```false```, no checks are performed and the trial automatically ends when clicking the button. |
| check_blanks | boolean | false | Boolean value indicating if the answers given by participants should be checked for completion after the button was clicked. If ```true```, answers are checked and in case there are some missing, the ```mistake_fn``` is called. In this case, the trial does not automatically finish. If ```false```, no checks are performed and the trial automatically ends when clicking the button. |
| mistake_fn | function | ```function(){}``` | Function called if ```check_answers``` is set to ```true``` and there is a difference between the participants answers and the correct solution provided in the text. |
## Data Generated
@ -63,6 +64,23 @@ import cloze from '@jspsych/plugin-cloze';
<a target="_blank" rel="noopener noreferrer" href="../../demos/jspsych-cloze-demo1.html">Open demo in new tab</a>
???+ example "Cloze example using default settings with completion checking and custom error handling"
=== "Code"
```javascript
var cloze_trial = {
type: jsPsychCloze,
text: 'Science notebooks have a %%-colored front cover. Math notebooks have a %%-colored front cover.',
check_blanks: true,
mistake_fn: function() { alert('Please fill in all blanks.'); }
};
```
=== "Demo"
<div style="text-align:center;">
<iframe src="../../demos/jspsych-cloze-demo3.html" width="90%;" height="500px;" frameBorder="0"></iframe>
</div>
<a target="_blank" rel="noopener noreferrer" href="../../demos/jspsych-cloze-demo3.html">Open demo in new tab</a>
???+ example "More elaborate example (with check against correct solution, custom error handling and modified button text)"
=== "Code"