Welcome to the LimeSurvey Community Forum

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

Export the order of question options

  • nadica123
  • nadica123's Avatar Topic Author
  • Offline
  • Junior Member
  • Junior Member
More
4 months 2 weeks ago #253225 by nadica123
Export the order of question options was created by nadica123
Please help us help you and fill where relevant:
Your LimeSurvey version: [see right hand bottom of your LimeSurvey admin screen]
Own server or LimeSurvey hosting:
Survey theme/template:
==================
(Write here your question/remark)

Hello,

I would like to know if it's possible to export the order of which answer options are displayed to a respondent, since I have questions where the answer options are rotating each time the question is opened. I'm not seeing such option in the export menu of the survey. Does that mean it is not possible?

Thank you.

Please Log in to join the conversation.

  • tpartner
  • tpartner's Avatar
  • Away
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
4 months 2 weeks ago #253230 by tpartner
Replied by tpartner on topic Export the order of question options
There is no built-in facility for that. You will need to use JavaScript to write the order to a hidden question.

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.

Please Log in to join the conversation.

  • Joffm
  • Joffm's Avatar
  • Online
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
4 months 2 weeks ago #253232 by Joffm
Replied by Joffm on topic Export the order of question options
My question is "Why do you display answer options in random order?"
Answer: To avoid a bias because of the order.
In this case it is not necessary to know anything about the order.

OR:
Your goal is to analyse the effect of different orders.
Let's say there are 6 answer options.
You will get 720 different ways they are displayed.
How will you analyse this.

Here you should create a controlled scenario.
Meaning: You define some orders, which you are interested in (option 2 before option 4 vs  option 2 after option 4, etc.)
Then you display these different questions by a random number.

Joffm

Volunteers are not paid.
Not because they are worthless, but because they are priceless

Please Log in to join the conversation.

  • nadica123
  • nadica123's Avatar Topic Author
  • Offline
  • Junior Member
  • Junior Member
More
4 months 2 weeks ago #253237 by nadica123
Replied by nadica123 on topic Export the order of question options
Thank you for your answer,

This was a request by the client for which the survey was made, as they wanted to have the order of the options besides the answers in the exported file, for what purpose I am not sure.
Since they didn't have any special requests regarding the order I'm assuming they just wanted to avoid bias.

Have a nice day!

Please Log in to join the conversation.

  • nadica123
  • nadica123's Avatar Topic Author
  • Offline
  • Junior Member
  • Junior Member
More
4 months 2 weeks ago #253238 by nadica123
Replied by nadica123 on topic Export the order of question options
Hi,

the question is not hidden, so not sure what you meant by hidden question. Will JavaScript work for regular questions?
How do you suggest this script to be implemented, for each question individually?


Thank you.

Please Log in to join the conversation.

  • Joffm
  • Joffm's Avatar
  • Online
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
4 months 2 weeks ago #253241 by Joffm
Replied by Joffm on topic Export the order of question options

you meant by hidden question.

As you do not want to display this order to the respondent, you have to hide the question.

 

Volunteers are not paid.
Not because they are worthless, but because they are priceless

Please Log in to join the conversation.

  • tpartner
  • tpartner's Avatar
  • Away
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
4 months 2 weeks ago - 4 months 2 weeks ago #253249 by tpartner
Replied by tpartner on topic Export the order of question options

How do you suggest this script to be implemented, for each question individually?
Yes, you would need a hidden question for every question you want the order recorded for.

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Last edit: 4 months 2 weeks ago by tpartner.

Please Log in to join the conversation.

  • Joffm
  • Joffm's Avatar
  • Online
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
4 months 2 weeks ago #253251 by Joffm
Replied by Joffm on topic Export the order of question options
You can use this script

Place your hidden question of type "short text" right after the question in the same group.

Place this code into the question 
Code:
    $(document).on('ready pjax:scriptcomplete',function(){
        
        //Identify the questions
        var thisQuestion = $('#question{QID}');
        var hiddenQuestion = $(thisQuestion).nextAll('.text-short:eq(0)');
        
        // Create an array of answer codes
        var answerCodes = [];
        $('li.answer-item', thisQuestion).each(function(i) {
            answerCodes.push($(this).attr('id').split('X{QID}')[1]);
        });
        
        // Load the hidden question
        $('input:text', hiddenQuestion).val(answerCodes);
        
    });
</script>
 

 

Joffm

 

Volunteers are not paid.
Not because they are worthless, but because they are priceless

Please Log in to join the conversation.

  • nadica123
  • nadica123's Avatar Topic Author
  • Offline
  • Junior Member
  • Junior Member
More
4 months 2 weeks ago #253300 by nadica123
Replied by nadica123 on topic Export the order of question options
Thank you Joffm,

I will try this.

Please Log in to join the conversation.

  • nadica123
  • nadica123's Avatar Topic Author
  • Offline
  • Junior Member
  • Junior Member
More
4 months 2 weeks ago #253305 by nadica123
Replied by nadica123 on topic Export the order of question options
This code doesn't work for me, I added it in the code for the short text hidden question, but I end up with empty field where the order should be written.

I am using this version 6.3.4+231108

Not sure why it doesn't record the order in the question

Please Log in to join the conversation.

  • holch
  • holch's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
4 months 2 weeks ago #253316 by holch
Replied by holch on topic Export the order of question options
How do you hide the question? Via the GUI with "always hide this question"?

This won't work because if the question is hidden this way, it does not appear in the source code and thus Javascript can not write to it.

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

Please Log in to join the conversation.

  • Joffm
  • Joffm's Avatar
  • Online
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
4 months 2 weeks ago #253343 by Joffm
Replied by Joffm on topic Export the order of question options
Just to prove that it works.
Here in fruity 23


I hope you did not forget to add the starting <script> tag.

Joffm

Volunteers are not paid.
Not because they are worthless, but because they are priceless
The following user(s) said Thank You: DenisChenu

Please Log in to join the conversation.

Lime-years ahead

Online-surveys for every purse and purpose