- Posts: 12
- Thank you received: 0
Welcome to the LimeSurvey Community Forum
Ask the community, share ideas, and connect with other LimeSurvey users!
array filter for array values
- joost1982
- Topic Author
- Offline
- New Member
Less
More
8 years 10 months ago #120239
by joost1982
array filter for array values was created by joost1982
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?
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?
The topic has been locked.
- DenisChenu
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 13912
- Thank you received: 2549
8 years 10 months ago #120243
by DenisChenu
Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member, professional service on demand , plugin development .
I don't answer to private message.
Replied by DenisChenu on 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 , plugin development .
I don't answer to private message.
The topic has been locked.
- dobelin
- Offline
- New Member
Less
More
- Posts: 3
- Thank you received: 0
8 years 10 months ago - 8 years 10 months ago #120435
by dobelin
Replied by dobelin on 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.
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: 8 years 10 months ago by dobelin.
The topic has been locked.
- DenisChenu
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 13912
- Thank you received: 2549
8 years 10 months ago - 8 years 10 months ago #120440
by DenisChenu
Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member, professional service on demand , plugin development .
I don't answer to private message.
Replied by DenisChenu on topic array filter for array values
Hi
demonstration.sondages.pro/upload/survey...y_filtrecomplexe.lss
You can look at Survey Logic file
And in limeservice : you can use javascript in your question text. Look at the workaround fr a howto
Denis
demonstration.sondages.pro/upload/survey...y_filtrecomplexe.lss
You can look at Survey Logic file
And in 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 , plugin development .
I don't answer to private message.
Last edit: 8 years 10 months ago by DenisChenu.
The following user(s) said Thank You: dobelin
The topic has been locked.
- dobelin
- Offline
- New Member
Less
More
- Posts: 3
- Thank you received: 0
8 years 10 months ago - 8 years 10 months ago #120451
by dobelin
Replied by dobelin on 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?
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: 8 years 10 months ago by dobelin.
The topic has been locked.
- DenisChenu
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 13912
- Thank you received: 2549
8 years 10 months ago #120460
by DenisChenu
Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member, professional service on demand , plugin development .
I don't answer to private message.
Replied by DenisChenu on 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
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 , plugin development .
I don't answer to private message.
The following user(s) said Thank You: dobelin
The topic has been locked.
- dobelin
- Offline
- New Member
Less
More
- Posts: 3
- Thank you received: 0
8 years 10 months ago #120490
by dobelin
Replied by dobelin on topic array filter for array values
Maintenant je comprends. Il a parfaitement fonctionné. Merci beaucoup pour votre patience e disposition!
The topic has been locked.
- keunes
- Offline
- Junior Member
Less
More
- Posts: 29
- Thank you received: 2
7 years 10 months ago - 7 years 10 months ago #135019
by keunes
Replied by keunes on 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?
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: 7 years 10 months ago by keunes. Reason: clarify
The topic has been locked.
- mguerrero
- Offline
- New Member
Less
More
- Posts: 10
- Thank you received: 1
7 years 10 months ago - 7 years 10 months ago #135035
by mguerrero
Replied by mguerrero on 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.
Regards.
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.
Code:
<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>
Last edit: 7 years 10 months ago by mguerrero.
The topic has been locked.
- tpartner
- Away
- LimeSurvey Community Team
Less
More
- Posts: 10613
- Thank you received: 3691
7 years 10 months ago #135060
by tpartner
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Replied by tpartner on 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.
The topic has been locked.
- keunes
- Offline
- Junior Member
Less
More
- Posts: 29
- Thank you received: 2
7 years 10 months ago - 7 years 10 months ago #135065
by keunes
Replied by keunes on 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: [tt]if(MEDGEBRTRAD_1 != "Nooit")[/tt] or [tt]if(MEDGEBRTRAD_1 != 1)[/tt]
- where MEDGEBRTRAD_1 is a subquestion of an array question where [tt]Nooit[/tt] is the answer text and [tt]1[/tt] the answer code
I guess I'm doing something wrong here, but don't know what 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.
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: [tt]if(MEDGEBRTRAD_1 != "Nooit")[/tt] or [tt]if(MEDGEBRTRAD_1 != 1)[/tt]
- where MEDGEBRTRAD_1 is a subquestion of an array question where [tt]Nooit[/tt] is the answer text and [tt]1[/tt] the answer code
I guess I'm doing something wrong here, but don't know what 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: 7 years 10 months ago by keunes. Reason: clarify
The topic has been locked.
- keunes
- Offline
- Junior Member
Less
More
- Posts: 29
- Thank you received: 2
7 years 10 months ago - 7 years 10 months ago #135073
by keunes
Replied by keunes on topic array filter for array values
ok, so that use of 'if' is wrong, I just figured out. Should be [tt]if(test,result_if_true,result_if_false)[/tt], so in my case [tt]if(MEDGEBRTRAD_1="Nooit","1","0")[/tt]
I guess the same can be done via [tt]regexMatch(pattern,input)[/tt]?
I guess the same can be done via [tt]regexMatch(pattern,input)[/tt]?
Last edit: 7 years 10 months ago by keunes. Reason: forgot [/tt]
The topic has been locked.