Multiple choice subquestion logic

More
3 years 4 months ago #101665 by rui_b
Hello all,

is it possible to filter/exclude subquestions in a multiple choice type, according to a token attribute?

Ex: I want to exclude subquestion 2, if TOKEN:attribute_1 == 1

Best regards

Please Log in to join the conversation.

More
3 years 4 months ago - 3 years 4 months ago #101668 by tpartner
Untested, but placing this in the source of the multiple-choice question should do the trick:

<script type="text/javascript" charset="utf-8">	
	var attribute_1 = '{TOKEN:ATTRIBUTE_1}';
 
	$(document).ready(function() { 
 
		if(attribute_1 == 1) {
			// Hide the second sub-question			
			$('#question{QID} .question-item:eq(1)').hide();
		}
	});
</script>

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Last Edit: 3 years 4 months ago by tpartner.
The following user(s) said Thank You: rui_b

Please Log in to join the conversation.

More
3 years 4 months ago #101672 by rui_b
Thank you for the quick response!

Isn't it possible to do it through relevance equation or array filter? Or even in the sub-question title by using an expression?

Please Log in to join the conversation.

More
3 years 4 months ago #101673 by tpartner
Not as far as I know.

Cheers,
Tony Partner

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

Please Log in to join the conversation.