MCPcopy Create free account
hub / github.com/StackExchange/Survey / buildRandomization

Function buildRandomization

packages/survey/scripts/qualtrics.ts:211–230  ·  view source on GitHub ↗
(orderedKeys: string[], anchoredLast: string[])

Source from the content-addressed store, hash-verified

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.
211const RANDOMIZED_SLOT = '{~Randomized~}'
212function 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 ---------------------------------------------

Callers 1

toQuestionPayloadFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected