Welcome, Guest
Username: Password: Remember me
  • Page:
  • 1
  • 2

TOPIC: Validating an Array (Texts)

Validating an Array (Texts) 8 months 2 weeks ago #103000

  • DenisChenu
  • DenisChenu's Avatar
  • OFFLINE
  • Moderator Lime
  • Posts: 6334
  • Thank you received: 818
  • Karma: 243
Hi,

And sum(self)==100 ?

Denis
The administrator has disabled public write access.

Validating an Array (Texts) 8 months 2 weeks ago #103003

  • Dede1989
  • Dede1989's Avatar
  • OFFLINE
  • Fresh Lemon
  • Posts: 7
  • Karma: 0
What do you mean by And? sum(self)==100 does not work because limesurvey sums up all options (including invisible ones).
The administrator has disabled public write access.

Validating an Array (Texts) 8 months 2 weeks ago #103004

  • DenisChenu
  • DenisChenu's Avatar
  • OFFLINE
  • Moderator Lime
  • Posts: 6334
  • Thank you received: 818
  • Karma: 243
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.
The administrator has disabled public write access.

Validating an Array (Texts) 8 months 2 weeks ago #103015

  • tpartner
  • tpartner's Avatar
  • OFFLINE
  • LimeSurvey Team
  • Posts: 4191
  • Thank you received: 787
  • Karma: 359
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.

LimeSurvey is open-source and run entirely by volunteers so please consider donating to support the project.
The administrator has disabled public write access.

Validating an Array (Texts) 8 months 2 weeks ago #103022

  • Dede1989
  • Dede1989's Avatar
  • OFFLINE
  • Fresh Lemon
  • Posts: 7
  • Karma: 0
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' ?
The administrator has disabled public write access.

Validating an Array (Texts) 8 months 2 weeks ago #103025

  • tpartner
  • tpartner's Avatar
  • OFFLINE
  • LimeSurvey Team
  • Posts: 4191
  • Thank you received: 787
  • Karma: 359
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.

LimeSurvey is open-source and run entirely by volunteers so please consider donating to support the project.
The administrator has disabled public write access.

Validating an Array (Texts) 8 months 2 weeks ago #103068

  • TMSWhite
  • TMSWhite's Avatar
  • OFFLINE
  • LimeSurvey Team
  • Posts: 759
  • Thank you received: 82
  • Karma: 36
A working example is attached.

File Attachment:

File Name: limesurvey_survey_791239.lss
File Size: 25 KB


In this case, you use:
sum(self.sq_A.NAOK)

The reason this works is that sum(x,y,z) will only sum the visible values if you use the .NAOK suffix on each of x, y, and z (which is what self.sq_A.NAOK does). Without the .NAOK suffix, the sum will always be zero if any rows are invisible.

Here is a screen-shot:

testofsumself.NAOK.PNG
Last Edit: 8 months 2 weeks ago by TMSWhite.
The administrator has disabled public write access.
The following user(s) said Thank You: DenisChenu, Dede1989
  • Page:
  • 1
  • 2
Moderators: ITEd
Time to create page: 0.162 seconds
Donation Image