Welcome to the LimeSurvey Community Forum

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

Titles for subquestions

More
8 years 7 months ago #147293 by cstcandy
Hi there.

1) I would like to add and display subtitles to divide the sub-questions into several groups, so that it will be more reader-friendly and respondents can easily find their answers. If there is a solution, would it be different for multiple choice VS. list radio question?
For example, if the question is "Which country do you live in?.", the sub-questions will be displayed in the way like:
Asia
China □
Taiwan □
Thailand □
Singapore □
Malaysia □
Europe
UK □
USA □

2) If I would like to have randomization within each groups of subquestions, are there any solutions?


Appreciated for any response. :)
The topic has been locked.
  • LouisGac
  • LouisGac's Avatar
  • New Member
  • New Member
More
8 years 7 months ago #147305 by LouisGac
Replied by LouisGac on topic Titles for subquestions
can be done with JavaScript.
The topic has been locked.
More
8 years 7 months ago #147320 by DenisChenu
Replied by DenisChenu on topic Titles for subquestions
Easy without 2 (randomization) : there are surely some published workarounds in manual

Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member. - Professional support - Plugins, theme and development .
I don't answer to private message.
The topic has been locked.
More
8 years 7 months ago #147325 by Ben_V
Replied by Ben_V on topic Titles for subquestions

Benoît

EM Variables => bit.ly/1TKQyNu | EM Roadmap => bit.ly/1UTrOB4
Last Releases => 2.6x.x goo.gl/ztWfIV | 2.06/2.6.x => bit.ly/1Qv44A1
Demo Surveys => goo.gl/HuR6Xe (already included in /docs/demosurveys)
The following user(s) said Thank You: DenisChenu
The topic has been locked.
More
8 years 7 months ago #147359 by holch
Replied by holch on topic Titles for subquestions
@Ben_V: I tried the solution posted there (from Tpartner) and it wohnt work in LS 2.59.1. I guess the solution is for the 2.06 / 2.6 branch?

Help us to help you!
  • Provide your LS version and where it is installed (own server, uni/employer, SaaS hosting, etc.).
  • Always provide a LSS file (not LSQ or LSG).
Note: I answer at this forum in my spare time, I'm not a LimeSurvey GmbH employee.
The topic has been locked.
More
8 years 7 months ago #147361 by Ben_V
Replied by Ben_V on topic Titles for subquestions
Probably some selectors have changed..but sounds easy to adapt. This said, I cannot test because I do not have the recent cited version installed anywhere.

Benoît

EM Variables => bit.ly/1TKQyNu | EM Roadmap => bit.ly/1UTrOB4
Last Releases => 2.6x.x goo.gl/ztWfIV | 2.06/2.6.x => bit.ly/1Qv44A1
Demo Surveys => goo.gl/HuR6Xe (already included in /docs/demosurveys)
The topic has been locked.
More
8 years 7 months ago - 8 years 7 months ago #147371 by cstcandy
Replied by cstcandy on topic Titles for subquestions
I have tried the following script. Can I assume the number in bracket "eq(#)" is the row of the subtitle? I have modified the numbers according to my survey and didn't change anything else (sorry I am not familar with JS). It is not working, which my survey still displays the answer options as usual.
Code:
<script charset="utf-8" type="text/javascript">      
  $(document).ready(function() {  
 
    $( '#question{QID} li.question-item:eq(0) input.checkbox').css ({                     
      'display': 'none' 
    });
    $( 'question{QID} li.question-item:eq(5) input.checkbox').css ({                     
      'display': 'none' 
    });
    $( 'question{QID} li.question-item:eq(10) input.checkbox').css ({                     
      'display': 'none' 
    });
    $( 'question{QID} li.question-item:eq(15) input.checkbox').css ({                     
      'display': 'none' 
    });
    $( 'question{QID} li.question-item:eq(19) input.checkbox').css ({                     
      'display': 'none' 
    });
    $( 'question{QID} li.question-item:eq(23) input.checkbox').css ({                     
      'display': 'none' 
    });
    $( 'question{QID} li.question-item:eq(29) input.checkbox').css ({                     
      'display': 'none' 
    });
  });
