Hello!
I am not sure that the code components are the problem. The symptom is that the experiment stops at a gray screen in Pavlovia, when the task loops should start. The first 4 routines (that are not embedded in a loop) run normally, but when the tasks should start, I can only see a gray screen. I read on the forum that similarproblems might be because of the coding components (here: Experiment running in builder but stops after 1 trial in pavlovia). This is why I started checking them. However, I am not a programmer and I am not that familiat with coding to understand if the problem is really there or I should check some other aspects of the task.
Regarding the questions, I have 4 different tasks that participants complete in a random order. For 3 of the tasks I use code components to show feedback to participants after each response they input and offer them the correct solution if their answer is wrong.
- I do not use Python libraries.
- I only have code components inside routines that are part of a trial loop (training and test) and the code is in the Begin routine part. The code routine si accompanied by a Text routine, that shows the text for the feedback.
- The code components have 2 roles: (1) show feedback and/or (2) save scored answer in data file (1 if correct, 0 if incorrect)
I will exemplify for the Math task:
The participant is shown an equation on the screen - say 1+2+3. They ;hit a button on the screen when they are finished calculating, input their result in a text-box (ex., 6) and hit a submit answer button on the screen. At this point, the experiment shows them feedback - ‘Correct’ or ‘Incorrect. The correct answer is $correct answer for 1+2+3 equation’, based on their input answer.
This is the structure of the training routine - show equation > input answer > show feedback
I have a conditions file where I have all equations and their correct answer in separate columns (correct answers included initially as numbers, but then changed to strings, see below). I wanted to use this last column to determine the feedback, show the correct answer and save the score (1/0) for each equation in the data file. To do this, I made a code component where I wanted to first determine if the answer is correct and, based on this, to show the feedback - the code I showed in the last post (if input answer = correct answer in conditions file > show correct feedback, else > show incorrect feedback + correct answer).
However, because I needed to add the correct answer to the string “Incorrect. The correct answer is…”, psychopy wouldn’t concatenate the correct answer unless it had “” around it in the Excel file (the error said it couldn’t concatenate string + integer). So all correct answers are written “6” in the Excel file and I used the ’ " ’ to make the input answer a string, so I can compare it with the one in the Excel file.
Is it likley that this is the problem? What else could it be?
Thank you and sorry for the long text.