Randomizing Limited Radiobutton Options


Author
Message
Dave
Dave
Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)
Group: Administrators
Posts: 13K, Visits: 106K
Dave - 2/9/2022
emoe - 2/9/2022
Hi,

I'm new to coding and Inquisit and I'm trying to randomize what options are available for subjects to select using radiobuttons. I have 8 total options, but only want 2 options presented at a time, and for these 2 to always be presented together for that particular subject. I would like to have these pairs randomized so each subject gets a different set of pairs. 

Also, is there a way to block out a radiobutton option after it has been selected once? For example, if subjects are always directed back to the options screen where they can select from the 8 (or 2) different options, could I make it so people aren't able to select their past choices?

Here is what I have so far for anPost New Topicother condition (where subjects can select from all 8 topics at once).

Thank you!

<surveypage q1>
/ questions = [1=q1_rb]
/ branch = [if (radiobuttons.q1_rb.response=="Psychology") surveypage.q1_followup1]
/ branch = [if (radiobuttons.q1_rb.response=="History") surveypage.q1_followup2]
/ branch = [if (radiobuttons.q1_rb.response=="Folklore") surveypage.q1_followup3]
/ branch = [if (radiobuttons.q1_rb.response=="Physiology") surveypage.q1_followup4]
/ branch = [if (radiobuttons.q1_rb.response=="Chemistry") surveypage.q1_followup5]
/ branch = [if (radiobuttons.q1_rb.response=="Biology") surveypage.q1_followup6]
/ branch = [if (radiobuttons.q1_rb.response=="Sociology") surveypage.q1_followup7]
/ branch = [if (radiobuttons.q1_rb.response=="Nutrition") surveypage.q1_followup8]
/ showpagenumbers = false
/ showquestionnumbers = false

</surveypage>



<radiobuttons q1_rb>
/ options = ("Psychology", "History", "Folklore", "Physiology", "Chemistry", "Biology", "Sociology", "Nutrition")
/order = random
</radiobuttons>


<surveypage q1_followup1>


As for generating random pairs, you'll need to do something like this.

<list options>
/ items = ("option a", "option b", "option c", "option d", "option e","option f", "option g", "option h")
/ selectionrate = always
</list>

<values>
/ pair1a = ""
/ pair1b = ""
/ pair2a = ""
/ pair2b = ""
/ pair3a = ""
/ pair3b = ""
/ pair4a = ""
/ pair4b = ""
</values>

<expt>
/ onexptbegin = [
  values.pair1a = list.options.nextvalue;
  values.pair1b = list.options.nextvalue;
  values.pair2a = list.options.nextvalue;
  values.pair2b = list.options.nextvalue;
  values.pair3a = list.options.nextvalue;
  values.pair3b = list.options.nextvalue;
  values.pair4a = list.options.nextvalue;
  values.pair4b = list.options.nextvalue;
]
/ blocks = [1=examplesurvey]
</expt>

<survey examplesurvey>
/ showquestionnumbers = false
/ showpagenumbers = false
/ pages = [1=pair1page; 2=pair2page; 3= pair3page; 4=pair4page]
</survey>

<surveypage pair1page>
/ questions = [1=pair1]
</surveypage>

<radiobuttons pair1>
/ caption = "Pair 1"
/ options = ("<%values.pair1a%>", "<%values.pair1b%>")
</radiobuttons>

<surveypage pair2page>
/ questions = [1=pair2]
</surveypage>

<radiobuttons pair2>
/ caption = "Pair 2"
/ options = ("<%values.pair2a%>", "<%values.pair2b%>")
</radiobuttons>

<surveypage pair3page>
/ questions = [1=pair3]
</surveypage>

<radiobuttons pair3>
/ caption = "Pair 3"
/ options = ("<%values.pair3a%>", "<%values.pair3b%>")
</radiobuttons>

<surveypage pair4page>
/ questions = [1=pair4]
</surveypage>

<radiobuttons pair4>
/ caption = "Pair 4"
/ options = ("<%values.pair4a%>", "<%values.pair4b%>")
</radiobuttons>


I'm not clear on what exactly you want to do regarding "is there a way to block out a radiobutton option after it has been selected once."

