Open dsernst opened 3 months ago
Copied from https://github.com/npfoss/nap-app/issues/6#issuecomment-2227161202
Implementation notes for self:
"randomize_order": true
to ballot schema, per question.
Doesn't need to be programmed into Ballot-Design Wizard for now
randomize_order: true
, then on page load on voter's device, generate permutation array (shuffle) for rendering the options. Keep write-ins last.Quick and dirty, but should work.
Instead of generating the permutation array from new random bits, generate it deterministically from a seed of hash(verification_number + question.id)
.
verification_number
is random among 10^12 possibilities.
question.id
isn't strictly necessary, but it means the permutations will be uncorrelated across multiple questions too (which seems a bit better), since question.id
s are forced unique.verification_number
is kept in localStorage (solving Slight Con 1 above).permutationFromSeed()
function. Have similar already.v1 done and now deployed. You can see it in action on this new ballot schema: siv.org/election/1721041614121/vote?auth=link.
Because the ballot design first gets loaded from localStorage if available, if you manually refresh the page it reshuffles with a small FOUC. This isn't visible on initial load (how most people will experience the page), only if people refresh.
The v2 design will fix this since it will use a deterministic shuffle based on verification #, but wanted to get something up and out the door.
See https://github.com/npfoss/nap-app/issues/6
————