Accessing Global Variable in Trial #1473
Unanswered
isabelletelford
asked this question in
Q&A
Replies: 1 comment 1 reply
-
Hi @isabelletelford, This is a case where you need dynamic parameters. This video goes into more detail about the flow and why this is necessary. |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi there,
I have a global variable
correct_trials
that is updated at different parts of my experiment to determine how many of the headphone check trials (the headphone check is 6 audio-button-response trials to determine if the participant's audio is good enough to complete the experiment) in the past headphone check node (includes all 6 trials) were correct. It's then used to decide if they have passed or failed the headphone check, and to determine whether they repeat it (after which there are other possible paths the experiment can take depending on the success/failure of that second headphone check) or go on to the main experiment.If they fail the check the first time, an instructions trial is run telling the participant how many trials of the 6 they got right. At this point,
correct_trials
is updating correctly (if I do aconsole.log(correct_trials)
the correct number is printed, and it recognizes if you passed the headphone check, skipping over the instructions trial as expected), but when it is used in the pages part of the instructions trial, it is always displayed as whatever the variable is initialized as. This is what is currently not working:You have failed the headphone check, getting ' + correct_trials + ' out of 6 trials correct. You need at least 5 correct to pass.
No matter how many trials were correct, if you fail the check (get <5 correct), it says 'You have failed the headphone check, getting 0 out of 6 trials correct' ascorrect_trials
is currently initialized to be 0. I am not sure if I am misunderstanding the control flow of JavaScript/jsPsych, but I cannot figure out how to get this piece of text to include the most recent value ofcorrect_trials
, and would appreciate any insight into what's going on! Here is some of my code, I will try to include everything that has to do with this variable.`
Beta Was this translation helpful? Give feedback.
All reactions