This is a bit of guesswork, but if you want a previously chosen option to disappear / no longer be available, this is best handled using a standard trial element instead of some radiobuttons/surveypage combination. In a nutshell:

<list options>
/ items = ("option a", "option b", "option c", "option d", "option e","option f", "option g", "option h")
/ selectionrate = always
</list>

<values>
/ pair1a = ""
/ pair1b = ""
</values>

<list pair1responses>
</list>

<expt>
/ onexptbegin = [
    values.pair1a = list.options.nextvalue;
    values.pair1b = list.options.nextvalue;
]
/ blocks = [1=exampleblock]
</expt>

<block exampleblock>
/ trials = [1-2=pair1trial]
</block>

<trial pair1trial>
/ ontrialend = [
    list.pair1responses.appenditem(trial.pair1trial.response);
]
/ stimulusframes = [1=click, pair1a, pair1b]
/ inputdevice = mouse
/ validresponse = (pair1a, pair1b)
/ isvalidresponse = [
    list.pair1responses.indexof(trial.pair1trial.response) == -1;
]
/ branch = [
    if (trial.pair1trial.response == "pair1a") {
        text.pair1a.skip = true;
        return surveypage.pair1a_follow_up;
    } else if (trial.pair1trial.response == "pair1b") {
        text.pair1b.skip = true;
        return surveypage.pair1b_follow_up;
    };
]
</trial>

<text click>
/ items = ("Click on one of the below options:")
/ position = (50%, 10%)
</text>

<text pair1a>
/ items = ("<%values.pair1a%>")
/ position = (50%, 30%)
</text>

<text pair1b>
/ items = ("<%values.pair1b%>")
/ position = (50%, 40%)
</text>

<surveypage pair1a_follow_up>
/ caption = "Follow-up questions about <%values.pair1a%> go here"
/ showpagenumbers = false
/ showquestionnumbers = false
</surveypage>

<surveypage pair1b_follow_up>
/ caption = "Follow-up questions about <%values.pair1b%> go here"
/ showpagenumbers = false
/ showquestionnumbers = false
</surveypage>

Dave
Dave
Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)
Group: Administrators
Posts: 13K, Visits: 106K
emoe - 2/9/2022
Hi,

I'm new to coding and Inquisit and I'm trying to randomize what options are available for subjects to select using radiobuttons. I have 8 total options, but only want 2 options presented at a time, and for these 2 to always be presented together for that particular subject. I would like to have these pairs randomized so each subject gets a different set of pairs. 

Also, is there a way to block out a radiobutton option after it has been selected once? For example, if subjects are always directed back to the options screen where they can select from the 8 (or 2) different options, could I make it so people aren't able to select their past choices?

Here is what I have so far for anPost New Topicother condition (where subjects can select from all 8 topics at once).

Thank you!

<surveypage q1>
/ questions = [1=q1_rb]
/ branch = [if (radiobuttons.q1_rb.response=="Psychology") surveypage.q1_followup1]
/ branch = [if (radiobuttons.q1_rb.response=="History") surveypage.q1_followup2]
/ branch = [if (radiobuttons.q1_rb.response=="Folklore") surveypage.q1_followup3]
/ branch = [if (radiobuttons.q1_rb.response=="Physiology") surveypage.q1_followup4]
/ branch = [if (radiobuttons.q1_rb.response=="Chemistry") surveypage.q1_followup5]
/ branch = [if (radiobuttons.q1_rb.response=="Biology") surveypage.q1_followup6]
/ branch = [if (radiobuttons.q1_rb.response=="Sociology") surveypage.q1_followup7]
/ branch = [if (radiobuttons.q1_rb.response=="Nutrition") surveypage.q1_followup8]
/ showpagenumbers = false
/ showquestionnumbers = false

</surveypage>



<radiobuttons q1_rb>
/ options = ("Psychology", "History", "Folklore", "Physiology", "Chemistry", "Biology", "Sociology", "Nutrition")
/order = random
</radiobuttons>


<surveypage q1_followup1>


As for generating random pairs, you'll need to do something like this.

<list options>
/ items = ("option a", "option b", "option c", "option d", "option e","option f", "option g", "option h")
/ selectionrate = always
</list>

