UiL-OTS-labs / jspsych-spr-mw

A self paced reading with moving window experiment using jsPsych
GNU General Public License v2.0
6 stars 3 forks source link

Make data removal after survey more robust #23

Closed maartenuni closed 6 months ago

maartenuni commented 2 years ago

Currently, when running the spr, the survey works as expected. Also when participant filled something out incorrectly, they could redo the survey. To ease data analysis, the survey would remove the survey that would be redone in a second attempt, So the question about birth year etc would not appear twice in the output. In survey.js is this bit of code that can become a culprit:

let survey_procedure = {
    timeline : [
        survey_1,
        survey_2,
        survey_review
    ],
    loop_function : function () {
        if (repeat_survey) {
            // clear last trials of the survey
            let collection = jsPsych.data.get();
            let trials = collection.values();
            trials.length = trials.length - this.timeline.length;
        }
        return repeat_survey;
    }
};

In the if( repeat_survey) {} the raw array length of the jsPsych database is made shorter and thereby removing the last few items that represent the survey. This works for the boilerplate, however it might fail when people for example put conditional timelines onto the timeline of the survey. A conditional timeline might not add anything to the database, but it does add to this.timeline.length, hence one might remove to much of the data. Perhaps it is possible to cache the length when entering the survey procedure and restore that length if the survey is repeated.