diff --git a/.changeset/violet-hairs-tap.md b/.changeset/violet-hairs-tap.md index b3231edc..d24fd8a8 100644 --- a/.changeset/violet-hairs-tap.md +++ b/.changeset/violet-hairs-tap.md @@ -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 diff --git a/docs/demos/jspsych-cloze-demo3.html b/docs/demos/jspsych-cloze-demo3.html index f6185044..e879b009 100644 --- a/docs/demos/jspsych-cloze-demo3.html +++ b/docs/demos/jspsych-cloze-demo3.html @@ -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.'); } }; diff --git a/docs/plugins/cloze.md b/docs/plugins/cloze.md index 1fe9f4ee..56d1084f 100644 --- a/docs/plugins/cloze.md +++ b/docs/plugins/cloze.md @@ -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.'); } }; ``` diff --git a/examples/jspsych-cloze.html b/examples/jspsych-cloze.html index dd57ea00..d32859b9 100644 --- a/examples/jspsych-cloze.html +++ b/examples/jspsych-cloze.html @@ -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!"); } }); diff --git a/packages/plugin-cloze/src/index.spec.ts b/packages/plugin-cloze/src/index.spec.ts index d05d57e2..3c383818 100644 --- a/packages/plugin-cloze/src/index.spec.ts +++ b/packages/plugin-cloze/src/index.spec.ts @@ -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, }, ]); diff --git a/packages/plugin-cloze/src/index.ts b/packages/plugin-cloze/src/index.ts index 5831f926..fc6e139b 100644 --- a/packages/plugin-cloze/src/index.ts +++ b/packages/plugin-cloze/src/index.ts @@ -21,17 +21,17 @@ const info = { 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 { static info = info; - constructor(private jsPsych: JsPsych) {} + constructor(private jsPsych: JsPsych) { } trial(display_element: HTMLElement, trial: TrialType) { var html = '
'; @@ -88,14 +88,14 @@ class ClozePlugin implements JsPsychPlugin { 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 = {