mirror of
https://github.com/jspsych/jsPsych.git
synced 2025-05-10 11:10:54 +00:00
change from check_blanks to allow_blanks
This commit is contained in:
parent
2f1a867494
commit
68c3490f91
@ -2,4 +2,4 @@
|
||||
"@jspsych/plugin-cloze": minor
|
||||
---
|
||||
|
||||
added `check_blanks` as a field, allowing for completion checking of answers
|
||||
added `allow_blanks` as a field, allowing for completion checking of answers
|
||||
|
@ -16,7 +16,7 @@
|
||||
var trial = {
|
||||
type: jsPsychCloze,
|
||||
text: 'Science notebooks have a %%-colored front cover. Math notebooks have a %%-colored front cover.',
|
||||
check_blanks: true,
|
||||
allow_blanks: false,
|
||||
mistake_fn: function() { alert('Please fill in all blanks.'); }
|
||||
};
|
||||
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
Current version: 1.1.1. [See version history](https://github.com/jspsych/jsPsych/blob/main/packages/plugin-cloze/CHANGELOG.md).
|
||||
|
||||
This plugin displays a text with certain words removed. Participants are asked to replace the missing items. Responses are recorded when clicking a button. Optionally, responses are evaluated and a function is called in case of differences, making it possible to inform participants about mistakes.
|
||||
This plugin displays a text with certain words removed. Participants are asked to replace the missing items. Responses are recorded when clicking a button. Responses can be evaluated and a function is called in case of either differences or incomplete answers, making it possible to inform participants about mistakes before proceeding.
|
||||
|
||||
## Parameters
|
||||
|
||||
@ -13,8 +13,8 @@ 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. |
|
||||
| allow_blanks | boolean | true | Boolean value indicating if the answers given by participants should be checked for completion after the button was clicked. If ```true```, answers are not checked for completion and blank answers are allowed. The trial will then automatically finish upon the clicking the button. If ```false```, answers are checked for completion, and in case there are some fields with missing answers, the ```mistake_fn``` is called. In this case, the trial does not automatically finish. |
|
||||
| mistake_fn | function | ```function(){}``` | Function called if ```check_answers``` is set to ```true``` or ```allow_blanks``` is set to false and there is a difference between the participants answers and the correct solution provided in the text, or if there is at least one field with a blank answer respectively. |
|
||||
|
||||
## Data Generated
|
||||
|
||||
@ -70,7 +70,7 @@ import cloze from '@jspsych/plugin-cloze';
|
||||
var cloze_trial = {
|
||||
type: jsPsychCloze,
|
||||
text: 'Science notebooks have a %%-colored front cover. Math notebooks have a %%-colored front cover.',
|
||||
check_blanks: true,
|
||||
allow_blanks: false,
|
||||
mistake_fn: function() { alert('Please fill in all blanks.'); }
|
||||
};
|
||||
```
|
||||
|
@ -26,7 +26,7 @@
|
||||
timeline.push({
|
||||
type: jsPsychCloze,
|
||||
text: 'Science notebooks have a %%-colored front cover. Math notebooks have a %%-colored front cover.',
|
||||
check_blanks: true,
|
||||
allow_blanks: false,
|
||||
mistake_fn: function () { alert("You have not filled in all the blanks!"); }
|
||||
});
|
||||
|
||||
|
@ -78,7 +78,7 @@ describe("cloze", () => {
|
||||
{
|
||||
type: cloze,
|
||||
text: "This is a %cloze% text.",
|
||||
check_blanks: true,
|
||||
allow_blanks: false,
|
||||
},
|
||||
]);
|
||||
|
||||
@ -106,7 +106,7 @@ describe("cloze", () => {
|
||||
{
|
||||
type: cloze,
|
||||
text: "This is a %cloze% text.",
|
||||
check_answers: true,
|
||||
allow_blanks: false,
|
||||
},
|
||||
]);
|
||||
|
||||
@ -139,7 +139,7 @@ describe("cloze", () => {
|
||||
{
|
||||
type: cloze,
|
||||
text: "This is a %cloze% text.",
|
||||
check_blanks: true,
|
||||
allow_blanks: false,
|
||||
mistake_fn: mistakeFn,
|
||||
},
|
||||
]);
|
||||
|
@ -21,17 +21,17 @@ const info = <const>{
|
||||
pretty_name: "Check answers",
|
||||
default: false,
|
||||
},
|
||||
/** Boolean value indicating if the answers given by participants should be checked for completeness after the button is clicked in order to move on. */
|
||||
check_blanks: {
|
||||
/** Boolean value indicating if the answers given by participants */
|
||||
allow_blanks: {
|
||||
type: ParameterType.BOOL,
|
||||
pretty_name: "Check blanks",
|
||||
default: false,
|
||||
default: true,
|
||||
},
|
||||
/** Function called if either the check_answers or check_blanks is set to TRUE and there is a discrepancy between the set answers and the answers provide or if all blanks aren't filled out, respectively. */
|
||||
/** Function called if either the check_answers is set to TRUE or the allow_blanks is set to FALSE and there is a discrepancy between the set answers and the answers provide or if all blanks aren't filled out, respectively. */
|
||||
mistake_fn: {
|
||||
type: ParameterType.FUNCTION,
|
||||
pretty_name: "Mistake function",
|
||||
default: () => {},
|
||||
default: () => { },
|
||||
},
|
||||
},
|
||||
};
|
||||
@ -49,7 +49,7 @@ type Info = typeof info;
|
||||
class ClozePlugin implements JsPsychPlugin<Info> {
|
||||
static info = info;
|
||||
|
||||
constructor(private jsPsych: JsPsych) {}
|
||||
constructor(private jsPsych: JsPsych) { }
|
||||
|
||||
trial(display_element: HTMLElement, trial: TrialType<Info>) {
|
||||
var html = '<div class="cloze">';
|
||||
@ -88,14 +88,14 @@ class ClozePlugin implements JsPsychPlugin<Info> {
|
||||
field.style.color = "black";
|
||||
}
|
||||
}
|
||||
if (trial.check_blanks) {
|
||||
if (!trial.allow_blanks) {
|
||||
if (answers[i] === "") {
|
||||
answers_filled = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ((trial.check_answers && !answers_correct)||(trial.check_blanks && !answers_filled)) {
|
||||
if ((trial.check_answers && !answers_correct) || (!trial.allow_blanks && !answers_filled)) {
|
||||
trial.mistake_fn();
|
||||
} else {
|
||||
var trial_data = {
|
||||
|
Loading…
Reference in New Issue
Block a user