Hi everybody, I’m new to PsychoPy and I am trying to make an experiment in which the user is presented a question with checkboxes, and is supposed to select two out of the four answers. If the user clicks one right checkbox, they get one point, and if they click two, they get two points. I have made the checkboxes (through shapes) and have gotten a way for Psychopy to record which box the user selects, but I’m not sure how to incorporate the right/wrong aspect and the point system.
OS (e.g. Win10):
Mac OS High Sierra
PsychoPy version (e.g. 1.84.x):
What are you trying to achieve?:
I have made checkboxes out of the shape option in Builder, and I want to associate each checkbox with a wrong/right answer. For example, there will be a problem presented, and the user will click two of the four checkboxes. If the user selects one of the correct checkboxes, they will get one point, and if they select both, they will get two points.
What did you try to make it work?:
So far, I tried to make an excel sheet and set corrAns to the two checkboxes which are correct and added some code in, but when I run the experiment, the column to indicate whether the user got the answer correct or incorrect always shows up with 0, so I’m not particularly sure where to start.
OK so it sounds like you have 2 shapes that are ‘clickable’ by the mouse. You will then see that the mouse component also saves a set of parameters that you define (the default parameter is ‘name’ which is whatever you have typed in the ‘name’ field of your shape).
Add a column to your conditions file called ‘corrAns’ then specify on each trial the name of the shape that could be clicked (for the correct answer).
To save the ‘correct’ answer, you then need a small code component (custom>code). In the ‘end routine tab’ use:
if mouse.clicked_name == corrAns:
correct = 1
correct = 0
trials.addData('correct', correct)#add this variable to your data file
#substitute 'mouse' for the name of your mouse component
#substitute 'trials' for the name of your loop
You can see a similar technique outlined here for typed responses https://www.youtube.com/watch?v=-Fto45M7bS0
Hope this helps,
Thank you! Is there any way to make it so the correct point system gives one point for each individual correct answer? It seems as the code attached works to grant a the user one correct point tally if the user selects the exact two answers that I put in the corrAns column, but if the user only selects one correct answer, is there a way to alter it so that the user gets one point (versus zero points)?
Aha ok yes I see you are trying to actually check multiple clicks. In that case, you need to be keeping a list of clicks and comparing them to a list of predefined correct clicks (from your ‘corrAns’ column as you say).
Does this demo do something similar to what you need?
Yes, it does! Thank you so much!