[solved] Using form_multiple_choice: how to log answers of 8 questions in a row?
Hi,
I am working on a short questionnaire using form_multiple_choice. I have 8 MC questions with four answer options each (of which only one is correct). I want them all to appear one after the other and then provide a feedback screen afterwards that indicates the score.
I have built a small test experiment with three questions. I don't quite understand how the responses on the form_multiple_choice need to be logged and how I indicate which of the options is correct. I have now put together this:

Do I need a logger after each form_multiple_choice or is that overkill? How else can I keep track of the responses to the questions? Any pointers would be greatly appreciated. ![]()
Thank you for your time and have a nice day!
- Florian
Comments
Hi Florian,
How about you use a
loop? In this sense, in each iteration you run yourformonce with one of the questions, log the response (with alogger) and then proceed with the next iteration. Once, all the questions are answered, you can leave theloopand present the feedback. Depending on what the feedback is supposed to look like, you might have to add some extra book keeping in aninline_script(accessing current response and store them permanently in another variable).In the
loop_tableof theloop, you'll have to set the question and the answers as variables.Does this help you?
Eduard
Hi Eduard,
thanks, that got me at least two steps further!
I now have a
loopwith a couple of variables (question_text, answer_option_[1 through 4], and correct_response (indicating which of the options [1 through 4] is correct).So now I have this structure:
EDIT: I just realized that the formatting of the code block below was completely messed up. Fixed it now.
When I run the experiment, all questions are shown - yay!
However, I don't understand how to log the responses and/or access them in the
inline_script. According to this part in the documentation I should be able to access them usingvar.variable_name. In theform_multiple_choice, I indicate that the "response variable" is response. In theinline_script, however, neitherprint(response)norprint(var.response)seem to work (both give me the error that they are "not defined").What does seem to work is using
print(self.get("response"))(as suggested in this part of the documentation). This prints the text of the answer option, though. Is there a way to get the index of the option?Thanks!
First of all, which OpenSesame are you using? Accessing variables via
var.<varname>was only introduced in Opensesame 3.0. For all older versions, you'd have to do something like this:There are some ways how to retrieve the index. The most straightforward one is this, I think
I hope you get the idea.
Eduard
Hi Eduard,
this seems to work really well! I have used the suggested if-elif-else structure to determine the ID/index. When I use
exp.set('varname', index), theloggerwill write varname to the .csv file. Awesome! Thanks a lot for that!Now I am wondering how I can display the score on the feedback
sketchpadat the end. If I compute the score in the same inline_script and set it usingexp.set('score', score), it gets written to the .csv as well. So that's great because I have trial-by-trial information regarding the score. However, when I try to set the text on thesketchpadto "Your score is [score].", it will complain that I am trying to use a variable that does not exist.You said above:
How would I go about doing this?
Thank you for your time, Eduard - I really appreciate it!
P.S.: I am using OpenSesame 2.9.6 on Mac OS Yosemite.
I don't think it matters for your case. So just briefly, when using a
loopto repeat some action and save some outcome to a variable, you need to make sure that you can use the outcome of each iteration, before it is overwritten by the next iteration. You can uselists rather than simple variables for example, but there many ways to go. At any rate, it should not matter for you.YOur problem lies in the
prepare-runstructure of OpenSesame. That is, since your outcome variable is computed during therunphase, on the fly, so to speak, it doesn't exist yet, when all theitems in thesequenceare initialized (duringprepare).If you want to present feedback only once in the end of a block of questions, you can move it outside the
sequenceand you should be set (maybe you also have to initialize yourscorevariable somewhere before). If you need it updated on every trial it is a bit more complicated.Eduard
Thanks for the quick response.
This is the structure of my experiment at the moment:

It says here that "All inline_script items share the same workspace. This means that variables that are created in one inline_script are available in another inline_script." That's why I tried to initialize the
scorevariable in theinline_scriptinit_score (it contains only one line:score = 0). In theinline_scriptinside mysequenceI have this code:(
crespis either 0 or 1, indicating a correct response.)The
loggerwill write this to the file but I still can't accessscorein the feedbacksketchpad.That's what I did but I am still getting the message that the variable doesn't exist. How would I initialize it before and where?
This is the very last step I need to make this work.
Thanks a lot!
Ah, I was afraid this will happen. You could try the
feedbackitem. So, don't use an a regularsketchpad, but the a version of it which is dedicated to make feedback presentation easier.Alternatively, instead of a
sketchpaduse aninline_scriptand and put your feedback in therunphase.Eduard
Hi Eduard,
using a
feedbackitem with the same text on it (i.e., "Your score is [score].") works without any problems! Beautiful. Thanks a lot for your help!