Helllo all! Thank you again for all your help with my previous question. I’ve been learning a lot from you, but am currently rather stumped.
OS : Windows 10
PsychoPy version : 3.2.4
Standard Standalone? (y/n) : Yes
Context: After showing an English words with four translation options and displaying and storing feedback for later routines (Correct/Incorrect), I am trying to skip the incorrectMeaningFeedback routine when feedback = ‘Correct’, and run it when feedback =‘Incorrect’. In case of running the routine, you should be able to press ‘t’ to display the correct translation text (setting color from black to white to make it visible). It should only show while keeping ‘t’ pressed; repeated presses should be allowed and press duration cumulatively recorded (didn’t get to that part yet), spacebar should end the routine and continue with the next trial in the outer loop.
A. Routine does not end when feedback = ‘Correct’, instead infinitely displaying the background.
B. Pressing space or t does not end routine or show translation respectively
What I have tried to do is debug with print(), see code below. I have concluded the keys are being registered, but there is something wrong with executing the statements aside from print(). In summary:
Problem A. When the feedback == ‘Correct’:
It prints the ‘End at begin routine correct’ but continues to print the ‘No escape, no t, no space’ until I press escape. I have tried this if feedback == ‘Correct’: both at begin and end or routine.
Problem B. When the feedback == ‘Incorrect’:
It again prints only the associated text in the output when pressing either ‘space’ or ‘t’ or continues to print the ‘No escape, no t, no space’ until I press escape
I have no idea what I am doing wrong here. Any and all help is very welcome, thank you in advance for your response and time!
The current code in the code_iMF
if feedback == 'Correct': trials_feedbackLoop.finished = True continueRoutine = False meaningFeedback = "" #temporarily added as this gave error if not set translationFeedback = "" #temporarily added as this gave error if not set print('End at begin routine correct') #Prints statement, does not end elif feedback == 'Incorrect': meaningFeedback = 'Keep the letter t pressed to see the right translation: \n\n\n' + str(currentWord) + '\n\n\n Press <SpaceBar> to continue' translationFeedback = correctAnswer print('Running incorrect loop')
keys = event.getKeys() if keys: if 'escape' in keys: core.quit() elif 'space' in keys: #must include something that checks whether mouse has been pressed trials_feedbackLoop.finished = True text_iMF_Translation.setColor([-1.000,-1.000,-1.000],'rgb') print('Spacebar pressed, ending routine') elif 't' in keys: text_iMF_Translation.setColor([1.000,1.000,1.000],'rgb') print('t key pressed, color for feedback white') else: text_iMF_Translation.setColor([-1.000,-1.000,-1.000],'rgb') print('No escape, no t, no space')
if feedback == 'Correct': trials_feedbackLoop.finished = True print('End at end routine correct')