Welcome, Guest
Username: Password: Remember me
  • Page:
  • 1
  • 2

TOPIC: Need help with special question type

Need help with special question type 2 years 6 months ago #76497

  • casim
  • casim's Avatar
  • OFFLINE
  • Fresh Lemon
  • Posts: 3
  • Karma: 0
Hi,

I work on a research in which we ask parents about their child's behaviour/personnality. My job is to adapt the questionnaire on Limesurvey. I'm not a specialist in programmation but everything goes fine up to date. I've been able to customize the template so I'm not too bad. But now there's a scale I don't know how to adapt and I really need help.

I read on another post that we can make 2 questions appear as one (but wasn't described how). Maybe it's the solution, maybe something else would do the job better.

I made 2 images, one with the original questionnaire (explained because it's in french),
helpwithlimesurveyquestion.jpg


the other with what I tried and what could be done if the only solution is to group 2 questions together.
helpwithlimesurveyexample.jpg



Thanks a lot!
The administrator has disabled public write access.

Re: Need help with special question type 2 years 6 months ago #76498

  • DenisChenu
  • DenisChenu's Avatar
  • OFFLINE
  • Moderator Lime
  • Posts: 6334
  • Thank you received: 818
  • Karma: 243
Hello,

I think you can use an array-dual scale for the question.

And after add some cell in javascript, something like that: (question number: 100)
1st : in subquestion put
1. <span class="answer1">Certains enfant ...</span><span class="answer2">D'autres enfants ...</span>
$(document).ready(function()
{
$("#question100 .question .dual_scale_separator").each(function(){
$(this).before('<th class="answer1" />');
$(this).after('<th class="answer2" />');
$(this).text("MAIS");
});
$("#question100 .question .answertext").each(function(){
td-answer1 = ;
td-answer2 = $(this).parent('tr').children('td.answer2');
$(this).children('.answer1').appendTo($(this).parent('tr').children('td.answer1'));
$(this).children('.answer1').appendTo('$(this).parent('tr').children('td.answer2')');
});
});

Not tested but it's the way I choose :).
Last Edit: 2 years 6 months ago by DenisChenu.
The administrator has disabled public write access.

Re: Need help with special question type 2 years 6 months ago #76499

  • DenisChenu
  • DenisChenu's Avatar
  • OFFLINE
  • Moderator Lime
  • Posts: 6334
  • Thank you received: 818
  • Karma: 243
OUps,

Look again:

You need one answer by line or 2 ?

(PS: I understand best french ;), but in french forum).
The administrator has disabled public write access.

Re: Need help with special question type 2 years 6 months ago #76500

  • casim
  • casim's Avatar
  • OFFLINE
  • Fresh Lemon
  • Posts: 3
  • Karma: 0
(sorry, I chose to write my question in english to optimize my chances to have an answer ;) )

I need one answer by line, because the child types are opposed, so a child may only be one type, and a little bit or much.
The administrator has disabled public write access.

Re: Need help with special question type 2 years 6 months ago #76502

  • tpartner
  • tpartner's Avatar
  • OFFLINE
  • LimeSurvey Team
  • Posts: 4193
  • Thank you received: 789
  • Karma: 359
In which case, I would use an array type question and insert the extra cells with JavaScript similar to what Shnoulle suggests.
Cheers,
Tony Partner

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

LimeSurvey is open-source and run entirely by volunteers so please consider donating to support the project.
The administrator has disabled public write access.

Re: Need help with special question type 2 years 6 months ago #76503

  • casim
  • casim's Avatar
  • OFFLINE
  • Fresh Lemon
  • Posts: 3
  • Karma: 0
Thanks a lot!

One last question :blush:

where do I insert the two scripts suggested?
the first in the subquestion and the second in the template .css?
The administrator has disabled public write access.

Re: Need help with special question type 2 years 6 months ago #76525

  • DenisChenu
  • DenisChenu's Avatar
  • OFFLINE
  • Moderator Lime
  • Posts: 6334
  • Thank you received: 818
  • Karma: 243
Hello,

For an array type question.
something like that:
$(document).ready(function()
{
$("#question100 .question .tbody .tr .td:nth-child(2)").each(function(){
$(this).after('<th class="answer2" />');
$(this).text('<th class="mais" />');
$(this).after('<th class="answer1" />');
});
$("#question100 .question .thead .tr .th:nth-child(2)").each(function(){
$(this).after('<th class="answer2" />');
$(this).text('<th class="mais" />');
$(this).after('<th class="answer1" />');
});
$("#question100 .question .answertext").each(function(){
$(this).children('.answer1').appendTo($(this).parent('tr').children('td.answer1'));
$(this).children('.answer2').appendTo($(this).parent('tr').children('td.answer2'));
$(this).parent('tr').children('td.mais').text('MAIS');
});
});

You can put in template.js
or directly in question text: see docs.limesurvey.org/Workarounds%3A+Manip..._etc._in_LimeSurvey_
The administrator has disabled public write access.

Re: Need help with special question type 2 years 6 months ago #76529

  • tpartner
  • tpartner's Avatar
  • OFFLINE
  • LimeSurvey Team
  • Posts: 4193
  • Thank you received: 789
  • Karma: 359
Oh, Denis, you just beat me to it :P

Here's my version for the array (replace "QQ" with the question ID:
<script type="text/javascript" charset="utf-8">
 
	$(document).ready(function() {
		var qID = QQ;
 
		// Reset the column widths
		$('#question'+qID+' col').css({'width':'auto'});
 
		// Insert some cells in the header row
		$('#question'+qID+' table.question thead th:eq(1)').after('<th></th><th></th><th></th>');
 
		// Loop through the answer rows
		$('#question'+qID+' table.question tbody tr').each(function(i) {
			// Insert some cells
			$('td:eq(1)', this).after('<td class="midAnswer1-'+i+'"></td><td class="separator"></td><td class="midAnswer2-'+i+'"></td>');
			// Load the new cells
			$('td.separator', this).text('MAIS');
			$('span.answer1', this).appendTo('td.midAnswer1-'+i+'');
			$('span.answer2', this).appendTo('td.midAnswer2-'+i+'');
		});
	});
 
</script>
Cheers,
Tony Partner

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

LimeSurvey is open-source and run entirely by volunteers so please consider donating to support the project.
The administrator has disabled public write access.

Re: Need help with special question type 2 years 6 months ago #76530

  • tpartner
  • tpartner's Avatar
  • OFFLINE
  • LimeSurvey Team
  • Posts: 4193
  • Thank you received: 789
  • Karma: 359
And, yes, the first part goes in the subquestions. Something like:

Capture_2012-03-13.PNG
Cheers,
Tony Partner

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

LimeSurvey is open-source and run entirely by volunteers so please consider donating to support the project.
The administrator has disabled public write access.

Re: Need help with special question type 2 years 6 months ago #76532

  • DenisChenu
  • DenisChenu's Avatar
  • OFFLINE
  • Moderator Lime
  • Posts: 6334
  • Thank you received: 818
  • Karma: 243
Oups:
// Reset the column widths is a good idea.

Like I say, i never test the script i put in the forum ;)

And you do only one each, very best !
The administrator has disabled public write access.
  • Page:
  • 1
  • 2
Moderators: ITEd
Time to create page: 0.147 seconds
Donation Image