Restricting responses to dropdown questions


Author
Message
mb194503
mb194503
Respected Member (356 reputation)Respected Member (356 reputation)Respected Member (356 reputation)Respected Member (356 reputation)Respected Member (356 reputation)Respected Member (356 reputation)Respected Member (356 reputation)Respected Member (356 reputation)Respected Member (356 reputation)
Group: Forum Members
Posts: 7, Visits: 21
Dave - Monday, April 15, 2019
mb194503 - Monday, April 15, 2019
I am asking participants to rank order a set of four items through a series of dropdown boxes. Is there a way to create an error if someone ranks the same option twice? For example: 

Rank 1: Item 1
Rank 2: Item 2
Rank 3: Item 1 
Rank 4: Item 3

When the participant clicks to continue, this should throw an error message that the same Item was selected twice. 

Thanks-MB

Yes, this is perfectly possible.

<block myblock>
/ trials = [1=rankpage]
</block>

<values>
/ rankstring = ""
</values>


<surveypage rankpage>
/ ontrialbegin = [values.rankstring = "";]
/ questions = [1=r1; 2=r2; 3=r3; 4=r4]
/ ontrialend = [values.rankstring = concat(values.rankstring, dropdown.r1.response);
values.rankstring = concat(values.rankstring, dropdown.r2.response);
values.rankstring = concat(values.rankstring, dropdown.r3.response);
values.rankstring = concat(values.rankstring, dropdown.r4.response);
]
/ branch = [if (!contains(values.rankstring, "1") || !contains(values.rankstring, "2") || !contains(values.rankstring, "3") || !contains(values.rankstring, "4")) surveypage.errorpage]
</surveypage>

<surveypage errorpage>
/ caption = "You ranked at least one item multiple times. Please try again."
/ branch = [surveypage.rankpage]
</surveypage>


<dropdown r1>
/ caption = "Rank 1"
/ options = ("Item 1", "Item 2", "Item 3", "Item 4")
/ optionvalues = ("1", "2", "3", "4")
</dropdown>

<dropdown r2>
/ caption = "Rank 2"
/ options = ("Item 1", "Item 2", "Item 3", "Item 4")
/ optionvalues = ("1", "2", "3", "4")
</dropdown>

<dropdown r3>
/ caption = "Rank 3"
/ options = ("Item 1", "Item 2", "Item 3", "Item 4")
/ optionvalues = ("1", "2", "3", "4")
</dropdown>

<dropdown r4>
/ caption = "Rank 4"
/ options = ("Item 1", "Item 2", "Item 3", "Item 4")
/ optionvalues = ("1", "2", "3", "4")
</dropdown>

Thank you!! That worked! -MB
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: 104K
mb194503 - Monday, April 15, 2019
I am asking participants to rank order a set of four items through a series of dropdown boxes. Is there a way to create an error if someone ranks the same option twice? For example: 

Rank 1: Item 1
Rank 2: Item 2
Rank 3: Item 1 
Rank 4: Item 3

When the participant clicks to continue, this should throw an error message that the same Item was selected twice. 

Thanks-MB

Yes, this is perfectly possible.

<block myblock>
/ trials = [1=rankpage]
</block>

<values>
/ rankstring = ""
</values>


<surveypage rankpage>
/ ontrialbegin = [values.rankstring = "";]
/ questions = [1=r1; 2=r2; 3=r3; 4=r4]
/ ontrialend = [values.rankstring = concat(values.rankstring, dropdown.r1.response);
values.rankstring = concat(values.rankstring, dropdown.r2.response);
values.rankstring = concat(values.rankstring, dropdown.r3.response);
values.rankstring = concat(values.rankstring, dropdown.r4.response);
]
/ branch = [if (!contains(values.rankstring, "1") || !contains(values.rankstring, "2") || !contains(values.rankstring, "3") || !contains(values.rankstring, "4")) surveypage.errorpage]
</surveypage>

<surveypage errorpage>
/ caption = "You ranked at least one item multiple times. Please try again."
/ branch = [surveypage.rankpage]
</surveypage>


<dropdown r1>
/ caption = "Rank 1"
/ options = ("Item 1", "Item 2", "Item 3", "Item 4")
/ optionvalues = ("1", "2", "3", "4")
</dropdown>

<dropdown r2>
/ caption = "Rank 2"
/ options = ("Item 1", "Item 2", "Item 3", "Item 4")
/ optionvalues = ("1", "2", "3", "4")
</dropdown>

<dropdown r3>
/ caption = "Rank 3"
/ options = ("Item 1", "Item 2", "Item 3", "Item 4")
/ optionvalues = ("1", "2", "3", "4")
</dropdown>

<dropdown r4>
/ caption = "Rank 4"
/ options = ("Item 1", "Item 2", "Item 3", "Item 4")
/ optionvalues = ("1", "2", "3", "4")
</dropdown>

mb194503
mb194503
Respected Member (356 reputation)Respected Member (356 reputation)Respected Member (356 reputation)Respected Member (356 reputation)Respected Member (356 reputation)Respected Member (356 reputation)Respected Member (356 reputation)Respected Member (356 reputation)Respected Member (356 reputation)
Group: Forum Members
Posts: 7, Visits: 21
I am asking participants to rank order a set of four items through a series of dropdown boxes. Is there a way to create an error if someone ranks the same option twice? For example: 

Rank 1: Item 1
Rank 2: Item 2
Rank 3: Item 1 
Rank 4: Item 3

When the participant clicks to continue, this should throw an error message that the same Item was selected twice. 

Thanks-MB
GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...




Reading This Topic

Explore
Messages
Mentions
Search