- Posts: 12
- Thank you received: 0
Welcome to the LimeSurvey Community Forum
Ask the community, share ideas, and connect with other LimeSurvey users!
Answers random order - partial randomization & keeping distinct answers fixed
- dknvs
- Offline
- New Member
Less
More
9 years 9 months ago #109758
by dknvs
Replied by dknvs on topic Answers random order - partial randomization & keeping distinct answers fixed
YAY! IT WORKS! THANK YOU SO MUCH! :woohoo:
The topic has been locked.
- delarammahdaviii
- Offline
- Senior Member
Less
More
- Posts: 57
- Thank you received: 3
8 years 2 months ago #129711
by delarammahdaviii
Replied by delarammahdaviii on topic Answers random order - partial randomization & keeping distinct answers fixed
help me about ,Array questions to be randomized while always keeping 3 sub-question at the end
The topic has been locked.
- tpartner
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 10634
- Thank you received: 3698
8 years 2 months ago #129712
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 Answers random order - partial randomization & keeping distinct answers fixed
If, for example, the sub-question codes of the last 3 items are 97, 98 and 99, you can insert a script like this:
Sample survey attached:
Code:
<script type="text/javascript" charset="utf-8"> $(document).ready(function(){ // Move sub-question codes 97, 98, 99 to the end of the array $('#question{QID} table.subquestions-list tbody').append($('#question{QID} table.subquestions-list tr[id$="X{QID}97"]')) .append($('#question{QID} table.subquestions-list tr[id$="X{QID}98"]')) .append($('#question{QID} table.subquestions-list tr[id$="X{QID}99"]')); // Fix up array row background colours $('#question{QID} table.subquestions-list tbody > tr').each(function(i){ $(this).removeClass('array1 array2').addClass('array'+(2-(i%2))); }); }); </script>
Sample survey attached:
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Attachments:
The following user(s) said Thank You: delarammahdaviii
The topic has been locked.
- delarammahdaviii
- Offline
- Senior Member
Less
More
- Posts: 57
- Thank you received: 3
8 years 2 months ago #129713
by delarammahdaviii
Replied by delarammahdaviii on topic Answers random order - partial randomization & keeping distinct answers fixed
Thanks Tony
The topic has been locked.
- flannery
- Offline
- New Member
Less
More
- Posts: 1
- Thank you received: 0
8 years 1 month ago - 8 years 1 month ago #130977
by flannery
Replied by flannery on topic Answers random order - partial randomization & keeping distinct answers fixed
Attached is an updated version for 2.50+. This will keep subquestions 12 and 13 at the bottom of the list for a multiple choice question using the newspaper theme.
Code:
<script type="text/javascript" charset="utf-8"> $(document).ready(function(){ // Move sub-question codes 12, 13 to the end of the array $('#question{QID} .subquestions-list ').append($('#question{QID} .subquestions-list div[id$="X{QID}12"]').parent() ).append($('#question{QID} .subquestions-list div[id$="X{QID}13"]').parent() ); }); </script>
Last edit: 8 years 1 month ago by flannery.
The topic has been locked.
- rasheed
- Offline
- Junior Member
Less
More
- Posts: 20
- Thank you received: 0
8 years 1 month ago #131395
by rasheed
Replied by rasheed on topic Answers random order - partial randomization & keeping distinct answers fixed
I tested this with List (radio) question and it didn't work. Not sure if the script is compatible with 2.05 am using.
Thank you
Thank you
The topic has been locked.
- tpartner
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 10634
- Thank you received: 3698
8 years 1 month ago #131399
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 Answers random order - partial randomization & keeping distinct answers fixed
Tested what? There are several scripts in this thread. What are you trying to do and what script have you used?
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The topic has been locked.
- rasheed
- Offline
- Junior Member
Less
More
- Posts: 20
- Thank you received: 0
8 years 1 month ago #131401
by rasheed
Replied by rasheed on topic Answers random order - partial randomization & keeping distinct answers fixed
The topic has been locked.
- tpartner
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 10634
- Thank you received: 3698
8 years 1 month ago #131405
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 Answers random order - partial randomization & keeping distinct answers fixed
I find that the survey supplied in the workaround works in 2.05. Have you tried with the default template? Do you have any JavaScript errors?
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The topic has been locked.
- rasheed
- Offline
- Junior Member
Less
More
- Posts: 20
- Thank you received: 0
8 years 1 month ago #131407
by rasheed
Replied by rasheed on topic Answers random order - partial randomization & keeping distinct answers fixed
I think i found the reason. It doesn't actually work when answers are displayed in columns...
The topic has been locked.
- rasheed
- Offline
- Junior Member
Less
More
- Posts: 20
- Thank you received: 0
8 years 1 month ago #131453
by rasheed
Replied by rasheed on topic Answers random order - partial randomization & keeping distinct answers fixed
Is there any solution to make work with columns please ?
Thank you !
Thank you !
The topic has been locked.
- kapelas
- Offline
- New Member
Less
More
- Posts: 1
- Thank you received: 1
8 years 1 week ago #133153
by kapelas
Replied by kapelas on topic Answers random order - partial randomization & keeping distinct answers fixed
Regarding rasheed 's link in limesurvey, I would like to submit a small conversion to the script for partially randomize question in Array AND having the Repeat headers activated.
So, regarding the exact link
manual.limesurvey.org/Workarounds:_Manip...rs_-_Array_questions
If you add the <tag>:last</tag>, to point to the last descendant of the tbody, you add the question ONLY on the last tbody section of the repeated sections, otherwise the fixed sub-questions is added on every tbody section.
<script type="text/javascript" charset="utf-8">
$(document).ready(function() {
...
// Move the "fixed" row to the end
$('table.subquestions-list tbody:last', thisQuestion).append($('tr[id$="X'+q1ID+fixedCode+'"]'));
...
</script>
So, regarding the exact link
manual.limesurvey.org/Workarounds:_Manip...rs_-_Array_questions
If you add the <tag>:last</tag>, to point to the last descendant of the tbody, you add the question ONLY on the last tbody section of the repeated sections, otherwise the fixed sub-questions is added on every tbody section.
<script type="text/javascript" charset="utf-8">
$(document).ready(function() {
...
// Move the "fixed" row to the end
$('table.subquestions-list tbody:last', thisQuestion).append($('tr[id$="X'+q1ID+fixedCode+'"]'));
...
</script>
The following user(s) said Thank You: tpartner
The topic has been locked.