diff --git a/docs/plugins/cloze.md b/docs/plugins/cloze.md index 4ee5a51f74..1a1a9dff57 100644 --- a/docs/plugins/cloze.md +++ b/docs/plugins/cloze.md @@ -10,10 +10,11 @@ In addition to the [parameters available in all plugins](../overview/plugins.md# | Parameter | Type | Default Value | Description | | ------------- | -------- | ------------------ | ---------------------------------------- | -| 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 %). | +| 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 %). To input multiple correct answers, add a / between each answer (i.e. %correct/alsocorrect%). | | 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. | | 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. | +| case_sensitivity | boolean | true | Boolean value indicating if the answers given by participants should also be checked to have the right case along with correctness. If set to ```false```, case is disregarded and participants may type in whatever case they please. | | mistake_fn | function | ```function(){}``` | Function called if ```check_answers``` is set to ```true``` and there is a difference between the participant's answers and the correct solution provided in the text, or if ```allow_blanks``` is set to ```false``` and there is at least one field with a blank answer. | ## Data Generated diff --git a/packages/plugin-cloze/src/index.spec.ts b/packages/plugin-cloze/src/index.spec.ts index 38c4eca6f8..30307fc558 100644 --- a/packages/plugin-cloze/src/index.spec.ts +++ b/packages/plugin-cloze/src/index.spec.ts @@ -218,7 +218,6 @@ describe("cloze", () => { }); describe("cloze simulation", () => { - //TODO: bro why is this not working (wraps this in array but not the next one) test("data-only mode works", async () => { const { getData, expectFinished } = await simulateTimeline([ { diff --git a/packages/plugin-cloze/src/index.ts b/packages/plugin-cloze/src/index.ts index 13a91cb747..3b9241ac62 100644 --- a/packages/plugin-cloze/src/index.ts +++ b/packages/plugin-cloze/src/index.ts @@ -159,9 +159,7 @@ class ClozePlugin implements JsPsychPlugin { if (wordList.includes("")) { responses.push(this.jsPsych.randomization.randomWords({ exactly: 1 })); } else { - for (const word of wordList) { - responses.push(word); - } + responses.push(wordList); } } @@ -179,6 +177,8 @@ class ClozePlugin implements JsPsychPlugin { private simulate_data_only(trial: TrialType, simulation_options) { const data = this.create_simulation_data(trial, simulation_options); + data.response = data.response[0]; + this.jsPsych.finishTrial(data); } @@ -193,7 +193,9 @@ class ClozePlugin implements JsPsychPlugin { const inputs = display_element.querySelectorAll('input[type="text"]'); let rt = this.jsPsych.randomization.sampleExGaussian(750, 200, 0.01, true); for (let i = 0; i < data.response.length; i++) { - this.jsPsych.pluginAPI.fillTextInput(inputs[i] as HTMLInputElement, data.response[i], rt); + let res = data.response[i][Math.floor(Math.random() * data.response[i].length)]; + + this.jsPsych.pluginAPI.fillTextInput(inputs[i] as HTMLInputElement, res, rt); rt += this.jsPsych.randomization.sampleExGaussian(750, 200, 0.01, true); } this.jsPsych.pluginAPI.clickTarget(display_element.querySelector("#finish_cloze_button"), rt);