Issue with Arrow Position in IOWA Gambling Task Online Version - javascript
Dear all,
I am in the process of developing an online version of the IOWA Gambling Task and I’ve encountered a small issue that I hope you could help with.
In this task, participants choose a card from four decks, with each deck offering different rewards or penalties. After a participant selects a card, I would like the selected card to be visually highlighted.
To achieve this, I’ve decided to use an arrow to indicate the chosen card. I created the arrow on a sketchpad, and its x-position is determined by a JavaScript function placed after the keyboard input and before the sketchpad.
While this setup should work in theory, the arrow is consistently showing the position of the previous trial. For example, if a participant chooses deck 1 on trial 1, the arrow does not appear. However, in the second trial, if they select deck 3, the arrow is displayed below deck 1, even though it should be placed below deck 3.
I’ve attached the OpenSesame file for your reference. The creation of the x_arrow
variable is in the "update_arrow_keys" script, while the arrow itself is displayed in the "feedback_sketchpad" sketchpad.
You will notice some lines of code in the file that are currently not performing any essential functions; these are from various solutions I have tried. However, they should not affect the overall experiment.
Any insights or suggestions you have would be greatly appreciated!
Best regards,
Michele
Comments
Hi @michelescandola
I ran into the same issue and managed to solve it by moving the feedback sketchpad to the very beginning of the sequence. This way, it uses the updated x_arrow value from the previous trial, as the sketchpads seem to be prepared in advance at the start of each trial (and therefore do not take into account updates that occur later in the trial).
Let me know if this solution works for you!
Claire
Check out SigmundAI.eu for our OpenSesame AI assistant! 🤖
Thank you very much, Claire.
Your solution resolved my issue from a practical standpoint.
However, I still don't fully understand why my original version wasn't working. Nevertheless, considering that OpenSesame is a free tool, we should be very grateful for its availability.
Thanks again!
Hi @michelescandola
Glad it worked!
Sorry for not being clearer earlier. Your original version didn't work because sketchpad items are created at the start of each trial (i.e., in a "prepare" phase of the sequence, to ensure better timing; see documentation here and here).
These sketchpads are then drawn as needed during the trial (in a "run" phase), but aren't updated until the next trial when the sketchpad is re-created at the beginning of the sequence, with the new parameters :
[...] the contents of a sketchpad cannot depend on what happens during the sequence that it is part of. For example, you cannot use a sketchpad to provide immediate feedback on the response time collected by a keyboard_response item (assuming that the sketchpad and keyboard_response are part of the same sequence.)
This would explain why changes made during the trial weren't reflected in your sketchpad.
I hope this makes sense!
Claire
Check out SigmundAI.eu for our OpenSesame AI assistant! 🤖