I am trying to randomize the presentation order of experiment trials within groups which are specified in a table. I am running into an issue where the experiment freezes once a certain trial is reached, regardless of where it shows up in the overall ordering. In the table I have specified this particular trial is the last in the list of trials for that group, but I don’t know why that would cause execution of the script to stop.
This is because the TextInput element gets deleted once the trial is over, and the .log command on newTrial() is executed asynchronously, so this command will fail when it so happens that it is executed after the trial is over: .log("answer", getTextInput("answer_box"))
Use a global Var element to make sure the element persists outside the trial and the log command never crashes: