Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Progress bar behaves incorrectly when used with conditional_function / loop_function #3351

Open
Shaobin-Jiang opened this issue Jul 18, 2024 · 0 comments

Comments

@Shaobin-Jiang
Copy link
Contributor

When used with conditional_function and the timeline is skipped

let jsPsych = initJsPsych({
    show_progress_bar: true,
    message_progress_bar: (progress) => `${progress * 100}`,
});

let trial = {
    type: jsPsychHtmlKeyboardResponse,
    stimulus: 'Trial 1',
};

let child_timeline = {
    type: jsPsychHtmlKeyboardResponse,
    timeline: [{stimulus: 'Trial 2.1'}, {stimulus: 'Trial 2.2'}],
    conditional_function: function () {
        return false;
    },
};

jsPsych.run([trial, child_timeline, trial]);

In this case, when the second trial is finished, the progress ends at 0.75.

When used with loop_function and the timeline is looped

let jsPsych = initJsPsych({
    show_progress_bar: true,
    message_progress_bar: (progress) => `${progress * 100}`,
});

let trial = {
    type: jsPsychHtmlKeyboardResponse,
    stimulus: 'Trial 1',
};

let counter = 0;
let child_timeline = {
    type: jsPsychHtmlKeyboardResponse,
    timeline: [{stimulus: 'Trial 2.1'}, {stimulus: 'Trial 2.2'}],
    loop_function: function () {
        // loop the timeline twice
        counter++;
        return counter < 2;
    },
};

jsPsych.run([trial, child_timeline, trial]);

Progress increases with a 0.25 step and reaches 1 just before the second trial runs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant