Watts-Lab / surveys

Library of surveys for deliberation experiments
MIT License
3 stars 4 forks source link

🐞 Surveys re-randomizing order while being displayed? #151

Closed JamesPHoughton closed 3 months ago

JamesPHoughton commented 1 year ago

In at least one case, we observed a survey that had a random order shuffle its order while the participant was using it. This shouldn't happen!

JamesPHoughton commented 3 months ago

This was happening for surveys that were used during game stages of deliberation-empirica (not intro or exit stages) and would happen because the stage timer tick would cause the whole element tree to rerender. Making it so that stageTimer is not part of the default render tree means that now surveys won't be rendered every tick, and so the order persists.

However, if the page refreshes, or react re-renders the survey for some reason, the order will get re-randomized.

In the long term, it would make sense to persist the order in a useState, at least, so it doesn't rerandomize on rerender.