Validating an Array (Texts)

Mehr
5 Jahre 11 Monate her #85176 von dirend
dirend erstellte das Thema Validating an Array (Texts)
I have used the Array (texts) question type for one of my surveys.
May i know how to validate the percentage subquestion.
Here's what i want to be happened,
If the sum of the entered percentage values gets equal or more than 100 while user enters percentage values, it should give the user a relevant error message or warning.

I think i should put an equation to the Sub-question validation equation Logic field.
But all the equations i tried gave errors in the Logic File. :(

I have uploaded the exported survey file so you could get a proper idea.

Can any one help me on this? :) Thankxx in advance!
Anhang:

Bitte Anmelden oder Registrieren um an der Konversation teilzunehmen.

Mehr
5 Jahre 11 Monate her #85178 von TMSWhite
TMSWhite antwortete auf das Thema: Validating an Array (Texts)
You were close.

Use the "Question validation equation" instead of the "Sub-question validation equation". Since you are summing all of the variables in column 2, use this equation to ensure that the sum equals 100:
sum(self.sq_2)==100

When you use Show Logic File, you will see that equation auto-expands to this:
sum(2_A_2, 2_B_2, 2_C_2, 2_D_2, 2_E_2, 2_F_2, 2_G_2, 2_H_2, 2_I_2) == 100
Folgende Benutzer bedankten sich: dirend

Bitte Anmelden oder Registrieren um an der Konversation teilzunehmen.

Mehr
5 Jahre 11 Monate her #85187 von uwudamit
uwudamit antwortete auf das Thema: Validating an Array (Texts)
When i use this in Question validation equation it gave me a error in logic file saying that
it has errors. Here i have attached two images.







Can any one help me on this? Thanks in advance!
Anhang:

Bitte Anmelden oder Registrieren um an der Konversation teilzunehmen.

Mehr
5 Jahre 11 Monate her #85192 von TMSWhite
TMSWhite antwortete auf das Thema: Validating an Array (Texts)
Which version of 1.92+ are you using? This feature was added in one of the late July or August releases, so you may need to upgrade to the latest 1.92+ release.

If you don't want to upgrade, you can just enter the full equation instead of using the self variable, in which case the "Question validation equation" would be:
sum(2_A_2, 2_B_2, 2_C_2, 2_D_2, 2_E_2, 2_F_2, 2_G_2, 2_H_2, 2_I_2) == 100
Folgende Benutzer bedankten sich: dirend

Bitte Anmelden oder Registrieren um an der Konversation teilzunehmen.

Mehr
5 Jahre 11 Monate her #85195 von dirend
dirend antwortete auf das Thema: Validating an Array (Texts)
It's Version 1.92+ Build 120418.
Anyway we tried the full equation and it worked! :)
Thank you very much for your support Mr.TMSWhite!
:)

Bitte Anmelden oder Registrieren um an der Konversation teilzunehmen.

Mehr
5 Jahre 11 Monate her #85196 von uwudamit
uwudamit antwortete auf das Thema: Validating an Array (Texts)
Yes it worked.. :)

Thank you very much...

Bitte Anmelden oder Registrieren um an der Konversation teilzunehmen.

Mehr
5 Jahre 11 Monate her - 5 Jahre 11 Monate her #85231 von dirend
dirend antwortete auf das Thema: Validating an Array (Texts)
I got another question in the same survey.It's related to the survey file i'v attached in the first post of this topic.

In that survey file 1st sub query column is Rank.
I want to prevent user from entering the same values again.
How can i allow only unique values in the fields?
Is there any option or equation to do this?

I wan't it to be like this

https://docs.google.com/file/d/0B8JZMxx6Km7oT1NITjNkRGNqYzA/edit

Not like this

docs.google.com/file/d/0B8JZMxx6Km7oNG5nelVBRjI3WlU/edit
Letzte Änderung: 5 Jahre 11 Monate her von dirend.

Bitte Anmelden oder Registrieren um an der Konversation teilzunehmen.

Mehr
5 Jahre 11 Monate her #85233 von dirend
dirend antwortete auf das Thema: Validating an Array (Texts)
i didn't found any unique value checking operator so i went with a long equation to get the job done. Here's what i used.It worked.Hope someone else might come up with a better solution. :)


