View Issue Details

This bug affects 1 person(s).
 2
IDProjectCategoryView StatusLast Update
20200Bug reports_ Unknownpublic2025-08-02 18:36
ReporterAndrea01 Assigned To 
PrioritynoneSeveritypartial_block 
Status newResolutionopen 
Product Version6.4.x 
Summary20200: In a multiple-choice question with random order and an exclusive option, the exclusive option is not placed at the end.
Description

It only works with Joffm's JavaScript code
<script type="text/javascript" charset="utf-8">

/* $(document).on('ready pjax:scriptcomplete',function(){

    // The number of answers to be fixed at the end of the list
    var fixedAnswers = 1;

    // Set this to "true" if you want "Other" to be fixed in the last position
    var otherFixed = false;

    // Identify this question
    var qID = {QID}; 

    // Find the number of answers
    var ansCount = $('#question'+qID+' .answer-item').length;
    if($('#question'+qID+' input[type="text"]').length > 0) {
        ansCount = ansCount -1
    }
    console.log(ansCount);

    // Place the last n answers created at the end of the list
    var fixedIndex = fixedAnswers - 1;
    for (var i=0; i<fixedAnswers; i++) {
        var answer = $('input[id^="answer"][id$="X'+qID+(ansCount-fixedIndex)+'"]');
        var answerItem = $(answer).closest('.answer-item');
        var answersList = $(answer).closest('ul');
        $(answersList).append(answerItem);
        fixedIndex--;
    }       

    // Handle "Other"
    if(otherFixed == true && $('#question'+qID+' input[type="text"]').length > 0) {
        var otherAnswer = $('#question'+qID+' input[type="text"]');
        var otherAnswerItem = $(otherAnswer ).closest('.answer-item');
        var otherAnswersList = $(otherAnswer ).closest('ul');
        $(otherAnswersList).append(otherAnswerItem);
    }
});*/

</script>

Steps To Reproduce

Joffm did reproduce the bug

TagsNo tags attached.
Bug heat2
Complete LimeSurvey version number (& build)LimeSurvey Community Edition Version 6.15.5+250724
I will donate to the project if issue is resolvedNo
Browserfirefox, edge
Database type & versionmysqul ??
Server OS (if known)
Webserver software & version (if known)
PHP VersionPHP Version 7.4.33

Users monitoring this issue

There are no users monitoring this issue.

Activities

Joffm

Joffm

2025-08-02 18:36

reporter   ~83171

To clarify.
The issue is not that the exclusive option is not placed at the end.
As it is a randomized question the exclusive option can/should appear on each position.
The issue is that this option always appears at the same position.
With six subquestions I got this outcome
If the code of the exclusive option is x it is displayed always at position y
x:1, y:5
x:2, y:1
X:3, y:2
x:4, y:3
x:5, y:4
x:6, y:5
All other subquestions are displayed in randomized order.

I expected to get the exclusive option randomized as well.

And the script (btw: it is not mine; as far as I know from tpartner) is always necessary to fix the last subquestion always at the last position
"Parially randomed answers", workaround section of the manual.

Issue History

Date Modified Username Field Change
2025-08-01 17:00 Andrea01 New Issue
2025-08-02 18:36 Joffm Note Added: 83171
2025-08-02 18:36 Joffm Bug heat 0 => 2