Prevent Duplicate Data in Ranking Items for Survey


Author
Message
bjohns47@masonlive.gmu.edu...
bjohns47@masonlive.gmu.edu
Associate Member (132 reputation)Associate Member (132 reputation)Associate Member (132 reputation)Associate Member (132 reputation)Associate Member (132 reputation)Associate Member (132 reputation)Associate Member (132 reputation)Associate Member (132 reputation)Associate Member (132 reputation)
Group: Forum Members
Posts: 11, Visits: 85
I have just started using Inquisit 6 and have no experience with the prior versions or with C scripting, I am developing a survey that requires respondents to rank 10 items, 1 through 10.using a dropdown list. I have ensured that all items are ranked before proceeding by using /required = true for each dropdown; however, I have not been able to determine how to ensure that each item has a separate and different ranking to the other items, i.e. no duplicate rankings. Is this possible in Inquisit 6, and if so, how would I script this requirement? Each ranking, 1 through 10, must be used before proceeding and no items may have the same ranking.

Thanks for any helpful solutions.
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: 12K, Visits: 98K
I have just started using Inquisit 6 and have no experience with the prior versions or with C scripting, I am developing a survey that requires respondents to rank 10 items, 1 through 10.using a dropdown list. I have ensured that all items are ranked before proceeding by using /required = true for each dropdown; however, I have not been able to determine how to ensure that each item has a separate and different ranking to the other items, i.e. no duplicate rankings. Is this possible in Inquisit 6, and if so, how would I script this requirement? Each ranking, 1 through 10, must be used before proceeding and no items may have the same ranking.

Thanks for any helpful solutions.

See e.g. https://www.millisecond.com/forums/FindPost7524.aspx
bjohns47@masonlive.gmu.edu...
bjohns47@masonlive.gmu.edu
Associate Member (132 reputation)Associate Member (132 reputation)Associate Member (132 reputation)Associate Member (132 reputation)Associate Member (132 reputation)Associate Member (132 reputation)Associate Member (132 reputation)Associate Member (132 reputation)Associate Member (132 reputation)
Group: Forum Members
Posts: 11, Visits: 85
Dave,

That was very helpful and prevents the survey from continuing if a ranking is duplicated. When a duplicate occurs all the dropdown rankings are changed back to blanks. Is there script I could modify that would just flag the duplicate dropdown rankings, something similar to what occurs with the / required field where the first dropdown that has no ranking is flagged by changing the font color of the dropdown to red without restarting the survey?

Again, thank you very much for your helpful and quick reply.
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: 12K, Visits: 98K
Dave,

That was very helpful and prevents the survey from continuing if a ranking is duplicated. When a duplicate occurs all the dropdown rankings are changed back to blanks. Is there script I could modify that would just flag the duplicate dropdown rankings, something similar to what occurs with the / required field where the first dropdown that has no ranking is flagged by changing the font color of the dropdown to red without restarting the survey?

Again, thank you very much for your helpful and quick reply.

