- Posts: 2
- Thank you received: 1
Welcome to the LimeSurvey Community Forum
Ask the community, share ideas, and connect with other LimeSurvey users!
Random order is the same for all questions
- echevalier
-
Topic Author
- Offline
- New Member
-
Less
More
2 months 1 week ago - 2 months 1 week ago #241587
by echevalier
Random order is the same for all questions was created by echevalier
Please help us help you and fill where relevant:
Your LimeSurvey version: Version 5.6.8+230227
Own server
Survey theme/template: Inherit [fruity]
==================
Hello,
I am currently creating a questionnaire containing one group with 18 array questions, with each question containing 6 (identical) subquestions. The subquestions should be presented in a random order for each question. The survey is displayed question by question to the participant. I therefore set the "Random order" Display option to "Yes". When I am previewing the question group, each question gets indeed an individual random subquestion order. This is not the case when activating the survey: in this case, the subquestions are randomly shuffled once, but this order is used for every question in the group. I tested the survey on Chrome and Firefox, the issue appeared on both.
The closest topic I found is this one : forums.limesurvey.org/forum/can-i-do-thi...s-in-array-by-column I did not try this solution due to the old age of the topic (5 years) - it seems like random order was not implemented on LimeSurvey on that version yet.
Is there a way to make sure the subquestions get reshuffled for each question? Is there another option I am missing?
Thank you very much, any help is appreciated!
Workaround
The JS code snippet from the old thread mentioned above fixes the problem. You'll need to copy the code below in the question text (using the "Source" editor).
Link: forums.limesurvey.org/forum/can-i-do-thi...ray-by-column#158346
Code:
Credit to tpartner
Your LimeSurvey version: Version 5.6.8+230227
Own server
Survey theme/template: Inherit [fruity]
==================
Hello,
I am currently creating a questionnaire containing one group with 18 array questions, with each question containing 6 (identical) subquestions. The subquestions should be presented in a random order for each question. The survey is displayed question by question to the participant. I therefore set the "Random order" Display option to "Yes". When I am previewing the question group, each question gets indeed an individual random subquestion order. This is not the case when activating the survey: in this case, the subquestions are randomly shuffled once, but this order is used for every question in the group. I tested the survey on Chrome and Firefox, the issue appeared on both.
The closest topic I found is this one : forums.limesurvey.org/forum/can-i-do-thi...s-in-array-by-column I did not try this solution due to the old age of the topic (5 years) - it seems like random order was not implemented on LimeSurvey on that version yet.
Is there a way to make sure the subquestions get reshuffled for each question? Is there another option I am missing?
Thank you very much, any help is appreciated!
Workaround
The JS code snippet from the old thread mentioned above fixes the problem. You'll need to copy the code below in the question text (using the "Source" editor).
Link: forums.limesurvey.org/forum/can-i-do-thi...ray-by-column#158346
Code:
Code:
<script type="text/javascript" charset="utf-8"> function shuffleArray(array) { for (var i = array.length - 1; i > 0; i--) { var j = Math.floor(Math.random() * (i + 1)); var temp = array[i]; array[i] = array[j]; array[j] = temp; } return array; } $(document).on('ready pjax:complete',function() { var thisQuestion = $('#question{QID}'); var elements = $('tr.answers-list', thisQuestion).detach().toArray(); shuffleArray(elements); $('tr.answers-list', thisQuestion).remove(); $. each (elements, function(i, el) { $('table.subquestion-list tbody:eq(0)', thisQuestion).append(el); }); }); </script>
Credit to tpartner
Last edit: 2 months 1 week ago by echevalier. Reason: format
Please Log in to join the conversation.
2 months 1 week ago #241588
by Joffm
Volunteers are not paid.
Not because they are worthless, but because they are priceless
Replied by Joffm on topic Random order is the same for all questions
There was already a thread about this and a bug report
[url] bugs.limesurvey.org/view.php?id=18440 [/url]
Joffm
[url] bugs.limesurvey.org/view.php?id=18440 [/url]
Joffm
Volunteers are not paid.
Not because they are worthless, but because they are priceless
The following user(s) said Thank You: DenisChenu, echevalier
Please Log in to join the conversation.
- DenisChenu
-
- Offline
- LimeSurvey Community Team
-
Less
More
- Posts: 13144
- Thank you received: 2422
2 months 1 week ago #241589
by DenisChenu
Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member, professional service on demand , plugin development .
I don't answer to private message.
Replied by DenisChenu on topic Random order is the same for all questions
Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member, professional service on demand , plugin development .
I don't answer to private message.
Please Log in to join the conversation.
- echevalier
-
Topic Author
- Offline
- New Member
-
Less
More
- Posts: 2
- Thank you received: 1
2 months 1 week ago #241591
by echevalier
Replied by echevalier on topic Random order is the same for all questions
Hi Denis,
I don't see the "Does this bug affect you?" link. I tried to login on the bug report site, but my account credentials are not working and when I click on "Sign up" it redirects me to my LimeSurvey account page.
Log in anonymously doesn't let me use the "Does this bug affect you?" link either.
How should I proceed? Thank you!
I don't see the "Does this bug affect you?" link. I tried to login on the bug report site, but my account credentials are not working and when I click on "Sign up" it redirects me to my LimeSurvey account page.
Log in anonymously doesn't let me use the "Does this bug affect you?" link either.
How should I proceed? Thank you!
The following user(s) said Thank You: DenisChenu
Please Log in to join the conversation.
- DenisChenu
-
- Offline
- LimeSurvey Community Team
-
Less
More
- Posts: 13144
- Thank you received: 2422
2 months 1 week ago #241594
by DenisChenu
Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member, professional service on demand , plugin development .
I don't answer to private message.
Replied by DenisChenu on topic Random order is the same for all questions
Arg right :
bugs.limesurvey.org/view.php?id=18675
Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member, professional service on demand , plugin development .
I don't answer to private message.
The following user(s) said Thank You: echevalier
Please Log in to join the conversation.
2 months 1 week ago #241598
by tpartner
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Replied by tpartner on topic Random order is the same for all questions
It looks like the code got messed up by the forum editor.Workaround...
Code:
<script type="text/javascript" charset="utf-8"> function shuffleArray(array) { for (var i = array.length - 1; i > 0; i--) { var j = Math.floor(Math.random() * (i + 1)); var temp = array[i]; array[i] = array[j]; array[j] = temp; } return array; } $(document).on('ready pjax:complete',function() { var thisQuestion = $('#question{QID}'); var elements = $('tr.answers-list', thisQuestion).detach().toArray(); shuffleArray(elements); $('tr.answers-list', thisQuestion).remove(); $. each (elements, function(i, el) { $('table.subquestion-list tbody:eq(0)', thisQuestion).append(el); }); }); </script>
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The following user(s) said Thank You: DenisChenu, echevalier
Please Log in to join the conversation.