The short version of the issue: I have an experiment that shows 4 random numbers that need to be added together (i.e., on each trial, you would see something like 8+3+5+1). Participants type in their response, then should be shown their response and what the correct response was. The numbers, the participant response, and the correct response are all recorded in the data output. I cannot get the experiment to show the correct response on the next routine, nor does it write the correct response to the data in the order that it appears on the screen.
What I have right now:
On the routine that shows the equation:
Begin Experiment
#generate four random numbers to be inserted into the text - this just generates something for them to exist - these could probably be assigned 0s or something, they're just placeholders
numOne = randint(1,10)
numTwo = randint(1,10)
numThree = randint(1,10)
numFour = randint(1,10)
Begin Routine
#generate the numbers for the actual routine
numOne = randint(1,10)
numTwo = randint(1,10)
numThree = randint(1,10)
numFour = randint(1,10)
Then, on the next routine where they get feedback:
Begin Experiment
corrResp = 0
Begin Routine
corrResp = numOne + numTwo + numThree + numFour
thisExp.addData("corrResp",corrResp)
corrResp is put in my text element, like so:
Starting on the second trial, it shows corrResp as the actual correct number, but on the first trial it shows corrResp as 0. I imagine this is because it isn’t correctly writing corrResp yet, but I can’t figure out why. If I move the code of “corrResp = numOne + numTwo + numThree + numFour” to the End Routine section of the first routine, then it actually shows me the correct response for the next loop iteration, essentially giving the participant the correct response for the next trial.
The second issue is that it does not seem to be writing the corrResp into my data in the correct order. The initial assignment of 0 doesn’t appear in my data, even though it shows that on screen, and then it writes some of the correct corrResp to seemingly random rows and other times I can’t figure out where the corrResp number in the data came from.