| 209 | // slot per choice in display order, where each randomized slot is the literal |
| 210 | // token "{~Randomized~}" and an anchored choice is named by its choice key. |
| 211 | const RANDOMIZED_SLOT = '{~Randomized~}' |
| 212 | function buildRandomization(orderedKeys: string[], anchoredLast: string[]): QualtricsRandomization { |
| 213 | if (anchoredLast.length === 0) { |
| 214 | return { Type: 'All', Advanced: null, TotalRandSubset: '' } |
| 215 | } |
| 216 | const randomized = orderedKeys.filter((k) => !anchoredLast.includes(k)) |
| 217 | return { |
| 218 | Type: 'Advanced', |
| 219 | Advanced: { |
| 220 | FixedOrder: orderedKeys.map((k) => (anchoredLast.includes(k) ? k : RANDOMIZED_SLOT)), |
| 221 | RandomizeAll: randomized, |
| 222 | RandomSubSet: [], |
| 223 | ScaleReversal: [], |
| 224 | Undisplayed: [], |
| 225 | TotalRandSubset: 0, |
| 226 | }, |
| 227 | ConsistentScaleReversal: false, |
| 228 | EvenPresentation: false, |
| 229 | TotalRandSubset: '', |
| 230 | } |
| 231 | } |
| 232 | |
| 233 | // --- choice/answer builders --------------------------------------------- |