<values>
/ pair1a = ""
/ pair1b = ""
/ pair2a = ""
/ pair2b = ""
/ pair3a = ""
/ pair3b = ""
/ pair4a = ""
/ pair4b = ""
</values>

<expt>
/ onexptbegin = [
  values.pair1a = list.options.nextvalue;
  values.pair1b = list.options.nextvalue;
  values.pair2a = list.options.nextvalue;
  values.pair2b = list.options.nextvalue;
  values.pair3a = list.options.nextvalue;
  values.pair3b = list.options.nextvalue;
  values.pair4a = list.options.nextvalue;
  values.pair4b = list.options.nextvalue;
]
/ blocks = [1=examplesurvey]
</expt>

<survey examplesurvey>
/ showquestionnumbers = false
/ showpagenumbers = false
/ pages = [1=pair1page; 2=pair2page; 3= pair3page; 4=pair4page]
</survey>

<surveypage pair1page>
/ questions = [1=pair1]
</surveypage>

<radiobuttons pair1>
/ caption = "Pair 1"
/ options = ("<%values.pair1a%>", "<%values.pair1b%>")
</radiobuttons>

<surveypage pair2page>
/ questions = [1=pair2]
</surveypage>

<radiobuttons pair2>
/ caption = "Pair 2"
/ options = ("<%values.pair2a%>", "<%values.pair2b%>")
</radiobuttons>

<surveypage pair3page>
/ questions = [1=pair3]
</surveypage>

<radiobuttons pair3>
/ caption = "Pair 3"
/ options = ("<%values.pair3a%>", "<%values.pair3b%>")
</radiobuttons>

<surveypage pair4page>
/ questions = [1=pair4]
</surveypage>

<radiobuttons pair4>
/ caption = "Pair 4"
/ options = ("<%values.pair4a%>", "<%values.pair4b%>")
</radiobuttons>


I'm not clear on what exactly you want to do regarding "is there a way to block out a radiobutton option after it has been selected once."
emoe
emoe
Associate Member (82 reputation)Associate Member (82 reputation)Associate Member (82 reputation)Associate Member (82 reputation)Associate Member (82 reputation)Associate Member (82 reputation)Associate Member (82 reputation)Associate Member (82 reputation)Associate Member (82 reputation)
Group: Forum Members
Posts: 6, Visits: 23
Hi,

I'm new to coding and Inquisit and I'm trying to randomize what options are available for subjects to select using radiobuttons. I have 8 total options, but only want 2 options presented at a time, and for these 2 to always be presented together for that particular subject. I would like to have these pairs randomized so each subject gets a different set of pairs. 

Also, is there a way to block out a radiobutton option after it has been selected once? For example, if subjects are always directed back to the options screen where they can select from the 8 (or 2) different options, could I make it so people aren't able to select their past choices?

Here is what I have so far for anPost New Topicother condition (where subjects can select from all 8 topics at once).

Thank you!

<surveypage q1>
/ questions = [1=q1_rb]
/ branch = [if (radiobuttons.q1_rb.response=="Psychology") surveypage.q1_followup1]
/ branch = [if (radiobuttons.q1_rb.response=="History") surveypage.q1_followup2]
/ branch = [if (radiobuttons.q1_rb.response=="Folklore") surveypage.q1_followup3]
/ branch = [if (radiobuttons.q1_rb.response=="Physiology") surveypage.q1_followup4]
/ branch = [if (radiobuttons.q1_rb.response=="Chemistry") surveypage.q1_followup5]
/ branch = [if (radiobuttons.q1_rb.response=="Biology") surveypage.q1_followup6]
/ branch = [if (radiobuttons.q1_rb.response=="Sociology") surveypage.q1_followup7]
/ branch = [if (radiobuttons.q1_rb.response=="Nutrition") surveypage.q1_followup8]
/ showpagenumbers = false
/ showquestionnumbers = false

</surveypage>



<radiobuttons q1_rb>
/ options = ("Psychology", "History", "Folklore", "Physiology", "Chemistry", "Biology", "Sociology", "Nutrition")
/order = random
</radiobuttons>


<surveypage q1_followup1>
GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...




Reading This Topic

Explore
Messages
Mentions
Search