Willkommen, Gast
Benutzername: Passwort: Angemeldet bleiben:

THEMA: Array filter exclusion

Array filter exclusion 11 Monate 3 Wochen her #101142

  • id_wahyu
  • id_wahyus Avatar
  • OFFLINE
  • Junior Lime
  • Beiträge: 29
  • Karma: 0
Hi All.
I need some advice and how to deal with "Array filter" or "Array filter exclusion".
It said that for Multiple choice question(s) (separated by semicolons).

My case:
Q1a_FM - Brand Awa FM
Q1a_OTH - Brand Awa Others
Q1b_FM - Ad Awa FM

So at Q1b_FM, at the "Array-filter" option I defined Q1a_FM;Q1a_OTH. But it's not working properly, only show the answer of Q1a_FM.

Any advice for me please.
Letzte Änderung: 11 Monate 3 Wochen her von id_wahyu. Begründung: edit wording
Der Administrator hat öffentliche Schreibrechte deaktiviert.

Array filter exclusion 11 Monate 3 Wochen her #101153

  • tpartner
  • tpartners Avatar
  • OFFLINE
  • LimeSurvey Team
  • Beiträge: 4281
  • Dank erhalten: 807
  • Karma: 370
When filtering by multiple questions, if an answer code exists in BOTH filter questions, it must be selected in BOTH filter questions before it will appear in the filtered question.

If an answer code only exists in ONE of the filter questions, it only needs to be selected in that question before it will appear in the filtered question.
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.
Der Administrator hat öffentliche Schreibrechte deaktiviert.

Array filter exclusion 11 Monate 3 Wochen her #101161

  • id_wahyu
  • id_wahyus Avatar
  • OFFLINE
  • Junior Lime
  • Beiträge: 29
  • Karma: 0
Thanks Tony, for my case Q1a_FM and Q1a_OTH are exclusive each other.

How write the "Array filter" for multiple questions?
I tried "Q1a_FM; Q1a_OTH" but only show Q1a_FM input.

Thanks.
Der Administrator hat öffentliche Schreibrechte deaktiviert.

Array filter exclusion 11 Monate 3 Wochen her #101165

  • tpartner
  • tpartners Avatar
  • OFFLINE
  • LimeSurvey Team
  • Beiträge: 4281
  • Dank erhalten: 807
  • Karma: 370
Can you attach an exported sample survey with that group?
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.
Der Administrator hat öffentliche Schreibrechte deaktiviert.

Array filter exclusion 11 Monate 3 Wochen her #101168

  • id_wahyu
  • id_wahyus Avatar
  • OFFLINE
  • Junior Lime
  • Beiträge: 29
  • Karma: 0
Please find attached.

Dateianhang:

Dateiname: h7cc8467.lsg
Dateigröße: 39 KB
Der Administrator hat öffentliche Schreibrechte deaktiviert.

Array filter exclusion 11 Monate 3 Wochen her #101171

  • tpartner
  • tpartners Avatar
  • OFFLINE
  • LimeSurvey Team
  • Beiträge: 4281
  • Dank erhalten: 807
  • Karma: 370
Ah, now I see your problem. There is no way to satisfy the "must be selected in BOTH filter questions" requirement.

I think the only solution would be to insert a hidden question and use JavaScript to toggle its check-boxes as Q1a_FM and Q1a_OTH are answered. You could then filter Q1b_FM with the hidden question.
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.
Der Administrator hat öffentliche Schreibrechte deaktiviert.

Array filter exclusion 11 Monate 3 Wochen her #101172

  • id_wahyu
  • id_wahyus Avatar
  • OFFLINE
  • Junior Lime
  • Beiträge: 29
  • Karma: 0
Thanks for the prompt reply Tony.
Do you have any sample or documentation on how to create that hidden question?
Der Administrator hat öffentliche Schreibrechte deaktiviert.

Array filter exclusion 11 Monate 3 Wochen her #101177

  • tpartner
  • tpartners Avatar
  • OFFLINE
  • LimeSurvey Team
  • Beiträge: 4281
  • Dank erhalten: 807
  • Karma: 370
1) Set up your survey to use JavaScript.

2) Copy Q1a_FM and place the new question after Q1a_OTH. Lets call the new question "Q1a_Hidden".

3) Filter Q1b_FM by Q1a_Hidden.

4) Add the following script to the source of Q1a_Hidden.

The script hides Q1a_Hidden and puts a listener on the check-boxes in Q1a_FM and Q1a_OTH. If either are found to be checked, the corresponding option in Q1a_Hidden is checked and the checkconditions() function is fired.

<script type="text/javascript" charset="utf-8">	
	$(document).ready(function(){
 
		// Identify some stuff
		var qHiddenID = {QID};
		var hiddenQuestion = $('#question'+qHiddenID);
		var prevQuestions = $(hiddenQuestion).prevAll('.multiple-opt');
		var q1ID = $(hiddenQuestion).prevAll('.multiple-opt:eq(1)').attr('id').replace(/question/, '');
		var q2ID = $(hiddenQuestion).prevAll('.multiple-opt:eq(0)').attr('id').replace(/question/, '');
 
		// Hide the hidden question
		$(hiddenQuestion).hide();
 
		// Listener on the first two multiple-choice questions
		$('input.checkbox', prevQuestions).change(function(event){
 
			// Identify some more stuff
			var thisQuestionCode = $(this).closest('.multiple-opt').attr('id').replace(/question/, '');
			var thisAnswerCode = $(this).attr('id').split('X'+thisQuestionCode)[1];
			var hiddenOption = $('input.checkbox[id$="X'+qHiddenID+thisAnswerCode+'"]');
 
			// Find if either of the filter options are checked
			var filterChecked = false;
			if($('input.checkbox[id$="X'+q1ID+thisAnswerCode+'"]').is(':checked') || $('input.checkbox[id$="X'+q2ID+thisAnswerCode+'"]').is(':checked')) {
				filterChecked = true;
			}
 
			// Toggle the hidden option accordingly
			if(filterChecked != $(hiddenOption).is(':checked')) {
				$(hiddenOption).trigger('click');
				checkconditions($(hiddenOption).attr('value'), $(hiddenOption).attr('name'), $(hiddenOption).attr('type'));
			}
		});
	});
</script>


Here is a working example:

Dateianhang:

Dateiname: h2aadb73.lss
Dateigröße: 62 KB
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.
Letzte Änderung: 7 Monate 1 Stunde her von tpartner.
Der Administrator hat öffentliche Schreibrechte deaktiviert.

Array filter exclusion 11 Monate 3 Wochen her #101198

  • id_wahyu
  • id_wahyus Avatar
  • OFFLINE
  • Junior Lime
  • Beiträge: 29
  • Karma: 0
Thanks for the help Tony.
But, it is working perfect if I use option "Group by Group", and is not with "Question by question" - the Q1a_hidden keep showing.

Any step that I missed Tony?
Der Administrator hat öffentliche Schreibrechte deaktiviert.

Array filter exclusion 11 Monate 3 Wochen her #101210

  • tpartner
  • tpartners Avatar
  • OFFLINE
  • LimeSurvey Team
  • Beiträge: 4281
  • Dank erhalten: 807
  • Karma: 370
This solution will only work if all questions are on the same page.JavaScript can only manipulate elements that exist in the current page.
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.
Der Administrator hat öffentliche Schreibrechte deaktiviert.
Folgende Benutzer bedankten sich: id_wahyu
Moderatoren: ITEd
Ladezeit der Seite: 0.142 Sekunden
Donation Image