</script>
Last edit: 8 years 7 months ago by DenisChenu. Reason: spoiler => code
The topic has been locked.
More
8 years 7 months ago #147372 by cstcandy
Replied by cstcandy on topic Titles for subquestions
Sorry, didn't manage to paste the script properly.
The topic has been locked.
More
8 years 7 months ago #147377 by cstcandy
Replied by cstcandy on topic Titles for subquestions
I just tried the script and use default template in my survey. The script works!
So I wonder it is the problem of my designed template. Any specific script to be added in the template.css?

Thanks!
The topic has been locked.
More
8 years 7 months ago - 8 years 7 months ago #147393 by tpartner
Replied by tpartner on topic Titles for subquestions
In version 2.5x, there are pseudo-elements inserted for the check-boxes and you can't reliably use JavaScript to apply styles to a pseudo-element.

The simplest approach is to apply classes to the row elements and target the pseudo-elements in those rows with CSS. You should also remove the check-boxes in those rows in case someone tabs through the question.

1) Add something like this to the question source:
Code:
<script type="text/javascript" charset="utf-8">    
 
  $(document).ready(function() {
    // First Row
    $('#question{QID} .question-item:eq(0)').parent().addClass('sub-header');
    $('#question{QID} .question-item:eq(0)').find('input').remove();
    // Sixth Row
    $('#question{QID} .question-item:eq(5)').parent().addClass('sub-header');
    $('#question{QID} .question-item:eq(5)').find('input').remove();
    // Tenth Row
    $('#question{QID} .question-item:eq(11)').parent().addClass('sub-header');
    $('#question{QID} .question-item:eq(11)').find('input').remove();
  });
</script>

2) Add something like this to the end of template.css:
Code:
.multiple-opt .sub-header .question-item {
  padding-left: 0;
}
 
.multiple-opt .sub-header .label-text {
  margin-left: 0;
  font-weight: bold;
}
 
.multiple-opt .sub-header .checkbox label::before {
  display: none;
}

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Last edit: 8 years 7 months ago by tpartner.
The following user(s) said Thank You: Ben_V, LouisGac
The topic has been locked.
More
8 years 7 months ago #147412 by holch
Replied by holch on topic Titles for subquestions
I think we should have such titles as a feature in Limesurvey, especially for multi answer, list radio and Array.

Help us to help you!
  • Provide your LS version and where it is installed (own server, uni/employer, SaaS hosting, etc.).
  • Always provide a LSS file (not LSQ or LSG).
Note: I answer at this forum in my spare time, I'm not a LimeSurvey GmbH employee.
The following user(s) said Thank You: cstcandy
The topic has been locked.
More
8 years 7 months ago #147471 by cstcandy
Replied by cstcandy on topic Titles for subquestions
Thanks for your help.
But it still doesn't work in my own template... (I am not the one who designed the template so I cannot find out the problem niether.)
The topic has been locked.
More
8 years 7 months ago #147474 by cstcandy
Replied by cstcandy on topic Titles for subquestions
Hi all, I have another solution for the sake of displaying sub-titles.
I use the following script to "hide" the checkbox of particular codes.
The Blankbutton.png is a transparent picture and saved in the template editor.

My next question - is it possible to randomize the answers within groups and then randomize between groups? Thanks so much!

<script type="text/javascript" charset="utf-8">

$(document).ready(function(){

var templatePath = $('head link[href*="template.css"]').attr('href').replace(/template.css/, '');

// Apply images to Group 1 $("input#answerYYYYXYYYYXYYYYYY").imageTick({

// Image to use as a selected state of the checkbox
tick_image_path: templatePath+"Blankbutton.png",
// Image to use as a non-selected state
no_tick_image_path: templatePath+"Blankbutton.png",
// Class to apply to all checkbox images that are dynamically created
image_tick_class: "checkboxes"
});
});

</script>

The topic has been locked.
More
8 years 7 months ago #147485 by tpartner
Replied by tpartner on topic Titles for subquestions

My next question - is it possible to randomize the answers within groups and then randomize between groups? Thanks so much!

You could do that with with JavaScript but without knowing the structure of your template it's impossible to give a code example.

An alternative may be to use several questions and CSS to make them appear as one. Again without template details it's impossible to give a code example.

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 5 months ago #181920 by tixeon
Replied by tixeon on topic Titles for subquestions
Is there a solution for this that works in 3.15.9?
The topic has been locked.
Moderators: tpartnerholch

Lime-years ahead

Online-surveys for every purse and purpose