Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature: Allow shuffling of answer options | Sort options #1271

Merged
merged 1 commit into from
Sep 20, 2022

Conversation

susnux
Copy link
Collaborator

@susnux susnux commented Jul 29, 2022


This introduces an question option to randomize the order of the answer options.
Shuffling the order of the answer choices reduces bias in responses. (#1067)

If no shuffling is enabled the options are sorted in the order they were
created, as currently they are shown as returned by the database which
is not necessarily sorted. (#1007)

@susnux susnux force-pushed the feat/shuffle_options branch 2 times, most recently from 1f4dd39 to 1727167 Compare July 29, 2022 16:48
@codecov
Copy link

codecov bot commented Jul 29, 2022

Codecov Report

Merging #1271 (641a003) into master (78a5301) will increase coverage by 0.01%.
The diff coverage is 38.46%.

Additional details and impacted files
@@             Coverage Diff              @@
##             master    #1271      +/-   ##
============================================
+ Coverage     36.83%   36.84%   +0.01%     
- Complexity      507      512       +5     
============================================
  Files            47       48       +1     
  Lines          1960     1973      +13     
============================================
+ Hits            722      727       +5     
- Misses         1238     1246       +8     

@susnux susnux added enhancement New feature or request 3. to review Waiting for reviews labels Jul 29, 2022
@susnux susnux requested a review from jotoeri July 30, 2022 09:38
CHANGELOG.md Outdated Show resolved Hide resolved
lib/Db/Question.php Outdated Show resolved Hide resolved
src/mixins/QuestionMixin.js Outdated Show resolved Hide resolved
@jotoeri jotoeri requested a review from Chartman123 July 31, 2022 08:21
@susnux susnux force-pushed the feat/shuffle_options branch 5 times, most recently from dd5d2ba to ba32e89 Compare August 31, 2022 20:20
@susnux susnux requested a review from jotoeri August 31, 2022 20:22
Copy link
Member

@jotoeri jotoeri left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be fine, i think 🤔

Copy link
Member

@jotoeri jotoeri left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Argh, sorry, i was too fast pushing the button.
Just getting this on console, when adding a new question:
grafik

@jotoeri jotoeri added this to the 3.0 milestone Sep 1, 2022
@susnux susnux force-pushed the feat/shuffle_options branch 2 times, most recently from 64cbafb to f68b582 Compare September 2, 2022 09:22
@susnux
Copy link
Collaborator Author

susnux commented Sep 2, 2022

Just getting this on console, when adding a new question

Oh yes that happens if there are no settings as the empty array would be serialized as an array instead of an object (assoc. array). This is now fixed.

@susnux susnux requested a review from jotoeri September 2, 2022 09:24
@jotoeri
Copy link
Member

jotoeri commented Sep 5, 2022

Top 👍
Just one more thing i found now:
When checking/unchecking the Shuffle-Checkbox, we should update the computed property of sortedOptions. Currently, this only takes effect after reloading the page (while editing the form).

@susnux
Copy link
Collaborator Author

susnux commented Sep 5, 2022

Hm while editing (at least in the editing view) options should not be shuffled (only in the submit view).
But I will test this as soon as I got some time for preparing a test env, as currently master is broken (due to nextcloud-eventbus 3.0.1 dependency of nextcloud-vue which is already fixed but 3.0.2 is not released)

@jotoeri
Copy link
Member

jotoeri commented Sep 5, 2022

Hm while editing (at least in the editing view) options should not be shuffled (only in the submit view).

When editing a single question, i'm totally with you. Then they should be ordered.
But on Form-Editing, when not editing a single question (i.e. Within Create.vue, but edit=false of Question.vue), the options are currently unsorted (if set). I think that is fine, as this situation should indicate how the final form looks like, but it should also be reactive, so when unchecking the shuffle, then the options are directly shown as sorted (and the other way round).

due to nextcloud-eventbus 3.0.1 dependency of nextcloud-vue which is already fixed but 3.0.2 is not released

Do you know npm link? You can relatively quickly just clone eventbus master, ci, build, link and then link @nextcloud/event-bus on forms. Then it works with current master, so you can use it already. 😉

@susnux
Copy link
Collaborator Author

susnux commented Sep 6, 2022

When checking/unchecking the Shuffle-Checkbox, we should update the computed property of sortedOptions. Currently, this only takes effect after reloading the page (while editing the form).

Fixed that.

One general thing I noticed: Currently every interaction is debounced, resulting in a slight UI latency. Would it not be smoother to just debounce the request to the server? (As the UI is currently also not checking the request for success, meaning there is no rollback if that request failed).

Copy link
Member

@jotoeri jotoeri left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • Old Questions are not loaded/shown (i.e. Questions with ExtraSettingsJson = NULL)
  • The way of sorting is quite biased, no? Can we get to a Fisher-Yates here? Should be of same Order, but much more effective.
  • Can you please test it on your own properly? Takes also quite much time for me, to do this...

src/mixins/QuestionMixin.js Show resolved Hide resolved
@jotoeri
Copy link
Member

jotoeri commented Sep 6, 2022

One general thing I noticed: Currently every interaction is debounced, resulting in a slight UI latency.

Hmm, i don't think the delay is much of a problem. It is anyways only visible on the two boolean switches and if we fix the actions to be inside of the Editing-Mode, then it even won't be visible that much. (#1329) I also have in mind, that chaning this would also increase the load on the browser due to permanently updating and triggering corresponding reactivities.

@susnux
Copy link
Collaborator Author

susnux commented Sep 6, 2022

@jotoeri Fixed your comments. Sorry for the inconvenience, I will try to test better.

Copy link
Member

@jotoeri jotoeri left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be fine now. 👍

@jotoeri
Copy link
Member

jotoeri commented Sep 11, 2022

@Chartman123 wanna double-check here? 😉

lib/Db/Question.php Outdated Show resolved Hide resolved
@susnux susnux force-pushed the feat/shuffle_options branch 5 times, most recently from 46c95f5 to ee62a5b Compare September 20, 2022 00:03
This introduces an question option to randomize the order of the answer options
by using the Fisher-Yates algorithm.
Shuffling the order of the answer choices reduces bias in responses.
Implements #1067

If no shuffling is enabled the options are sorted in the order they were
created, as currently they are shown as returned by the database which
is not necessarily sorted. Fixes #1007

Signed-off-by: Ferdinand Thiessen <[email protected]>
@Chartman123 Chartman123 added 4. to release Ready to be released and/or waiting for tests to finish and removed 3. to review Waiting for reviews labels Sep 20, 2022
@jotoeri jotoeri merged commit 6e1ae89 into master Sep 20, 2022
@jotoeri jotoeri deleted the feat/shuffle_options branch September 20, 2022 11:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
4. to release Ready to be released and/or waiting for tests to finish enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Ability to randomise order of multiple choice answers Order of choices is not stable
3 participants