- Posts: 75
- Thank you received: 0
Welcome to the LimeSurvey Community Forum
Ask the community, share ideas, and connect with other LimeSurvey users!
Multiple choice random order
- Andrea01
- Topic Author
- Offline
- Senior Member
Less
More
10 years 5 months ago #100738
by Andrea01
Multiple choice random order was created by Andrea01
Hi,
I have multiple choice question and Show the items in random order.
Is is possible not to randomize the last item in the question.
If I use "Exclusive Option" the item will not be randomized, however, if clicked, all other items get deactivated, and this is not what I Need.
Thanks in advance
Andrea
I have multiple choice question and Show the items in random order.
Is is possible not to randomize the last item in the question.
If I use "Exclusive Option" the item will not be randomized, however, if clicked, all other items get deactivated, and this is not what I Need.
Thanks in advance
Andrea
The topic has been locked.
- tpartner
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 10611
- Thank you received: 3690
10 years 5 months ago #100741
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 Multiple choice random order
Hi Andrea, see this workaround -
manual.limesurvey.org/Workarounds:_Manip...28radio.29_questions
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The topic has been locked.
- Andrea01
- Topic Author
- Offline
- Senior Member
Less
More
- Posts: 75
- Thank you received: 0
10 years 5 months ago #100763
by Andrea01
Replied by Andrea01 on topic Multiple choice random order
thank you, but not working with Limesurvey 2.0
The topic has been locked.
- tpartner
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 10611
- Thank you received: 3690
10 years 5 months ago - 10 years 5 months ago #100765
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 Multiple choice random order
I just tested it in the default template of LimeSurvey 2.0 and it works fine. Perhaps you had incorrect IDs or where using another template.
Regardless, here is an updated version of the script for LS 2.0. Create the question as described in the workaround and add this script to the question source:
Regardless, here is an updated version of the script for LS 2.0. Create the question as described in the workaround and add this script to the question source:
Code:
<script type="text/javascript" charset="utf-8"> $(document).ready(function() { var qID = {QID}; var thisQuestion = $('#question'+qID); // Find the number of answers var ansCount = $('.answer-item', thisQuestion).length; // Place the last answer created at the end of the list $('.questions-list', thisQuestion).append($('.answer-item[id$="X'+qID+ansCount+'"]')); }); </script>
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Last edit: 10 years 5 months ago by tpartner.
The topic has been locked.
- Andrea01
- Topic Author
- Offline
- Senior Member
Less
More
- Posts: 75
- Thank you received: 0
10 years 4 months ago #100918
by Andrea01
Replied by Andrea01 on topic Multiple choice random order
Hi tpartner,
thank you, works fine for multiple options questions. For list radio questions I changed
$('.questions-list', thisQuestion).append($('.answer-item[id$="X'+qID+ansCount+'"]'));
to
$('.answers-list', thisQuestion).append($('.answer-item[id$="X'+qID+ansCount+'"]'));
I also managed to make my template work with the code from the Workaround by changing
$( 'div#question' + qID + ' td.answer li' ).each(function(i) {
ansCount = (i + 1);
to
$( 'div#question' + qID + ' div.answers li' ).each(function(i) {
ansCount = (i + 1);
and
$( 'input#answer' + sID + 'X' + gID + 'X' + qID + ansCount + '' ).parent().appendTo($( '#question' + qID + ' td.answer ul' ));
to
$( 'input#answer' + sID + 'X' + gID + 'X' + qID + ansCount + '' ).parent().appendTo($( '#question' + qID + ' div.answer ul' ));
Best regards
Andrea
thank you, works fine for multiple options questions. For list radio questions I changed
$('.questions-list', thisQuestion).append($('.answer-item[id$="X'+qID+ansCount+'"]'));
to
$('.answers-list', thisQuestion).append($('.answer-item[id$="X'+qID+ansCount+'"]'));
I also managed to make my template work with the code from the Workaround by changing
$( 'div#question' + qID + ' td.answer li' ).each(function(i) {
ansCount = (i + 1);
to
$( 'div#question' + qID + ' div.answers li' ).each(function(i) {
ansCount = (i + 1);
and
$( 'input#answer' + sID + 'X' + gID + 'X' + qID + ansCount + '' ).parent().appendTo($( '#question' + qID + ' td.answer ul' ));
to
$( 'input#answer' + sID + 'X' + gID + 'X' + qID + ansCount + '' ).parent().appendTo($( '#question' + qID + ' div.answer ul' ));
Best regards
Andrea
The topic has been locked.