Skip to content

Commit

Permalink
simulation bugfix pt. 2 + docs
Browse files Browse the repository at this point in the history
  • Loading branch information
jadeddelta committed Nov 1, 2022
1 parent d2be99f commit 3f91e52
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
3 changes: 2 additions & 1 deletion docs/plugins/cloze.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion packages/plugin-cloze/src/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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([
{
Expand Down
10 changes: 6 additions & 4 deletions packages/plugin-cloze/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -159,9 +159,7 @@ class ClozePlugin implements JsPsychPlugin<Info> {
if (wordList.includes("")) {
responses.push(this.jsPsych.randomization.randomWords({ exactly: 1 }));
} else {
for (const word of wordList) {
responses.push(word);
}
responses.push(wordList);
}
}

Expand All @@ -179,6 +177,8 @@ class ClozePlugin implements JsPsychPlugin<Info> {
private simulate_data_only(trial: TrialType<Info>, simulation_options) {
const data = this.create_simulation_data(trial, simulation_options);

data.response = data.response[0];

this.jsPsych.finishTrial(data);
}

Expand All @@ -193,7 +193,9 @@ class ClozePlugin implements JsPsychPlugin<Info> {
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);
Expand Down

0 comments on commit 3f91e52

Please sign in to comment.