Hi! I am trying to program an experiment and am not familiar with python coding.
Basically I have participants view different general knowledge questions and then answer a few different questions about the general knowledge questions that they are viewing. The setup of the experiment is that they are shown a general knowledge question, they are asked if they ever knew the question, then they are asked to type in the answer, then they are asked to rate how confident they are in their answer, and finally they are asked if they would like to study the question again (y for yes and n for no). This loop runs through for each question and works, but I need to add another component. I am trying to write a code for two things.
First: After participants view all of the general knowledge questions and answer y or n for if they want to study the question again, I want them to be put into a routine in which they actually study the questions that they selected y for.
Second: I need a counter to display on the screen for each question they select y for in the loop. They are only allowed to select 33 out of 99 questions so I need it to count down from 33 so they know how many more questions they can select.
If anyone could help me with this I would be so grateful! Not sure if using an adaptive staircase is the best option.
Well, please understand I mean this constructively, but I think there are a couple reasons no one has responded. Right now your question is very broad and general, and in thinking about how to help you, the only way to provide an answer would be to essentially make the experiment for you.
You’ll get a better response if you give one clear question, show us how you tried to implement it, and why it’s not working out. Short minimal working examples that people can quickly read, download, understand, and tinker with will encourage people to answer, and often when you make the MWE (minimal working example) you find the answer to your problem. Specifically, have you tried the staircase demo?
I understand that I’m not being specific, but that is because I am very new to this and don’t even know where to start (I have done all of the demos I could find). I also cannot find anything similar to what I am doing on any forums. Maybe I can just start with this question. How can I make a countdown that starts at 33 and continues to count down each time a participant presses the “y” key. So far I have created a variable called countdown and have used an “if, else” statement.
intial = 33 (I put this is the beginning of the experiment)
i = 1
if key_resp_3 = 'y’
countdown = initial - i
else key_resp_3 = 'n’
countdown = initial
With this the number will go down to 32 but will never advance further. I’m really not sure how to approach it.
First, I don’t see why you would need i. Second, the if/else block is not properly indented. Third, comparisons in Python are made via ==, while = is an assignment. Fourth, as far as I know, response keys are stored in key_resp_3.keys, which is a list, not a string. So the comparisons will have to look differently. Taken together, the code could like something like this (I wrap the code block in triple backticks here to have to forum format it properly):
# Beginning of the experiment
intial = 33
countdown = initial
# In the loop
if key_resp_3.keys[0] == 'y':
countdown -= 1 # Subtract 1
else: # 'n' response, I guess...
countdown = initial
It is not clear to me why you would want to reset the countdown entirely on evey n response, though. Also I don’t know whether to expect any other responses than simply y and n, and if more than one key presses per trial will be collected. Depends on the configuration of the keyboard component.
You need to learn at least the most basic Python syntax to understand what you’re doing here. I think this website can be helpful. Otherwise you will not be able to understand and adjust the code later on! Please do take the time to learn a little Python, or the amount of support required to get you fully up and running would easily exceed what many would be able (and willing) to provide on this forum. This is not meant to discourage you in any way, but should serve as a motivation
Thanks so much! I used i because I’m used to coding in other platforms like spm where it would be required. The only responses I would get for this would be ‘y’ and ‘n’ for yes and no. Also, I don’t want to reset the countdown on every response. I want it to remain the same when participants respond n and count down by 1 every time they respond y. I will definitely check out this website. I appreciate you being so helpful.