Matrix where some subquestions got comments

Plus d'informations
il y a 1 an 2 mois #163050 par McTell
COM_KUNENA_MESSAGE_CREATED_NEW
Hey,

I’ve got a Matrix of different questions in LimeSurvey. Yet, some of them require the participant to specify an answer. I would like to have a "comment" text filed behind that specific questions.

The most helpful approach was this one (also check the attachment):
www.limesurvey.org/forum/can-i-do-this-w...w--my-solution#89695

As you also see the attachment I want to control on what subquestions this comment field is shown. Is this somehow possible?


Thanks for any help,
McTell
Pièces jointes :

Connexion ou Créer un compte pour participer à la conversation.

LimeSurvey Partners
Plus d'informations
il y a 1 an 2 mois #163074 par tpartner
COM_KUNENA_MESSAGE_REPLIED_NEW
What LS version are you using?

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

Connexion ou Créer un compte pour participer à la conversation.

Plus d'informations
il y a 1 an 2 mois #163103 par McTell
COM_KUNENA_MESSAGE_REPLIED_NEW
Version 2.00+ Build 130514

but maybe at some point our institutes uses a different hoster, that uses Version 2.72.5+171121 and upgrades much more eagerly...

I’d prefer responding for 2.00, though.

many thanks,
mctell

Connexion ou Créer un compte pour participer à la conversation.

Plus d'informations
il y a 1 an 2 mois #163113 par LouisGac
COM_KUNENA_MESSAGE_REPLIED_NEW
2.0.x has known critical vulnerabilities.
Your institute should update as soon as possible.

Connexion ou Créer un compte pour participer à la conversation.

Plus d'informations
il y a 1 an 2 mois #163127 par tpartner
COM_KUNENA_MESSAGE_REPLIED_NEW
I agree that you should update.

I cannot test on 2.0, but this should work...

1) Create the array question.

2) Add a multiple-short-text question after the array with sub-question codes identical to those of the array where you want the text inputs inserted.

3) Add the following script to the source of the array question. The script will hide the multiple-short-text question and add its question text and text inputs to the corresponding array rows.

<script type="text/javascript" charset="utf-8">
	$(document).ready(function(){
 
		// Identify the questions
		var q1ID = '{QID}';
		var thisQuestion = $('#question{QID}');
		var nextQuestion = $(thisQuestion).next('div[id^="question"]');
		var q2ID = $(nextQuestion).attr('id').replace(/question/, '');
 
		// Hide the multi-text question
		$(nextQuestion).hide();
 
		// Add extra cells to the array rows
		$('.subquestions-list thead tr', thisQuestion).append('<th />');
		$('.subquestions-list tbody tr', thisQuestion).append('<td />');
 
		// Move the multi-text question text to the last column header cell of the array
		$('.subquestions-list thead tr th:last', thisQuestion).text($('.questiontext', nextQuestion).text());
 
		// Move the text inputs
		$('input.text', nextQuestion).each(function(i){
			var thisCode = $(this).attr('id').split('X'+q2ID)[1];
			$('.subquestions-list tbody tr[id$="X'+q1ID+thisCode+'"] td:last', thisQuestion).append(this);
		});
 
		// Some cleanup styles
		$('col', thisQuestion).css({
			'width': 'auto'
		});
		$('.subquestions-list tbody th, .subquestions-list tbody td', thisQuestion).css({
			'padding': '4px 10px'
		});
	});
</script>


This script will work for 2.7x and 3.x:

<script type="text/javascript" charset="utf-8">
	$(document).ready(function(){
 
		// Identify the questions
		var q1ID = '{QID}';
		var thisQuestion = $('#question{QID}');
		var nextQuestion = $(thisQuestion).next('div[id^="question"]');
		var q2ID = $(nextQuestion).attr('id').replace(/question/, '');
 
		// A class for the array question
		$(thisQuestion).addClass('with-inserted-texts');
 
		// Hide the multi-text question
		$(nextQuestion).hide();
 
		// Add extra cells to the array rows
		$('.subquestion-list thead tr', thisQuestion).append('<th class="text-center" />');
		$('.subquestion-list tbody tr', thisQuestion).append('<td />');
 
		// Move the multi-text question text to the last column header cell of the array
		$('.subquestion-list thead tr th:last', thisQuestion).text($('.questiontext', nextQuestion).text());
 
		// Move the text inputs
		$('input[type="text"]', nextQuestion).each(function(i){
			var thisCode = $(this).attr('id').split('X'+q2ID)[1];
			$('.subquestion-list tbody tr[id$="X'+q1ID+thisCode+'"] td:last', thisQuestion).append(this);
		});
 
		// Insert some styles 
		var newStyles = '.with-inserted-texts col { \
							width: auto !important; \
						} \
						.with-inserted-texts .subquestion-list tbody th,\
						.with-inserted-texts .subquestion-list tbody td { \
							padding: 4px 10px; \
						} \
						.with-inserted-texts .subquestion-list tbody th,\
						.with-inserted-texts .subquestion-list tbody td { \
							height: 50px; \
							vertical-align: middle; \
						} \
						.with-inserted-texts .radio label::before,\
						.with-inserted-texts .radio label::after { \
						}';	
		$('head').append('<style type="text/css">'+newStyles+'</style>');
	});
</script>

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

Connexion ou Créer un compte pour participer à la conversation.

Plus d'informations
il y a 1 an 2 mois #163160 par McTell
COM_KUNENA_MESSAGE_REPLIED_NEW
Getting a JavaScript Error:

Uncaught TypeError: Cannot read property 'replace' of undefined

Not sure how to resolve this... I attached the lss with you instructions.

Thanks for any advice.

Best,
McTell
Pièces jointes :

Connexion ou Créer un compte pour participer à la conversation.

Plus d'informations
il y a 1 an 2 mois #163167 par tpartner
COM_KUNENA_MESSAGE_REPLIED_NEW
Can you activate a test survey and give a link?

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

Connexion ou Créer un compte pour participer à la conversation.

Plus d'informations
il y a 1 an 2 mois #163191 par McTell
COM_KUNENA_MESSAGE_REPLIED_NEW
The error is gone, hiding the text field works, yet I don’t see the text field at all, not even next to it:

survey.cbs.mpg.de/index.php/714867/lang-en

Connexion ou Créer un compte pour participer à la conversation.

Plus d'informations
il y a 1 an 2 mois #163195 par tpartner
COM_KUNENA_MESSAGE_REPLIED_NEW
You have not followed my instructions! Your second question is a short-text, not a multiple-short-text.

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

Connexion ou Créer un compte pour participer à la conversation.

Plus d'informations
il y a 1 an 2 mois #163199 par McTell
COM_KUNENA_MESSAGE_REPLIED_NEW
Damn, it’s working now. Thanks!!

Connexion ou Créer un compte pour participer à la conversation.

Commencez dès maintenant !

Créez simplement un compte et commencez à utiliser LimeSurvey dès aujourd'hui.

Inscrivez-vous maintenant

Inscrivez-vous à notre Newsletter!