[open] Restrict moving on to next item
Currently, I have a form that displays a word on the left of the screen and a box on the right for a subject to type an associated word. I accomplish this with the widgets and the code below, which are part of a loop.
set cols "1;1;1;1;1;1"
set form_question ""
set form_var "keyboard_response"
set rows "1;1;1;1;1;1;1;1;1"
widget 2 4 1 1 label center="yes" text="[word]"
widget 3 4 1 1 text_input focus="yes" stub=" " return_accepts="yes" var="[form_var]"
Currently, my experiment runs fine, but, if the box is left blank and I press ENTER, the experiment moves on to the next item.
What I would like to do is stipulate that a subject cannot just press ENTER to move on to the next item until she types something in the box. I don't want a subject to accidentally press ENTER and lose the chance to type anything. I tried inserting a keyboard_response, but that requires the subject to press ENTER twice to move on; once for (presumably) return_accepts and once for the keyboard response. I only want the subject to have to press ENTER once to move on (i.e., she should type the associated word, press enter once, and then the loop should move to the next pair).
Does anyone know how I can code this, or is there something I can do with keyboard_response to accomplish what I am trying to do?
Comments
Hi random number,
I think it would be best to place your form item in (a sequence item in) a loop item. The idea is to repeatedly run the form as long as participants haven't provided an answer.
Clicking on the loop item, you can check the "advanced options" box to reveal a break-if command. Here you can insert a command along the lines of "response != '' " (resulting in: break if response is not nothing). It may also be desirable to add a warning message if participants haven't filled in anything. To realize this, you would have to place a second form in the sequence, that is only run (you can indicate a run-if statement) if the first form wasn't answered correctly. The second copy would be identical to the first, with the addition of a warning message. (If you want to implement this, make sure that the first form isn't run again if the second form is run! It requires some logic but it's do-able; let me know if you need help with this).
Good luck,
Cheers,
Josh
Currently, I have a loop which contains a sequence. That sequence contains the variable "word" (my list of words that appear as the subject presses ENTER) and the widgets.
When I type keyboard_response != "" in the advanced options, I get this error message: Failed to compile conditional statement "keyboard_response != ": 'keyboard_response != ' is not a valid conditional statement in sequence item '__NV'
I tried typing "not self.has('keyboard_response')" (without "" of course) in that space in advanced options, and I get
Unexpected error
line: 1
exception message: 'unicode' object is not callable
exception type: TypeError
Traceback (also in debug window):
File "dist\libqtopensesame\misc\process.py", line 139, in run
File "dist\libopensesame\experiment.py", line 347, in run
File "dist\libopensesame\sequence.py", line 47, in run
File "dist\libopensesame\loop.py", line 136, in run
File "", line 1, in
TypeError: 'unicode' object is not callable
Can I add a keyboard_response item and say
Correct response: None
Allowed responses: All
and then make the widget not require ENTER to move on because the keyboard_response item will move the experiment along?
Hi,
Without having tested it I suspect that
""
is not equal to" "
. Don' forget to include a character in between the quotation marks.Regarding your second question, I don't think what you'll have in your mind will solve the issue. Josh's solution is the one I'd recommend as well. So, wrap another
sequence
around yourword
item and set its no. of repeats to a very high number. Additionally, you have to define a break statement that will cause theloop
to stop and proceed with the otherwidgets
.Good luck,
Eduard