Use scripting to get, set, and unset values for Rank Order questions.
Rank Order items are zero-based. Therefore, a question with 5 items (i1,
i2, i3, i4, i5) has an authored index of
0,
1,
2,
3, and
4.
| Function or property | Description |
|---|---|
datapoint.set([1,3,0]);
|
Sets and ranks Rank Order items (zero-based). The authored indexes must be within range and unique. |
datapoint.set([])
|
Unsets the data point.
Set(undefined/null) will throw an exception.
|
datapoint.get() => [1, 3, 0];
|
Gets the ranked items.
[] is the default value that is returned if no
items are ranked.
|
dataPoint.unset();
|
Removes the ranking from all ranked items and sets the question to not answered. |
Example
A Rank Order question has 5 items. The zero-based authored indexes range from 0 to 4.
| Rank Order question |
|---|
|
i1 - 0 i2 - 1 i3 - 2 i4 - 3 i5 - 4 |
Consider the following function example:
datapoint.set([1,3,0]);
This function will return:
Ranked
- i2
- i4
- i1
Unranked
- i3
- i5