Howdy, Stranger!

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

Supported by

Problem with ratingscale


is there any way to group a variable for a checkbox and a rating scale? So that the participant can answer either with a point on the scale or by marking a checkbox. I also need to have a validator that checks that the participants have done one of these things. It works if I have a validator with the following code: "return var.var1 != 'no'" and var1 is the variable for both the rating scale and the checkbox(not adding a group for the checkbox). However, in this case, it's not possible to unselect the rating scale. This means that if the participant first click on a point on the scale and then wants to answer with the checkbox instead, it's not possible. (I'm using legacy and inline scripts).

Thanks in advance!


  • Hi Lina,

    That's an interesting scenario. So I guess you want have a checkbox that participants can check to indicate that they don't want to check anything on the rating scale. Right? Of course the most pragmatic solution would be to simply add one node to the rating scale, and label it 'Not applicable' or something like that.

    A more elaborate solution would be to validate the form on every click, and uncheck any nodes on the rating scale whenever the no-rating checkbox has been checked. That's possible, but it requires a bit of hacking, as you can see in the script below. (Personally I'd probably go with the easy option of adding a node to the rating scale!)



    def validate():
        # If the no-rating checkbox is checked, disallow any value to be set on
        # the rating scale
        if var.no_rating != 'no':
        print(var.no_rating, var.rating)
        # Only accept the form when the Ok button has been clicked
        return var.ok_button == 'yes'
    form = Form(validator=validate)
    # The .construct() is a hack that turns the widget into an object that
    # supports .set_value() etc.
    rating_scale = RatingScale(
        click_accepts=True  # To call validate() on every click
    checkbox = Checkbox(
        text='Don\'t rate',
        click_accepts=True  # To call validate() on every click
    button = Button(text='Ok', var='ok_button')
    form.set_widget(rating_scale, (0, 0))
    form.set_widget(checkbox, (1, 0))
    form.set_widget(button, (0, 1), colspan=2)

  • Hi Sebastiaan,

    yes exactly! The reason for this question was that I wanted to add a "Don't want to answer" option. Thank you so much for your suggestions. I'll try both and see what works best for me.

    All the best,


Sign In or Register to comment.