Welcome to the LimeSurvey Community Forum

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

Multiple choice table and insert a list (dropdown) in table as answer options

  • Joffm
  • Joffm's Avatar
  • Away
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
3 years 2 weeks ago - 3 years 2 weeks ago #215085 by Joffm
Hi, Lisa,
sometimes a good idea to read the manual 
[url] manual.limesurvey.org/Question_groups_-_...reate_question_group [/url]

See
 


And quota?
[url] manual.limesurvey.org/Survey_quotas#Add_new_quota [/url]

You want 0 persons who answer "No".
So the limit you have to set is "0".

Joffm


 

Volunteers are not paid.
Not because they are worthless, but because they are priceless
Last edit: 3 years 2 weeks ago by Joffm.
The topic has been locked.
  • LisaTW
  • LisaTW's Avatar Topic Author
  • Offline
  • Junior Member
  • Junior Member
More
3 years 2 weeks ago #215113 by LisaTW
Hi Joffm,
Thank you for your great jobs.  The first question was solved successfully. 

In attachment, I add a question (Q00) with quota, could you please help me check why it didn't work?

And in your sample survey, participant will see 3 questions out of 8 randomly, each page only shows one question. but in my survey, all questions in G1 are showed on one page. Could I change this like your sample survey?

Lisa

Part of the message is hidden for the guests. Please log in or register to see it.
The topic has been locked.
  • LisaTW
  • LisaTW's Avatar Topic Author
  • Offline
  • Junior Member
  • Junior Member
