Welcome to the LimeSurvey Community Forum

Ask the community, share ideas, and connect with other LimeSurvey users!

Email score problem

  • marektondryk
  • marektondryk's Avatar Topic Author
  • Offline
  • Premium Member
  • Premium Member
More
6 years 4 months ago #160424 by marektondryk
Email score problem was created by marektondryk
Hi,
i have survey with equations assessment on email.
there are 7 questions gropus. For each questoin group i use assesment:

{(sum(qb1.value,qb2.value,qb3.value,qb4.value,qb5.value,qb6.value,qb7.value,qb8.value,qb9.value,qb10.value)/40)*100}%

qb1-qb10 are hidden equations questions. max score for each group is 40 (4points for each question).

Is it possible to put some text depends on score value? i.e if score is 0-20% in emal is displayed text "very poor score:, 21-40% "poorscore", 41-60% "avarage score", 61-80% "good score", 81-100% "very good score"
The topic has been locked.
  • Joffm
  • Joffm's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
6 years 4 months ago - 6 years 4 months ago #160459 by Joffm
Replied by Joffm on topic Email score problem
Hi,
The Buzzword is "Tayloring".
manual.limesurvey.org/Expression_Manager#Tailoring_.2F_Piping

If you had provided a sample survey I could show more detailled.

But something like:

Your result is {if(sumQB<=20,"very poor",if(sumQB<=40,"poor",if(sumQB<=60,"average",if(sumQB<=80,"good","very good"))))}

Joffm

Volunteers are not paid.
Not because they are worthless, but because they are priceless
Last edit: 6 years 4 months ago by Joffm.
The topic has been locked.
  • marektondryk
  • marektondryk's Avatar Topic Author
  • Offline
  • Premium Member
  • Premium Member
More
6 years 4 months ago #160505 by marektondryk
Replied by marektondryk on topic Email score problem
Thank You Joffm!
There wasn't one coma, I changed to:

{if(sumqb<=20,"very poor",
if(sumqb<=40,"poor",
if(sumqb<=60,"average",
if(sumqb<=80,"good",
if(sumqb<=100,"very good")))))}

but it doesn't work... in email is displayed

"if(sumqb<=20,"very poor",
if(sumqb<=40,"poor",
if(sumqb<=60,"average",
if(sumqb<=80,"good",
if(sumqb<=100,"very good")))))"

without curly braces '{}'... :ohmy:
The topic has been locked.
  • marektondryk
  • marektondryk's Avatar Topic Author
  • Offline
  • Premium Member
  • Premium Member
More
6 years 4 months ago #160525 by marektondryk
Replied by marektondryk on topic Email score problem
LimeSurvey
version 2.67.3+170728

curly braces doesn't work...
The topic has been locked.
  • Joffm
  • Joffm's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
6 years 4 months ago #160529 by Joffm
Replied by Joffm on topic Email score problem
Hi,
please read about the if-function.

In your example the "false"-part is missing.

If(condition,true part,false part)

Joffm

Volunteers are not paid.
Not because they are worthless, but because they are priceless
The topic has been locked.
  • marektondryk
  • marektondryk's Avatar Topic Author
  • Offline
  • Premium Member
  • Premium Member
More
6 years 4 months ago #160538 by marektondryk
Replied by marektondryk on topic Email score problem
{if(sumqb<=20,"very poor",if(sumqb<=40,"poor",if(sumqb<=60,"average",if(sumqb<=80,"good",if(sumqb<=100,"very good")))))}

Underline isn't false part for 1st condition? Isn't it something like 'nested conditions'?
The topic has been locked.
  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
6 years 4 months ago - 6 years 4 months ago #160540 by tpartner
Replied by tpartner on topic Email score problem
I think Joffm's point is that every if() statment needs s true and false result and your last nested if() statement appears to be missing the false result.

