Enforcing Unique Rankings Across Numeric Datapoints
In some situations, the Ranking Question may not be an option within your survey and conventional numeric questions must be used instead. The example below is placed in a computational immediately before the number questions or matrix table you wish to validate. It records each value, checks that they are unique, and returns a value of 1 if the validation succeeds.
/* First, create an array to store the values we are checking. */ $USER_nums = array(); $USER_nums['1'] = $Q2a; $USER_nums['2'] = $Q2b; $USER_nums['3'] = $Q2c; $USER_nums['4'] = $Q2d; $USER_nums['5'] = $Q2e; /* Next, create a second array to hold only the unique values. */ $USER_result = array_unique($USER_nums); /* Store counts for both arrays in new variables. */ $USER_count1 = count($USER_nums); $USER_count2 = count($USER_result); /* Compare and return a value of 1 if they are equivalent. */ if ($USER_count1 == $USER_count2) return 1; else return false;
You can reference this computational in your number or matrix validation and not allow the respondent to continue until the 1 value has been computed.