Conditional loop not working on Pavlovia

If this template helps then use it. If not then just delete and start from scratch.

OS Win10:
PsychoPy version : 2021.1.2
Standard Standalone?: y
What are you trying to achieve?: Make a demographic form. I have sliders and textboxes participants have to fill in. When they are done they click on a ‘Next’ button. If they have not filled in all the questions, a error message appears.

Everything works great offline, but online, the error messages don’t show up on Pavlovia. Clicking on the Next button goes to the next page even if the answers were not provided.

What did you try to make it work?:
I have this code component:
Begin Experiment
msg_10 = ’ ’

Each Frame
click = mouse.isPressedIn(polygon, buttons = [0])
if click == True:
if id.text ==’ ’ or ‘’:
msg_10 = ‘Please provide your id’
elif age.text == ’ ’ or ‘’:
msg_10 = ‘Please indicate your age’
elif gender.getRating() == None:
msg_10 = ‘Please indicate your gender’
continueRoutine = False

What specifically went wrong when you tried that?:
It’s weird because clicking on the button will go to the next page, as specified by the else condition, but nothing else in the loop works on Pavlovia.

I’m surprised this works locally.

When coding you can’t write if X == A or B, you have to write if X == A or X == B

Thanks for the clarification!
I’m new to coding and i’m trying stuff out.

I figured out a new way to write this that seems to work:
if mouse.isPressedIn(polygon, [0]) and id.text != ’ ’ and age.text != ’ ’ and gender.getRating != None:
continueRoutine = False
elif id.text == ’ ':
msg_10 = ‘Please provide your id’
elif age.text == ’ ':
msg_10 = ‘Please indicate your age’
elif gender.getRating() == None:
msg_10 = ‘Please indicate your gender’

However, on Pavlovia the page will just go to the next as if set on a timer. This only happens for the first routine. None of my component has a set end time. This does not happen locally.
Any clue what is going on?


I suspect that the issue is with .text

How are you setting those values? I’m not sure of the functionality of editable text boxes since I haven’t yet started using them instead of code based solutions.

Check my crib sheet for how to view the browser console and add print statements to view the values of your variables)

The values (’ ') are those I have as default in the textboxes and slider. So if a participants forgets to enter a value, the message will be displayed and they won’t be able to proceed until they entered a value.

I’m not sure where I found .text anymore. I tried getText(), and the same issue occurs online (although it still works locally).

Can you tell me more about your code based solutions?


So I modified the code a bit and added console logs and it works!
Although a bit weirdly. If I hover the mouse over the polygon button without clicking the button, the message will appear. As far as I am concerned, this doesnt bother me too much, but i’m curious why this is happening?

Offhand I don’t recognise the use of , [] within isPressedIn

I took it out and the hover thing still happens. So I doubt this is the source.