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

More
6 years 10 months ago #155306 by bsommerhalder
Hi everyone,

I've been reading through docs and these forums, I hope I haven't missed the solution to this question somewhere.


I have a multiple choice list with an "Other" option, and my subquestions are not sequentially named, as I am attempting to match variable naming to programming from another provider (migrating to Lime).

I would like to randomize my list of subquestions, but at the end of the list, always have OTHER, followed by "None". Desired behaviour.

SubQ A
SubQ B ...
SubQ X
SubQ OTHER
SubQ NONE

Where SubQ A thru SubQ X are randomized, but SubQ OTHER and SubQ NONE remain in the second-last and last position in the list, respectively.

I've tried making adaptations to various examples in this thread to no avail.

Is anyone able to assist with this?

Many thanks in advance.
The topic has been locked.
  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
6 years 10 months ago #155307 by tpartner
LimeSurvey version?

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The topic has been locked.
More
6 years 10 months ago #155308 by bsommerhalder
Apologies, version: 2.64.7+170404
The topic has been locked.
  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
6 years 10 months ago - 6 years 10 months ago #155309 by tpartner
Add this script to the question source (modifying "lastItem" as required):

Code:
<script type="text/javascript" charset="utf-8">
  $(document).ready(function() {
 
    // Identify this question
    var qID = {QID};
    var thisQuestion = $('#question'+qID);
 
    // Define the sub-question code to be placed last
    var lastItem = 'SQ004';
 
    // Move that item to the end of the list
    $('.question-item[id$="X'+qID+lastItem+'"]', thisQuestion).addClass('last-item').parent().appendTo($('.subquestion-list', thisQuestion));
  });
</script>

Add something like this to the end of template.css:

Code:
.question-item.last-item {
    margin-top: 15px;
}

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Last edit: 6 years 10 months ago by tpartner.
The following user(s) said Thank You: bsommerhalder
The topic has been locked.
More
6 years 10 months ago #155310 by bsommerhalder
Thank you very very much! This worked great, aside from a formatting issue with the "Other" option I am now experiencing but I am sure this has to do with the custom template I am using ("Olive" from survey-consulting.com).

Screenshot attached, where "I experience none of these conditions" is the SubQ that I am forcing to be last using the JS you provided. If you happen to have a simple solution for this I would be (even more) grateful, but I realize this may come down to some formatting trial-and-error in combination with your excellent solution.

Thanks again.
Attachments:
The topic has been locked.
  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
6 years 10 months ago #155311 by tpartner
Can you activate a test survey and give a link here?

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The topic has been locked.
More
6 years 10 months ago #155312 by bsommerhalder
I created a test survey (same template with your JSS added) with just that question (again with your JSS implemented) here: bit.ly/2se0J35
The topic has been locked.
  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
6 years 10 months ago #155314 by tpartner
Hmm...the template uses the image-tick plugin which, in my opinion, should be replaced with pseudo-elements as in the core shipped templates.

Use this rule at the end of template.css which will force the last item to its own row.

Code:
.question-item.last-item {
    clear: both;
    margin-top: 15px;
}

I still don't like the way the text input is handled, however that is driven by the template and not a result of this workaround.


Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The topic has been locked.
  • holch
  • holch's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
6 years 10 months ago #155522 by holch
I am not surprised, as the template "Olive" only states that it is compatible with the 2.06/ 2.6.x LTS branch and not with the most recent 2.6x branch.

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

The topic has been locked.

Lime-years ahead

Online-surveys for every purse and purpose