Assign Answer from Array to a Category

More
2 years 10 months ago #137183 by michaelji
Can I and, how can I assign an array answer to a category in order to tally the category?

The respondent chooses column 2 in the array for Option 1. I want to assign Category 3 with a value of 2.

Next question, similar, chooses column 5 for Option 3. This should be assigned Category 1with a value of 5.

The goal is to report to the admin that this respondent rates in Category 1, so far
And better yet, report to the admin the score of the four categories to the admin in the "Detailed admin notification"

Thanks

tpartner wrote: I'm still not convinced this is the best design but you could do something like this:

<script type="text/javascript" charset="utf-8">	
 
	$(document).ready(function(){	
 
		// Identify this question
		var thisQuestion = $('#question{QID}');
 
		// Assign column-specific classes
		$('table.subquestion-list tr', thisQuestion).each(function(i) {
 
			var scale = 1;
			$('> *:gt(0)', this).each(function(i){
				$(this).addClass('column-'+(i+1)+' scale-'+scale+'');
				$(this).attr('data-column', i+1);
				$(this).attr('data-scale', scale);
				if(i == 1) {
					scale++
				}
			});
		});
 
		// Listener on the radios
		$('input.radio', thisQuestion).on('click', function(e){
			$('input.radio', thisQuestion).prop('disabled', false);
			$('input.radio:checked', thisQuestion).each(function(e) {
				var thisCell = $(this).closest('td.answer-item');
				var thisScale = $(thisCell).attr('data-scale');
				$('td[data-scale="'+thisScale+'"]', thisQuestion).not(thisCell).find('input.radio').prop('disabled', true);
			});
		});
 
		// Insert scale headers and separator
		$('colgroup', thisQuestion).remove();
		$('.scale-1.column-1', thisQuestion).before('<td class="inserted-scale-separator"></td>');
		$('.scale-1.column-2', thisQuestion).after('<td class="inserted-scale-separator"></td>');
		$('table.subquestion-list thead', thisQuestion).prepend('<tr class="scale-headers">\
																	<td></td>\
																	<td class="inserted-scale-separator"></td>\
																	<th class="text-center scale-1" data-scale="1" colspan="2">Scale 1</th>\
																	<td class="inserted-scale-separator"></td>\
																	<th class="text-center scale-2" data-scale="2" colspan="2">Scale 2</th>\
																</tr>');
 
		// Some styles (could be done in template.css)
		$('.inserted-scale-separator', thisQuestion).css({
			'width': '5px',
			'background-color': '#FFFFFF'
		});
		$('thead .scale-1', thisQuestion).css({
			'background-color': '#8da6c1',
			'font-weight': 'bold'
		});
		$('thead .scale-2', thisQuestion).css({
			'background-color': '#a7bacf',
			'font-weight': 'bold'
		});
		$('tbody .scale-1', thisQuestion).css({
			'background-color': '#c0cedd',
			'font-weight': 'bold'
		});
		$('tbody .scale-2', thisQuestion).css({
			'background-color': '#dae2eb',
			'font-weight': 'bold'
		});
 
		// Insert a "Reset" button
		$('table.subquestion-list', thisQuestion).after('<input type="button" style="float:right;" value="Reset Question" class="resetQuestionButton" />');
 
		$('.resetQuestionButton', thisQuestion).click(function(e){
			$('input.radio', thisQuestion).prop('checked', false);
			$('input.radio', thisQuestion).prop('disabled', false);
		});
	});
</script>




Sample survey attached:

File Attachment:

File Name: limesurvey...9829.lss
File Size:18 KB

Please Log in or Create an account to join the conversation.

LimeSurvey Partners
More
2 years 10 months ago #137202 by tpartner
Please do not ask the same question in multiple threads. If someone had an answer, they would have given it.

I suspect you can achieve what you want with equation type questions if you read the Expression Manager documentation.

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

Please Log in or Create an account to join the conversation.

More
2 years 10 months ago #137228 by michaelji
Sorry for the cross post...I cannot edit the original and the typo error. I figured that people could not search on a misspelled topic heading.

I will check the suggestion you made and plow through the manual for my answer. I thought it would be an easy answer to and easy question. Limesurvey, since it is group effort is difficult at times to figure out. The manual references the older version and older interface, so I have to try and interpret what is being described in relation to the new menus and interface.

BTW, thanks for the answer/suggestion, rant aside...

Please Log in or Create an account to join the conversation.

Start now!

Just create your account and start using Limesurvey today.

Register now
Join our Newsletter!