Unable to translate code component in Pavlovia

@sawal you are right. I created formAnswered on my own, it wouldn’t work in your code. I wanted the continue button to appear only after all of my slider questions were answered. If you want the continue button to be present from the beginning of your routine, you don’t need that first “if” statement at all. Just start with the “draw continue button” code, and make sure it isn’t indented. You should take out all uses of continueButtonOn as well.

For making the button disappear, you will want to include these lines in the end of your routine:
Py:

continueButton.setAutoDraw(False)
continueButtonText.setAutoDraw(False)

JS:

continueButton.setAutoDraw(false);
continueButtonText.setAutoDraw(false);

==========================================

On the other hand, if you (or anyone else) want to do something like I did…
The “form” I am using is actually just a bunch of sliders created by builder, since forms were not yet implemented in PsychoJS for Pavlovia. In the “each frame” section, before the code from my last response, I check if each slider has a response. If all of them do, then formAnswered becomes true. Something like:

Py:

# how many questions are answered?
n1 = slider1Name.getRating() is not None
n2 = slider2Name.getRating() is not None
n3 = slider3Name.getRating() is not None
formAnswered = n1 and n2 and n3

JS:

// how many questions are answered?
n1 = (slider1Name.getRating() !== undefined);
n2 = (slider2Name.getRating() !== undefined);
n3 = (slider3Name.getRating() !== undefined);
formAnswered = ((n1 && n2) && n3);

Make sure your slider names match what you have created instead of “slider1Name”.

I hope that answers your question!

1 Like

Oops just saw that everything works, glad you figured it out that last part by yourself!