Welcome to the LimeSurvey Community Forum

Ask the community, share ideas, and connect with other LimeSurvey users!

Randomise Array subquestions / one fixed at the bottom

  • PaulMRFGR
  • PaulMRFGR's Avatar Topic Author
  • Offline
  • Senior Member
  • Senior Member
More
3 years 6 months ago - 3 years 6 months ago #206626 by PaulMRFGR
Hi there,

I'd like to randomise the subquestions within an Array, but have one subquestion fixed so it appears at the bottom all of the time.

Been playing around with the source code all afternoon but can't really get it right - does anyone know what code to use here? I'm not too familiar with coding in general so admittedly that doesn't help - if someone could provide me with the right code and let me know how to change it so it's applicable to different array questions, that would be great.

I'm attaching the .lsg file here. The subquestion that needs to remain fixed at the bottom is 'o'.

Thank you.

File Attachment:

File Name: limesurvey...5549.lsq
File Size:12 KB
Last edit: 3 years 6 months ago by PaulMRFGR.
The topic has been locked.
  • holch
  • holch's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
3 years 6 months ago #206667 by holch
Sorry, won't be of help here. But usually helpers in the forum prefer a LSS file (with just the relevant questions) ofer LSQ or LSG files. Why? Because they require the helper to create a survey and hope that it is the same base language, because LSQ and LSG are language sensitive.

So ideally you copy your survey, delete all quetions that are not relevant and then export it to LSS.

Help us to help you. ;-)

I answer at the LimeSurvey forum in my spare time, I'm not a LimeSurvey GmbH employee.
No support via private message.

The following user(s) said Thank You: DenisChenu, tpartner
The topic has been locked.
  • PaulMRFGR
  • PaulMRFGR's Avatar Topic Author
  • Offline
  • Senior Member
  • Senior Member
More
3 years 6 months ago #206703 by PaulMRFGR
Hi there,

Thanks for the advice - I've now uploaded an .lss file to make it as easy as possible for anyone who feels like they can help.

Thanks again!


File Attachment:

File Name: limesurvey...8979.lss
File Size:23 KB
The topic has been locked.
  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
3 years 6 months ago #206719 by tpartner
Place this script in the question source:

Code:
<script type="text/javascript" charset="utf-8">  
  $(document).on('ready pjax:scriptcomplete',function(){
 
    // The sub-question code to be fixed at the end
    var fixedCode = 'o';
 
    // Identify this question
    var qID = '{QID}';
    var thisQuestion = $('#question'+qID);
 
    // Move the "fixed" sub-question
    $('table.subquestion-list tbody:last', thisQuestion).append($('tr[id$="X'+qID+fixedCode+'"]', thisQuestion));
    });
</script>

Sample survey attached:

File Attachment:

File Name: limesurvey...9(1).lss
File Size:25 KB

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
The topic has been locked.
  • PaulMRFGR
  • PaulMRFGR's Avatar Topic Author
  • Offline
  • Senior Member
  • Senior Member
More
3 years 6 months ago #206727 by PaulMRFGR
Thanks Tony,

This is really helpful but it doesn't appear to work unfortunately- we've tried uploading your .lss file and putting in the code ourselves. Is it possible that it's a compatibility issue (we're using 2.05+). Not sure if there's any work arounds if it is?

Thank you again!
The topic has been locked.
  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
3 years 6 months ago #206750 by tpartner
Try this in 2.05 (working from memory so untested):

Code:
<script type="text/javascript" charset="utf-8">  
  $(document).on('ready pjax:scriptcomplete',function(){
 
    // The sub-question code to be fixed at the end
    var fixedCode = 'o';
 
    // Identify this question
    var qID = '{QID}';
    var thisQuestion = $('#question'+qID);
 
    // Move the "fixed" sub-question
    $('table.subquestions-list tbody:last', thisQuestion).append($('tr[id$="X'+qID+fixedCode+'"]', thisQuestion));
    });
</script>

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The topic has been locked.

Lime-years ahead

Online-surveys for every purse and purpose