array filter for array values

More
3 years 4 months ago #120239 by joost1982
joost1982 created the topic: array filter for array values
Hi there, it is possible to use an array type question as an array filter. But is it also possible to show only certain values from the array question in the question in which the array filter is used?

Example:

question X - rate these things from 1 to 5

blablabla1 1 2 3 4 5
blablabla2 1 2 3 4 5
blablabla3 1 2 3 4 5
blablabla4 1 2 3 4 5
blablabla5 1 2 3 4 5

then question Y - which from the things is blablablablablabla?
Question Y must be an multiple choice question where only the things from question X are shown that are rated 4 or 5.

Is this possible?

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

More
3 years 4 months ago #120243 by DenisChenu
DenisChenu replied the topic: array filter for array values

Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member, professional service on demand (or search sondages pro).
An error happen ? Before make a new topic : remind the Debug mode .

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

More
3 years 4 months ago - 3 years 4 months ago #120435 by dobelin
dobelin replied the topic: array filter for array values
The survey showed in this link is exactly what I need, but I'm new using Limesurvey and don't now how to do this. I have already the two arrays and the filter is working (only shows the items i mark in the first array), but how can the second array show only questions marked "Sans rèponse" ?

One another thing is that I'm using online Surveylime and haven't access to the server in order to change configuration to run Javascript.
Last Edit: 3 years 4 months ago by dobelin.

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

More
3 years 4 months ago - 3 years 4 months ago #120440 by DenisChenu
DenisChenu replied the topic: array filter for array values
Hi

demonstration.sondages.pro/upload/survey...y_filtrecomplexe.lss

You can look at Survey Logic file

And in LimeSurvey Professional (previously LimeService) : you can use javascript in your question text. Look at the workaround fr a howto

Denis

Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member, professional service on demand (or search sondages pro).
An error happen ? Before make a new topic : remind the Debug mode .
Last Edit: 3 years 4 months ago by DenisChenu.
The following user(s) said Thank You: dobelin

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

More
3 years 4 months ago - 3 years 4 months ago #120451 by dobelin
dobelin replied the topic: array filter for array values
Hi Denis,

Thank you for your answer. My problem now is that I can't run Javascript.
Every website that I found say that I need go to set “Global settings -> Security -> Filter HTML for XSS” to “No”, but I don't have the privilegies to do this.
I tried what is in this page: manual.limesurvey.org/Workarounds:_Manip....29_in_LimeSurvey.3F but the test alert didn't work.

There is any solution?
Last Edit: 3 years 4 months ago by dobelin.

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

More
3 years 4 months ago #120460 by DenisChenu
DenisChenu replied the topic: array filter for array values
If you can add javascript in your question text : you need to use 2 different page.

Each question must be in sperate page, see the second system:
- first page : filter + Equation questioin type to SET the filter value (this 2 question can be in the same group than the first question and can be hidden)
- seocnd page : the array filtered.

See the second solution in lss file provided.

Denis

Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member, professional service on demand (or search sondages pro).
An error happen ? Before make a new topic : remind the Debug mode .
The following user(s) said Thank You: dobelin

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

More
3 years 4 months ago #120490 by dobelin
dobelin replied the topic: array filter for array values
Maintenant je comprends. Il a parfaitement fonctionné. Merci beaucoup pour votre patience e disposition!

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

More
2 years 5 months ago - 2 years 5 months ago #135019 by keunes
keunes replied the topic: array filter for array values
Dear all,

I have the same question, but as I don't speak French (well enough) I don't understand the explanation provided in the example (demonstration.sondages.pro/676785).

Somewhat like the OP, I have
- two (not one) array questions on page 1 (same answer categories, sub-question code continues counting)
- a multiple choice question on page 6 (same sub-question codes & names as the two array questions)
- filtering of the multiple choice question works properly based on the array questions (only shows subquestions which have been answered)

But how can the MC question be filtered on sub-questions marked "Sans réponse" (or 'never used' in my case)?
Trying to read French, I think I need to add javascript to my MC question to filter? Or should I add to my two array questions?
Last Edit: 2 years 5 months ago by keunes. Reason: clarify

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

