Creating Variables dependent on other variables
I am currently designing an eye-tracking experiment for emotion recognition with OpenSesame 3.1.9b1.
To collect the answers, I used the built-in form for multiple choice answers.
According to my what I read on here, there is no way to indicate the correct response in the forms, right?
And also, there is no easy way to let the 'form_response' give out numbers instead of the respective strings, right?
I am very new to programming, and just started learning python to accomplish what I want.
So I tried to define a new variable with an inline_script-item after the form and before the logger.
I managed to create the variable, and it also prints some values to the log-file.
I want the variable to print 1 if "correct_response" and "response" are the same (strings) and 0 if otherwise.
(The definition for the correct response was done in the loop table with the variable correct_response, in case you wondered.)
While testing, it only prints a 0 to the file, with an occasional 1 now and then.
The 1, however, does not turn up when the answer was right, but seems to appear randomly, also with wrong answers.
So I suppose there is something wrong with my code, or the code cannot access the variables in the way I want it to...
The code I used is the following:
def emotion_recognized (): print self.get('emotion_recognized') emotion_recognized = () if var.get('response') == var.get('correct_response'): emotion_recognized = 1 else: emotion_recognized = 0 var.set('emotion_recognized', emotion_recognized)
I would be really happy if anyone could help me resolve this, somehow!
Have a good start into the new week.
Best wishes from Switzerland and thank you very much in advance