# Multiple choice task with displayed answer and in/correct answer registered (urgent!)

**URL:** <https://discourse.psychopy.org/t/multiple-choice-task-with-displayed-answer-and-in-correct-answer-registered-urgent/27487>\
**Category:** Builder\
**Created:** [February 17, 2022, 3:54pm UTC](https://discourse.psychopy.org/t/multiple-choice-task-with-displayed-answer-and-in-correct-answer-registered-urgent/27487 "2022-02-17T15:54:15Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![adidance](https://avatars.discourse-cdn.com/v4/letter/a/3ec8ea/32.png) [@adidance](https://discourse.psychopy.org/u/adidance)\
**Post date:** [February 17, 2022, 3:54pm UTC](https://discourse.psychopy.org/t/multiple-choice-task-with-displayed-answer-and-in-correct-answer-registered-urgent/27487/1 "2022-02-17T15:54:15Z")

</div>

PsychoPy Version 2021.2.3

**What are you trying to achieve?:**  
This is my first experiment and I don’t understand much of coding. I’m using Builder and the experiment should be run online.  
One routine in my experiment (in a loop together with other routines) includes a multiple choice task, i.e. a question and three answer options. I would like for the participants to see what answer they give and to see later in the data file whether they gave the correct answer or not.

**What did you try to make it work?:**  
So far, I have inserted three text components into my routine, one with the question and three with the options (I tried putting everything in one text component which didn’t work, see below). The text always refers to the conditions file ($cont\_Que, $answ\_Opt1, $answ\_Opt2, $answOpt3), set every repeat. I also have a column with corrAns in that file (being either a, b, or c).

For the response I have included a keyboard component since this allows me to check for the correct answer. However, I don’t know how to display the answers the participants give on the screen. I do not want them to know whether their answer was correct or not (no feedback), but ideally, they’d see and be able to edit their answer, plus in the data, I would see whether their answer was correct or not.  
I also have a button to click that forces end of routine and continues to the next loop repetition.

**What specifically went wrong when you tried that?:**  
When I tried putting the question and the answer options in one text component, with a new line each time, the text shown was simply $cont\_Que, $answ\_Opt1, etc. Did I miss something here, is it possible to include everything in one component?

For displaying answers, I have read something on the forum about combining a text component and a code component, but I didn’t quite get what I’d need to do…  
Could I maybe use a textbox component (which automatically displays text AND is editable) and add some code so that the data will later show whether it was a correct or an incorrect answer?  
Even better would it be to only allow one letter in that textbox, to avoid answers like “ab” because the participant forgot to delete the first letter.

If you need any more info or a Python transcript please let me know.

---

<div class="post-metadata">

**Author:** ![wakecarter](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/wakecarter/32/5753_2.png) [@wakecarter](https://discourse.psychopy.org/u/wakecarter)\
**Post date:** [February 17, 2022, 4:21pm UTC](https://discourse.psychopy.org/t/multiple-choice-task-with-displayed-answer-and-in-correct-answer-registered-urgent/27487/2 "2022-02-17T16:21:32Z")

</div>

> [@adidance](#):
>
> Even better would it be to only allow one letter in that textbox, to avoid answers like “ab” because the participant forgot to delete the first letter.

I would use event.keys() in a code component for this to allow maximum flexibility.

My Brookes Template 2020 demo includes free text responses, as does digit span, free recall and key check.

> [@PsychoPy Online Demos](https://discourse.psychopy.org/t/psychopy-online-demos/22319):
>
> If you have routines or experiments that are likely to be useful to others, please create a post in this thread, editing your post to add new demos so there is one post per creator. Ideally set your demos so they can be tested without consuming a credit (if you don’t have a site license) by adding a final routine that can’t end, disabling save incomplete results and adding a small number of credits. Please do not discuss the demos in this thread or create more than one post unless you have a la…