Figuring out which exact rank numbers were duplicated or triplicated, etc. would be a huge pain (you'd have to compare every dropdown's response to every other dropdown's response), but you can keep the previous choices around and print out a more general error message like so:

<values>
/ rankstring = ""
/ validranking = false
/ d01_prev = 0
/ d02_prev = 0
/ d03_prev = 0
/ d04_prev = 0
/ errormessage = ""
</values>

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

<surveypage mypage>
/ caption = "Assign rank numbers below."
/ subcaption = "<font color=~"#FF0000~"><%values.errormessage%></font>"
/ questions = [1=d01; 2=d02; 3=d03; 4=d04]
/ ontrialbegin = [values.rankstring=""]
/ ontrialend = [values.rankstring=concat(values.rankstring,dropdown.d01.selectedcaption)]
/ ontrialend = [values.rankstring=concat(values.rankstring,dropdown.d02.selectedcaption)]
/ ontrialend = [values.rankstring=concat(values.rankstring,dropdown.d03.selectedcaption)]
/ ontrialend = [values.rankstring=concat(values.rankstring,dropdown.d04.selectedcaption)]
/ ontrialend = [
    values.d01_prev = dropdown.d01.response;
    values.d02_prev = dropdown.d02.response;
    values.d03_prev = dropdown.d03.response;
    values.d04_prev = dropdown.d04.response;
]
/ ontrialend = [if (contains(values.rankstring,"1")==true && contains(values.rankstring,"2")==true && contains(values.rankstring,"3")==true && contains(values.rankstring,"4")==true) {
        values.validranking = true;
    } else {
        values.validranking = false;
        values.errormessage = "Not all ranks have been uniquely assigned. Please revise your responses."
    };
]
/ branch = [if ( values.validranking == false) surveypage.mypage]
/ showpagenumbers = false
/ showquestionnumbers = false
</surveypage>

<dropdown d01>
/ options = ("1", "2", "3", "4")
/ defaultresponse = values.d01_prev
</dropdown>

<dropdown d02>
/ options = ("1", "2", "3", "4")
/ defaultresponse = values.d02_prev
</dropdown>

<dropdown d03>
/ options = ("1", "2", "3", "4")
/ defaultresponse = values.d03_prev
</dropdown>

<dropdown d04>
/ options = ("1", "2", "3", "4")
/ defaultresponse = values.d04_prev
</dropdown>




bjohns47@masonlive.gmu.edu...
bjohns47@masonlive.gmu.edu
Associate Member (132 reputation)Associate Member (132 reputation)Associate Member (132 reputation)Associate Member (132 reputation)Associate Member (132 reputation)Associate Member (132 reputation)Associate Member (132 reputation)Associate Member (132 reputation)Associate Member (132 reputation)
Group: Forum Members
Posts: 11, Visits: 85
Dave,

Thank you.

Absolutely wonderful and works great. Just incase someone else may use something like this, there was a small error in the subcaption at the end when /font was used. The following seems to work:

/subcaption = "<font color=~"#FF0000~"><%values.errormessage%></font color>"

How would I include an error message when a dropdown has not been selected? At this time the system automatically changes the text to red for the first question without a ranking , but no message is displayed.

Thanks again for all your help.

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: 12K, Visits: 98K
Dave,

Thank you.

Absolutely wonderful and works great. Just incase someone else may use something like this, there was a small error in the subcaption at the end when /font was used. The following seems to work:

/subcaption = "<font color=~"#FF0000~"><%values.errormessage%></font color>"

How would I include an error message when a dropdown has not been selected? At this time the system automatically changes the text to red for the first question without a ranking , but no message is displayed.

Thanks again for all your help.

> How would I include an error message when a dropdown has not been selected?

In pretty much the same way.

<values>
/ rankstring = ""
/ validranking = false
/ d01_prev = 0
/ d02_prev = 0
/ d03_prev = 0
/ d04_prev = 0
/ errormessage = ""
</values>

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

<surveypage mypage>
/ caption = "Assign rank numbers below."
/ subcaption = "<font color=~"#FF0000~"><%values.errormessage%></font>"
/ questions = [1=d01; 2=d02; 3=d03; 4=d04]
/ ontrialbegin = [values.rankstring="";]
/ ontrialend = [values.rankstring=concat(values.rankstring,dropdown.d01.selectedcaption)]
/ ontrialend = [values.rankstring=concat(values.rankstring,dropdown.d02.selectedcaption)]
/ ontrialend = [values.rankstring=concat(values.rankstring,dropdown.d03.selectedcaption)]
/ ontrialend = [values.rankstring=concat(values.rankstring,dropdown.d04.selectedcaption)]
/ ontrialend = [
    values.d01_prev = dropdown.d01.response;
    values.d02_prev = dropdown.d02.response;
    values.d03_prev = dropdown.d03.response;
    values.d04_prev = dropdown.d04.response;
]
/ ontrialend = [if (contains(values.rankstring,"1")==true && contains(values.rankstring,"2")==true && contains(values.rankstring,"3")==true && contains(values.rankstring,"4")==true) {
        values.validranking = true;
    } else {
        values.validranking = false;
        values.errormessage = "Not all ranks have been uniquely assigned. Please revise your responses.";
        if(dropdown.d01.response == "" || dropdown.d02.response == "" || dropdown.d03.response == "" || dropdown.d04.response == "") {
            values.errormessage = concat(values.errormessage, "<br>Please answer all questions.");
        }
    };
]
/ branch = [if ( values.validranking == false) surveypage.mypage]
/ showpagenumbers = false
/ showquestionnumbers = false
</surveypage>

<dropdown d01>
/ options = ("1", "2", "3", "4")
/ defaultresponse = values.d01_prev
/ required = false
</dropdown>

<dropdown d02>
/ options = ("1", "2", "3", "4")
/ defaultresponse = values.d02_prev
/ required = false
</dropdown>

<dropdown d03>
/ options = ("1", "2", "3", "4")
/ defaultresponse = values.d03_prev
/ required = false
</dropdown>

<dropdown d04>
/ options = ("1", "2", "3", "4")
/ defaultresponse = values.d04_prev
/ required = false
</dropdown>


bjohns47@masonlive.gmu.edu...
bjohns47@masonlive.gmu.edu
Associate Member (132 reputation)Associate Member (132 reputation)Associate Member (132 reputation)Associate Member (132 reputation)Associate Member (132 reputation)Associate Member (132 reputation)Associate Member (132 reputation)Associate Member (132 reputation)Associate Member (132 reputation)
Group: Forum Members
Posts: 11, Visits: 85
Thank you again. I would not have thought to set the dropdown required to false. All works great.
GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...




Reading This Topic

Explore
Messages
Mentions
Search