Help with progress bar #1180
-
|
So my experiment currently has two items on its timeline, the instructions page and the experiment itself. The progress bar immediately fills up to 50% after the instructions page is shown and doesn't move at all during the different trials and it fills up to 100% when the experiment is finished. How could I fix this where it'll progress with every trial? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
|
Hi @veranicolette, you could use the on_load: function() {
jsPsych.setProgressBar(0.05);
}And to change the values in your main task, you need some way of tracking or calculating how far through the task the participant is. One way to do this is to use jsPsych's data functions, like the var n_trials = 10;
var trial = {
//... other trial parameters...
on_finish: function(data) {
var trial_count = jsPsych.data.get().filter({task_segment: "main_task"}).count();
var progress = trial_count/n_trials;
jsPsych.setProgressBar(progress);
}
}Another option is to create a global var count = 0;
var n_trials = 10;
var trial = {
//... other trial parameters...
on_finish: function(data) {
count++;
var progress = count/n_trials;
jsPsych.setProgressBar(progress);
}
}I hope this helps! |
Beta Was this translation helpful? Give feedback.
-
|
Forgot to say that if you want to set the progress bar values yourself, I think you need to set jsPsych.init({
//... other settings...
show_progress_bar: true,
auto_update_progress_bar: false
}); |
Beta Was this translation helpful? Give feedback.
Hi @veranicolette, you could use the
jsPsych.setProgressBarfunction to manually set the progress bar values. For instance, in your instructions trial, you could use theon_loadfunction to set the progress bar to 0 or a very small value:And to change the values in your main task, you need some way of tracking or calculating how far through the task the participant is. One way to do this is to use jsPsych's data functions, like the
.filterfunction and.countfunction, to figure out how many trials of the main task the person has done. Then you can update the progress bar at the beginning or end of each trial: