Howdy, Stranger!

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

Supported by

[solved] Questionnaire issues

edited September 2014 in OpenSesame

Hi I am having trouble with some parts of a questionnaire
I want through opensesame to have the following:
if one presses the "next" button without having checked one or more of the available checkboxes to warn the user and not let him/her continue

and on another note

how can i control one of the checkboxes? e.g. if i have 6 checkboxes in a question, the user can select any one the five (one or more) except for one checkbox the 6th one...if that is selected it cannot select any of the others and has to press "next" for the next question....

Thanks ahead of time for the help

Comments

  • edited 10:50PM

    You can find a very useful discussion about about validating form input here:

    Essentially, to validate form input, you will need to implement some checks in an inline_script and, if necessary, run the form until your criteria are met. Forms don't have any built-in validation functionality, so -- to answer your second question -- you cannot disallow participants from checking too many checkboxes. However, you can check afterwards whether participants have checked too many checkboxes, and, if so, execute the form again.

    I cannot say anything more specific, because you would need to provide more details about the implementation of your experiment.

    Cheers!
    Sebastiaan

  • edited September 2014

    Thanks for your response

    So for example in the partial script below (which is modification of your questionnaire demo) I want to NOT allow participants to move to the next question unless at least one checkbox has been clicked...as in the consent form...the code below

    # Generated by OpenSesame 2.8.3 (Gutsy Gibson)
    # Wed Sep 10 19:29:22 2014 (nt)
    # <http://www.cogsci.nl/opensesame>
    
    set mouse_backend "legacy"
    set subject_parity "even"
    set height "768"
    set font_family "mono"
    set font_italic "no"
    set synth_backend "legacy"
    set title "Questionnaire"
    set coordinates "relative"
    set start "experiment"
    set sampler_backend "legacy"
    set transparent_variables "no"
    set foreground "white"
    set font_bold "no"
    set description "Default description"
    set background "black"
    set decline_message "You need to accept the consent form to participate!"
    set font_size "18"
    set keyboard_backend "legacy"
    set canvas_backend "legacy"
    set compensation "0"
    set bidi "no"
    set subject_nr "0"
    set width "1024"
    
    define form_consent Consent
        set accept_text "Συνεχίζω!"
        set rows "1;4;1;1"
        set description "A simple consent form"
        set checkbox_text "Έχω καταλάβει την διαδικασία και επιθυμώ να συνεχίσω."
        __form_text__
        Το πείραμα θα αρχίσει με κάποια δημογραφικά στοιχεία και στη συνέχεια με την συσχέτιση χειρονομιών με κάποιες λέξεις που αναφέρονται σε ένα Χ αντικείμενο.
    
        Είναι απαραίτητο να είστε ακριβείς και γι' αυτό το λόγο δεν υπάρχει χρονικός περιορισμός στις επιλογές σας.
    
        Στο τέλος του πειράματος θα σας εξηγήσουμε τι ακριβώς μελετάμε. 
    
    
        Ευχαριστούμε για την συμμετοχή σας!
        __end__
        set form_title "<span size=24>Πειραματίσου μαζί μας!</span>"
        set decline_text "Όχι, ευχαριστώ"
        set decline_message "You need to accept the consent form to participate!"
        widget 0 0 2 1 label text="[form_title]"
        widget 0 1 2 1 label center="no" text="[form_text]"
        widget 0 2 2 1 checkbox var="checkbox_status" text="[checkbox_text]"
        widget 0 3 1 1 button var="accept_status" text="[accept_text]"
        widget 1 3 1 1 button text="[decline_text]"
    
    
    define form_base Demographics
        set rows "1;1;1;1;1"
        set cols "1;1;1;1"
        widget 0 0 4 1 label text="<b>Μερικά απαραίτητα στοιχεία...</b>"
        widget 0 1 1 1 label center="no" text="Φύλλο"
        widget 1 1 1 1 checkbox group="gender" text="Γυναίκα" var="response_gender1"
        widget 2 1 1 1 checkbox group="gender" text="Άνδρας" var="response_gender1"
        widget 0 2 1 1 label center="no" text="Ελληνική γλώσσα"
        widget 1 2 1 1 checkbox group="language" text="Μητρική" var="response_language1"
        widget 2 2 1 1 checkbox group="language" text="Μη μητρική" var="response_language1"
        widget 0 3 1 1 label center="no" text="Ηλικία"
        widget 1 3 3 1 text_input var="response_age1"
        widget 0 4 4 1 button text="Οκ!"
    
  • edited 10:50PM

    I want to NOT allow participants to move to the next question unless at least one checkbox has been clicked...as in the consent form...the code below

    Right, so that's what the discussion I linked to above is all about :p. See especially this comment:

  • edited September 2014

    okay last message i hope...
    i did look at the previous messages and played with the sample code but i am still having trouble. So i modified the code for the rating scale for checkbox while maintaining all other code intact but i still have a problem....that is, you can leave the checkbox unchecked and it will still go on to the next trial....what am i missing?

    Code below:

    set mouse_backend "legacy"
    set subject_parity "even"
    set response2 ""
    set height "768"
    set sound_buf_size "512"
    set font_italic "no"
    set custom_cursor "yes"
    set synth_backend "legacy"
    set title "Example for Sylvia"
    set coordinates "relative"
    set start "experiment"
    set sampler_backend "legacy"
    set font_family "mono"
    set foreground "white"
    set font_bold "no"
    set description "In this example it is checked whether the text input is an integer between 0 and 100."
    set background "black"
    set font_size "18"
    set keyboard_backend "legacy"
    set canvas_backend "legacy"
    set compensation "0"
    set subject_nr "0"
    set width "1024"
    
    define inline_script create_form
        ___run__
        from libopensesame import widgets
    
        form = widgets.form(self.experiment, cols=[3,2], rows=[1,1,1,1,1,1,1,1], spacing = 10)
        titel = widgets.label(form,  text='Ongezond snacken is iets...', center=False)
        vraag1 = widgets.label(form,  text='1. dat ik regelmatig doe', center=False)
    
        instructie= widgets.label(form, text='1 = helemaal oneens, 7 = helemaal eens')
    
        ratingScale1 = widgets.checkbox(form, var='ongezond_SRHI_item1')
    
        nextButton = widgets.button(form, text='Verder')
    
        form.set_widget(titel, (0,0), colspan=1)
        form.set_widget(vraag1, (0,1))
    
        form.set_widget(instructie, (1,0))
        form.set_widget(ratingScale1, (1,1))
    
        form.set_widget(nextButton, (0,7), colspan=2)
        form._exec()
        __end__
        set _prepare ""
        set description "Executes Python code"
    
    define sequence experiment
        run warning_message "never"
        run create_form "never"
        run inline_script "always"
    
    define inline_script inline_script
        ___run__
        while True:
    
            incomplete = False
    
            exp.items["create_form"].run()
    
            if (self.get("ongezond_SRHI_item1") == "None" 
                ):
                incomplete = True
    
            if not incomplete:
                    break
    
            else:
                exp.items["warning_message"].prepare()
                exp.items["warning_message"].run()
    
        __end__
        set _prepare ""
        set description "Executes Python code"
    define sketchpad warning_message
        set duration "1000"
        set description "Displays stimuli"
        draw textline 0 0 "You didn't answer all the questions..." center=1 color=white font_family="mono" font_size=18 font_italic=no font_bold=no show_if="always" html="yes"
    
  • edited 10:50PM

    Hi,

    You're very very close. The problem was that an unchecked checkbox sets its response variable to 'no', and not to 'None'. This explained in more detail here:

    So the script below should do the trick. For future reference, you don't need to implement the form in an inline_script (although you can). You can also implement the form using a form_base plug-in, and only use an inline_script for the checking part.

    Cheers!
    Sebastiaan

    while True:
        incomplete = False
        exp.items["create_form"].run()
        print self.get("ongezond_SRHI_item1")
        if self.get("ongezond_SRHI_item1") == "no":
            incomplete = True
        if not incomplete:
                break
        else:
            exp.items["warning_message"].prepare()
            exp.items["warning_message"].run()
    
  • edited 10:50PM

    I created an experiment that runs perfectly on a MacBook Pro (OS X; OpenSesame 0.27.4). However, when I try to open the experiment file on my testing machine - a PC (running OpenSesame 2.8.2) - it gives an error message that reads: Unexpected error: exception message. Exception type: WindowsError

  • edited 10:50PM

    Hi Scarlett,

    As a first step, you could upgrade to OpenSesame 2.9.0. However, in case this doesn't resolve the issue: Do you see additional output in the debug window? And/ or do you see a opensesame.exe.log file in the OpenSesame folder? If so, please post!

    Cheers,
    Sebastiaan

Sign In or Register to comment.