Code:
{if(sumqb<=20,"very poor",
if(sumqb<=40,"poor",
if(sumqb<=60,"average",
if(sumqb<=80,"good",
if(sumqb<=100,"very good", "")))))}

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Last edit: 6 years 4 months ago by tpartner.
The topic has been locked.
  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
6 years 4 months ago #160542 by tpartner
Replied by tpartner on topic Email score problem
...or, slightly simplified:

Code:
{if(sumqb<=20,"very poor",
if(sumqb<=40,"poor",
if(sumqb<=60,"average",
if(sumqb<=80,"good", "very good"))))}

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The topic has been locked.
  • marektondryk
  • marektondryk's Avatar Topic Author
  • Offline
  • Premium Member
  • Premium Member
More
6 years 4 months ago #160546 by marektondryk
Replied by marektondryk on topic Email score problem
Thank You tpartner!
"If statment" seems to be all right, but I still have problem with braces...
If I put code:
Code:
{if(sumqb<=20,"very poor",
if(sumqb<=40,"poor",
if(sumqb<=60,"average",
if(sumqb<=80,"good", "very good"))))}

braces "{,}" disappears and just text is displayed:

if(sumqb<=20,"very poor",
if(sumqb<=40,"poor",
if(sumqb<=60,"average",
if(sumqb<=80,"good", "very good"))))


and calculations doesn't work...

Another caluculations in the same email works perfect:
Code:
{(sum(qb1.value,qb2.value,qb3.value,qb4.value,qb5.value,qb6.value,qb7.value,qb8.value,qb9.value,qb10.value)/40)*100}%
I have no idea what is wrong....
The topic has been locked.
  • Joffm
  • Joffm's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
6 years 4 months ago #160548 by Joffm
Replied by Joffm on topic Email score problem
Hi,
did I understand correctly?

You have the calculation
{(sum(qb1.value,qb2.value,qb3.value,qb4.value,qb5.value,qb6.value,qb7.value,qb8.value,qb9.value,qb10.value)/40)*100}%

and

{if(sumqb<=20,"very poor",
if(sumqb<=40,"poor",
if(sumqb<=60,"average",
if(sumqb<=80,"good", "very good"))))}

in the email?

If you calculated "sumqb" before why calculate it again here?

Or didn't you? Then "sumqb" is undefined.

Just an idea.

Best you provide a sample.

Best regards
Joffm

Volunteers are not paid.
Not because they are worthless, but because they are priceless
The topic has been locked.
  • Joffm
  • Joffm's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
6 years 4 months ago #160576 by Joffm
Replied by Joffm on topic Email score problem
Hi,
please, check your email template in source code modus.
Sometimes the editor changes "<=" to the HTML "&le;"
In that case you should use "le" instead of "<=".
manual.limesurvey.org/Expression_Manager#Operators

Or try to turn your statement.

{if(sumqb>80,"very good",if(sumqb>60,"good",if(sumqb>40,"average",if(sumqb>20,"poor","very poor"))))}


And the curly braces are never displayed if there is an error in the statement. You only see the incorrect statement itself.

Joffm

Volunteers are not paid.
Not because they are worthless, but because they are priceless
The topic has been locked.
  • marektondryk
  • marektondryk's Avatar Topic Author
  • Offline
  • Premium Member
  • Premium Member
More
6 years 4 months ago - 6 years 4 months ago #160588 by marektondryk
Replied by marektondryk on topic Email score problem
Here is test survey (att). @ to admin - calculations
Code:
{if(sumqb>80,"very good",if(sumqb>60,"good",if(sumqb>40,"average",if(sumqb>20,"poor","very poor"))))}
doesn't work.
Code:
{(sum(qb1.value,qb2.value,qb3.value,qb4.value,qb5.value,qb6.value,qb7.value,qb8.value,qb9.value,qb10.value)/40)*100}%
works properly, default template
Last edit: 6 years 4 months ago by marektondryk.
The topic has been locked.

Lime-years ahead

Online-surveys for every purse and purpose