More
2 years 4 months ago - 2 years 4 months ago #135035 by mguerrero
mguerrero replied the topic: array filter for array values
Hello,
You can use javascript and store variables in an array, and to assemble the values you can use expressions, you can also upload your .lss file to better understand the problem.
 
<script>
 
$(document).ready(function() {
 
	var sid = '{SID+'X'+GID+'X'+QID}';
 
	var arreglo = new Array();
 
	//conditions array using  expresion 
	arreglo[0] = {if((PA_1_P1.NAOK == 1)   or (PA_1_P2.NAOK == 1),0,1)};
	arreglo[1] = {if((PA_2_P1.NAOK == 1)   or (PA_2_P2.NAOK == 1),0,2)};
	arreglo[2] = {if((PA_3_P1.NAOK == 1)   or (PA_3_P2.NAOK == 1),0,3)};
	arreglo[3] = {if((PA_4_P1.NAOK == 1)   or (PA_4_P2.NAOK == 1),0,4)};
	arreglo[4] = {if((PA_5_P1.NAOK == 1)   or (PA_5_P2.NAOK == 1),0,5)};
	arreglo[5] = {if((PA_6_P1.NAOK == 1)   or (PA_6_P2.NAOK == 1),0,6)};
	arreglo[6] = {if((PA_7_P1.NAOK == 1)   or (PA_7_P2.NAOK == 1),0,7)};
	arreglo[7] = {if((PA_8_P1.NAOK == 1)   or (PA_8_P2.NAOK == 1),0,8)};
	arreglo[8] = {if((PA_9_P1.NAOK == 1)   or (PA_9_P2.NAOK == 1),0,9)};
	arreglo[9] = {if((PA_10_P1.NAOK == 1)  or (PA_10_P2.NAOK == 1),0,10)};
 
	$(arreglo).each(function(index, el) {
 
		if(el == 0)
		{
			el = "";
		}
		else{
			el = el;
			$("#javatbd"+sid+el).hide();
			$("input[name="+sid+el+"]").val('9999');
			$("input[name="+sid+el+"]").attr('checked',true);
		}
	});
 
});
 
 
</script>
Regards.
Last Edit: 2 years 4 months ago by mguerrero.

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

More
2 years 4 months ago #135060 by tpartner
tpartner replied the topic: array filter for array values
In the latest stable versions of LimeSurvey you can set Expression Manager relevance for individual subquestions.

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 4 months ago - 2 years 4 months ago #135065 by keunes
keunes replied the topic: array filter for array values
Thanks @mguerrero
Wasn't sure where the scripts should be placed, but now I know the Expression Manager is possible I'd rather use that :)

@tpartner, that's what I suspected and so I tried:

- SITU1PLATWHAT_1 (sub question of the multiple choice) with Relevance Equation: if(MEDGEBRTRAD_1 != "Nooit") or if(MEDGEBRTRAD_1 != 1)
- where MEDGEBRTRAD_1 is a subquestion of an array question where Nooit is the answer text and 1 the answer code

I guess I'm doing something wrong here, but don't know what :P My coding (& Expression Manager) skills are rather limited.

Attached you find my survey, but don't know how useful it is since all the questions are in Dutch and there's quite a few questions.
Attachments:
Last Edit: 2 years 4 months ago by keunes. Reason: clarify

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

More
2 years 4 months ago - 2 years 4 months ago #135073 by keunes
keunes replied the topic: array filter for array values
ok, so that use of 'if' is wrong, I just figured out. Should be if(test,result_if_true,result_if_false), so in my case if(MEDGEBRTRAD_1="Nooit","1","0")

I guess the same can be done via regexMatch(pattern,input)?
Last Edit: 2 years 4 months ago by keunes. Reason: forgot [/tt]

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

More
2 years 4 months ago #135074 by tpartner
tpartner replied the topic: array filter for array values
Sorry, don't have time to go through a survey but it seems to me that it should be something like this (without the IF statements). Note that we are comparing to the answer CODE in row one of "MEDGEBRTRAD", not the answer LABEL.

MEDGEBRTRAD_1 != 1

Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The following user(s) said Thank You: keunes

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

More
2 years 4 months ago #135076 by keunes
keunes replied the topic: array filter for array values
Yes, that did the trick :)
Thanks for the explanation!

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!