Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Supported by

[solved] Form rating scale question

edited March 2013 in OpenSesame

Hi All,

I am trying to make a questionnaire using the form functions with four rating scale items and a "Next" button. I was wondering whether it was possible to make it so that the Next button would advance the program only if all the questions were answered on the screen.

Thanks for all your work on OpenSesame!


  • edited 1:26AM

    Hi Rob,

    Sure, that's possible. You'll need a little bit of Python inline scripting for this. More specifically, you want to check whether none of the rating scale responses has the value 'None' (meaning no box was ticked). In order to use the rating_scale variable in an inline_script item, we use the experiment functionself.get(). The name of a given rating_scale variable depends on what value you gave to the 'var' keyword when you defined the rating_scale widget.

    For example, if you defined it as follows:

    widget 1 1 1 1 rating_scale var="question1" nodes="Agree;Don't know;Disagree"

    the participant's answer is contained by the variable 'question1', which can be made available in an inline_script like so:

    response = self.get("question1")

    For more info about getting and setting variables, see:

    The following inline script should give you an idea of how to do this in practice. Make sure you place the code in the Run phase tab of an inline_script that is appended to your trial sequence after the form_base item and before the logger item.

    # Make a list of all the response values:
    responseList = [self.get("question1"), self.get("question2"), self.get("question3")]
    while True:
        # If one or more of the response have the value 'None':
        if 'None' in responseList:
            # Rerun the item (after preparing it):
            # Check the responses again:
            responseList = [self.get("question1"), self.get("question2"), self.get("question3")]
        # Else, the experiment advances normally.

    An example experiment can be downloaded here (save with the extension '.opensesame').

    Does this help?



  • edited 1:26AM

    This fixes the problem and clarifies a couple of other questions I had about the inline script items as well. I was a bit uncertain on what python code controlled whether a form advanced to the next item in the sequence, but this clears it up.

    Thanks for all the help and the code!


Sign In or Register to comment.