More
3 years 2 weeks ago #215114 by LisaTW
Hi Joffm,
Thank you for your suggestions! 
1. $('.answer-item.answer-item.answer_cell_X001) is applied for the whole column. If i try "answer_cell_X001_Y002" the change is not applied. 
And I found this below, it seems not applied in Version 3.25.20

$('#javatbd371969X110X1123Y002 .answer-item.answer_cell_X001', thisQuestion).addClass('with-select').append('<select class="inserted-select form-control list-question-select">\

Thank you a lot in advance.

Lisa
The topic has been locked.
  • Joffm
  • Joffm's Avatar
  • Away
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
3 years 2 weeks ago #215118 by Joffm
Hi, Mandy,
do I understand this correctly?
You would like to have different options in the drop-downs in one column?
The purpose of an array question is to ask several dimensions on the same set of answers.

Better to split the question (less confusing for the respondents)
You may read this pdf
 

File Attachment:

File Name: surveyfriendly1.zip
File Size:977 KB



But anyway. Here you are
Code:
<script type="text/javascript" charset="utf-8">
    
    $(document).on('ready pjax:scriptcomplete',function(){
        var thisQuestion = $('#question{QID}');
 
        // Column-specific classes
        $('tr.subquestion-list', thisQuestion).each(function(i) {
            $('th, td', this).each(function(i) {
                $(this).addClass('column-'+i);
            });
        });
 
      
      
        // Insert selects into row 1 / column 1
        if($('tr.subquestion-list:eq(0) .answer-item.column-1 .inserted-select', thisQuestion).length == 0) {
            $('tr.subquestion-list:eq(0) .answer-item.column-1', thisQuestion).addClass('with-select').append('<select class="inserted-select form-control list-question-select">\
                <option value="">Please choose...</option>\
                <option value="1">Red</option>\
                <option value="2">Blue</option>\
                <option value="3">Yellow</option>\
            </select>');
        } 
        // Insert selects into row 1 / column 2
        if($('tr.subquestion-list:eq(0) .answer-item.column-2 .inserted-select', thisQuestion).length == 0) {
            $('tr.subquestion-list:eq(0) .answer-item.column-2', thisQuestion).addClass('with-select').append('<select class="inserted-select form-control list-question-select">\
                <option value="">Please choose...</option>\
                <option value="1">VW</option>\
                <option value="2">FORD</option>\
                <option value="3">FIAT</option>\
            </select>');
        } 
        // Insert selects into row 1 / column 3
        if($('tr.subquestion-list:eq(0) .answer-item.column-3 .inserted-select', thisQuestion).length == 0) {
            $('tr.subquestion-list:eq(0) .answer-item.column-3', thisQuestion).addClass('with-select').append('<select class="inserted-select form-control list-question-select">\
                <option value="">Please choose...</option>\
                <option value="1">1</option>\
                <option value="2">2</option>\
                <option value="3">3</option>\
            </select>');
        } 
 
        // Insert selects into row 2 / column 1
        if($('tr.subquestion-list:eq(1) .answer-item.column-1 .inserted-select', thisQuestion).length == 0) {
            $('tr.subquestion-list:eq(1) .answer-item.column-1', thisQuestion).addClass('with-select').append('<select class="inserted-select form-control list-question-select">\
                <option value="">Please choose...</option>\
                <option value="1">Yes</option>\
                <option value="2">No</option>\
                <option value="3">Do not know</option>\
            </select>');
        } 
        // Insert selects into row 2 / column 2
        if($('tr.subquestion-list:eq(1) .answer-item.column-2 .inserted-select', thisQuestion).length == 0) {
            $('tr.subquestion-list:eq(1) .answer-item.column-2', thisQuestion).addClass('with-select').append('<select class="inserted-select form-control list-question-select">\
                <option value="">Please choose...</option>\
                <option value="1">Option 1</option>\
                <option value="2">Option 2</option>\
                <option value="3">Do not know</option>\
            </select>');
        } 
        // Insert selects into row 2 / column 3
        if($('tr.subquestion-list:eq(1) .answer-item.column-3 .inserted-select', thisQuestion).length == 0) {
            $('tr.subquestion-list:eq(1) .answer-item.column-3', thisQuestion).addClass('with-select').append('<select class="inserted-select form-control list-question-select">\
                <option value="">Please choose...</option>\
                <option value="1">+++</option>\
                <option value="2">++</option>\
                <option value="3">+</option>\
                <option value="4">0</option>\
                <option value="5">-</option>\
                <option value="6">--</option>\
                <option value="7">---</option>\
            </select>');
        } 
 
 
        // Listeners on select elements
    $('.inserted-select', thisQuestion).on('change', function(i) {
      if($(this).val() != '') {
        $(this).closest('.answer-item').find('input:text').val($('option:selected', this).val()).trigger('change');
      }
      else {
        $(this).closest('.answer-item').find('input:text').val('').trigger('change');
      }
    });
      
 
        // Returning to page
        $('.with-select input:text', thisQuestion).each(function(i) {
            var thisCell = $(this).closest('.answer-item');
            var inputText = $.trim($(this).val());
            var selectval = $('select.inserted-select option', thisCell).filter(function () { return $(this).html() == inputText; }).val();
            $('select.inserted-select', thisCell).val(selectval);
        });
 
        
        // Clean-up styles
        $('select.inserted-select', thisQuestion).css({
            'max-width': '100%'
        });
        $('.with-select input:text', thisQuestion).css({
            'position': 'absolute',
            'left': '-9999em'
        });
    });
</script>

Here the rows and columns are "counted", so independent from your codes.
columns in the loop at the beginning of the script -> classes "column-1", "column-2", ...
rows by "eq(0)", "eq(1)", ... (index starts with 0)

   
 


And the sample survey.
 

File Attachment:

File Name: limesurvey...6416.lss
File Size:27 KB


Regarding your quota. This is absolutely correct; you should change the quita message.
But remember: A quota can only work in active surveys.
Easy to understand: How can a quota of e.g. 50 men / 50 women work, if there are no data stored?

Joffm

And I found this below, it seems not applied in Version 3.25.20

Oh, you found it.
Where? In front of the bakery in Marnixlaan?

A bit more information would have been appreciated 





 

Volunteers are not paid.
Not because they are worthless, but because they are priceless
The following user(s) said Thank You: LISHANGQI
The topic has been locked.
  • LisaTW
  • LisaTW's Avatar Topic Author
  • Offline
  • Junior Member
  • Junior Member
More
3 years 2 weeks ago #215123 by LisaTW
Hi Joffm,
Thank you very much for your suggestion. Sorry for making you confused. You understand me correctly. It's amazing that your solution absolutely fulfills my requirements.

And in your sample survey, participant will see 3 questions out of 8 randomly, each page only shows one question. In my survey, participant will see 9 questions out of 27 randomly, but all 9 questions in G1 are showed on one page. Could I change this like your sample survey?

Lisa

 
The topic has been locked.
  • Joffm
  • Joffm's Avatar
  • Away
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
3 years 2 weeks ago #215141 by Joffm
Hi,
Please,
once you talk about the array with drop-downs, once about this conjoint solution.
As these are two different questions, you should have opened two threads.

Okay, too late now.

Your setting to display the survey is "group by group".
You have to display "question by question".

In an online survey you always should display one question per page. Respondents should not be forced to scroll.
Only really short questionnaires you may display "group by group" or even "all on one page".

Usually we recommend to display "group by group" with only one question per group.
So you have the look&feel of "question by question", but also some options to merge two or more questions into one by javascript, or in some cases display two or more questions on one page.
This is very flexible.
But doesn't work in your design.

The problem is: LimeSurvey does not distinguish between the logical and visual grouping.
There were some feature requests to have a visual grouping (display several questions on one page horizontally or vertically or both) separated from the logical.
The logical grouping is mainly used for relevance equations, routing, and so on.

That's this.
As far as I see your questionnaire, the display "question by question" is advisable.
You see you used a lot of different ways to display questions in "Part 1 - conditional questions".
This is fine to avoid  boredom; but displayed on one page it is confusing.
By the way: In your "ethnical group" question you say  (It is possible to fill in multiple answers), but it is a list(radio) = single punch.

Well,
if you really want to display group by group there is a different - not built in - approach.

Here you use 27 groups with one question. All get the same randomization group name.
We use a javascript snippet in a hidden question (QString) of type "short text" to select 9 numbers out of your 27​​​​​​​ numbers.
And display only these selected groups.
If you want to display your survey like that, let me know.
And I will send an example.

Joffm

Volunteers are not paid.
Not because they are worthless, but because they are priceless
The following user(s) said Thank You: LISHANGQI
The topic has been locked.
  • LisaTW
  • LisaTW's Avatar Topic Author
  • Offline
  • Junior Member
  • Junior Member
More
3 years 2 weeks ago #215144 by LisaTW
Hi Joffm,
Thank you for your patience and suggestions. I should not put two different questions in one topic. Feel very sorry to make you always confused.

 There are several groups in my survey, for some groups, I'd like to show all questions on one page. 
Only in this conjoint group, I'd like to show one question per page. So your last suggestion may be more suitable.
Could you please send me the sample?

Lisa
 
The topic has been locked.
  • Joffm
  • Joffm's Avatar
  • Away
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
3 years 2 weeks ago #215146 by Joffm
Hi, 
I saw you have it already
[url] forums.limesurvey.org/forum/design-issue...-version-3-22#212411 [/url]

Till here
Random Group 1: strpos(random,"01")>0
Random Group 2: strpos(random,"02")>0
Random Group 3: strpos(random,"03")>0
...
Replace "group" by "question".
Here you may put all 27 questions into one group and set this relevance "strpos(...)>0" into the question relevance
All questions get the same randomization group name. 
Well, the have already.

Joffm

Volunteers are not paid.
Not because they are worthless, but because they are priceless
The topic has been locked.
  • LisaTW
  • LisaTW's Avatar Topic Author
  • Offline
  • Junior Member
  • Junior Member
More
3 years 2 weeks ago #215150 by LisaTW
Hi Joffm,
I really appreciate your kind help!
I may bother you again about this (9 out of 27 randomly) question. 
In "TEST 3" lss file, there are 27 groups and each contains one question. G0 contains javascript.
In "TEST 1" lss file, 27 questions are put in one group. G0 contains javascript.
I may do something wrong, the survey didn't work well.
I'm using  Version 3.25.20 .

Lisa
The topic has been locked.
  • Joffm
  • Joffm's Avatar
  • Away
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
3 years 2 weeks ago - 3 years 2 weeks ago #215153 by Joffm
Sorry, sorry,
having my coffee I realized that I wrote absolute nonsense.

What is in the link is 100% correct.

You have to create 27 groups, each with one question.
group relevance : strpos(...)>0

ALL groups have the same group randomization name.

So test3 will be working.

I'll have a quick look and come back.


It is nearly correct.
1. Question Q0 cannot be alone in a group. Just put it in one of your groups before or in the group with the explanation.
Why? The question is diesplayed (relevance==1). So the group is displayed.
But then you hide the question by javascript.
An empty group remains.

2. If you call this question Q0, you have to refer to this name, not to "random"
You want to say "If the question Q0 contains the string "03" , display the group"
Instead of changing all groups, rename the question "Q0" to "random"

3. There is no randomization group name in the groups

Joffm

Volunteers are not paid.
Not because they are worthless, but because they are priceless
Last edit: 3 years 2 weeks ago by Joffm.
The topic has been locked.
  • LisaTW
  • LisaTW's Avatar Topic Author
  • Offline
  • Junior Member
  • Junior Member
More
3 years 2 weeks ago #215156 by LisaTW
Hi Joffm,
Thank you very much for your reply. With your help I have mastered this challenge. 
Brilliant! It works perfectly.

Lisa
The topic has been locked.

Lime-years ahead

Online-surveys for every purse and purpose