(
(Q2_A_J1 != Q2_B_J1) and
(Q2_A_J1 != Q2_C_J1) and
(Q2_A_J1 != Q2_D_J1) and
(Q2_A_J1 != Q2_E_J1) and
(Q2_A_J1 != Q2_F_J1) and
(Q2_A_J1 != Q2_G_J1) and
(Q2_A_J1 != Q2_H_J1) and
(Q2_A_J1 != Q2_I_J1)
) and (
(Q2_B_J1 != Q2_C_J1) and
(Q2_B_J1 != Q2_D_J1) and
(Q2_B_J1 != Q2_E_J1) and
(Q2_B_J1 != Q2_F_J1) and
(Q2_B_J1 != Q2_G_J1) and
(Q2_B_J1 != Q2_H_J1) and
(Q2_B_J1 != Q2_I_J1)
) and (
(Q2_C_J1 != Q2_D_J1) and
(Q2_C_J1 != Q2_E_J1) and
(Q2_C_J1 != Q2_F_J1) and
(Q2_C_J1 != Q2_G_J1) and
(Q2_C_J1 != Q2_H_J1) and
(Q2_C_J1 != Q2_I_J1)
) and (
(Q2_D_J1 != Q2_E_J1) and
(Q2_D_J1 != Q2_F_J1) and
(Q2_D_J1 != Q2_G_J1) and
(Q2_D_J1 != Q2_H_J1) and
(Q2_D_J1 != Q2_I_J1)
) and (
(Q2_E_J1 != Q2_F_J1) and
(Q2_E_J1 != Q2_G_J1) and
(Q2_E_J1 != Q2_H_J1) and
(Q2_E_J1 != Q2_I_J1)
) and (
(Q2_F_J1 != Q2_G_J1) and
(Q2_F_J1 != Q2_H_J1) and
(Q2_F_J1 != Q2_I_J1)
) and (
(Q2_G_J1 != Q2_H_J1) and
(Q2_G_J1 != Q2_I_J1)
) and (
(Q2_H_J1 != Q2_I_J1)
)

Bitte Anmelden oder Registrieren um an der Konversation teilzunehmen.

Mehr
5 Jahre 11 Monate her #85234 von TMSWhite
TMSWhite antwortete auf das Thema: Validating an Array (Texts)
If you upgrade to the latest 1.92+ version, you will see that the the unique() function was added a couple of months ago. And, if you upgrade, you'll be able to use the self variable.

So, the question validation equation would be:
sum(self.sq_2)==100 && unique(self.sq_1)

And the question validation tip would be:
{if(sum(self.sq_2)==100,'','Sum of the percentage fields must be equal to 100<br/>')}

If you want the subject to rank all of the entries, you would set the question to mandatory, and could then use the following question validation equation and tip, respectively:
if(count(self)==18,(sum(self.sq_2)==100 && unique(self.sq_1)),1)
{if(count(self.sq_2)<9 or sum(self.sq_2)==100,'',implode('','Sum of the percentage fields must be equal to 100.  The current total is ',sum(self.sq_2),'<br/>'))}
{if(count(self.sq_1)<9 or unique(self.sq_1),'','Please rank each option once<br/>')}

Bitte Anmelden oder Registrieren um an der Konversation teilzunehmen.

Mehr
4 Jahre 7 Monate her #102994 von Dede1989
Dede1989 antwortete auf das Thema: Validating an Array (Texts)
Hello,

i want to implement the same functionality with one additional condition: I realized two questions. The first question determines all relevant answers for "question 2" by using a filter. The user now should be able to define percentages (SUM=100) just for the visible options. Is there any chance to implement this behavior?

Bitte Anmelden oder Registrieren um an der Konversation teilzunehmen.

Mehr
4 Jahre 7 Monate her #103000 von DenisChenu
DenisChenu antwortete auf das Thema: Validating an Array (Texts)
Hi,

And sum(self)==100 ?

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 .

Bitte Anmelden oder Registrieren um an der Konversation teilzunehmen.

Mehr
4 Jahre 7 Monate her #103003 von Dede1989
Dede1989 antwortete auf das Thema: Validating an Array (Texts)
What do you mean by And? sum(self)==100 does not work because limesurvey sums up all options (including invisible ones).

Bitte Anmelden oder Registrieren um an der Konversation teilzunehmen.

Mehr
4 Jahre 7 Monate her #103004 von DenisChenu
DenisChenu antwortete auf das Thema: Validating an Array (Texts)
I think :
sum(self) sum up all relevant option.

If you use array_filter it can work ?

No ?

Denis

PS: maybe it's better to do a new topic, and better explain. Because since one year there are a lot of change.

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 .

Bitte Anmelden oder Registrieren um an der Konversation teilzunehmen.

Mehr
4 Jahre 7 Monate her #103015 von tpartner
tpartner antwortete auf das Thema: Validating an Array (Texts)
Dede1989, what question types are you using?

Can you attach a small sample survey?

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

Bitte Anmelden oder Registrieren um an der Konversation teilzunehmen.

Mehr
4 Jahre 7 Monate her #103022 von Dede1989
Dede1989 antwortete auf das Thema: Validating an Array (Texts)
For my first question i'm using a multiple choice array. My second question, which uses the filter, is an array (numbers). My question validation for question 2 is "sum(self)==100". Maybe I can set all invisible options to a default value '0' ?

Bitte Anmelden oder Registrieren um an der Konversation teilzunehmen.

Jetzt loslegen!

Melden Sie sich jetzt an, und erstellen Sie in wenigen Minuten Ihre erste Umfrage.

Account einrichten

Abonnieren Sie unseren Newsletter

Abonnieren Sie unseren Newsletter für alle Neuigkeiten rund um LimeSurvey
captcha