# Email score problem

1 year 2 months ago #160424
marektondryk created the topic: Email score problem
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"

1 year 2 months ago - 1 year 2 months ago #160459 by Joffm
Joffm replied the topic: Email score problem
Hi,
The Buzzword is "Tayloring".
https://manual.limesurvey.org/Expression_Manager#Tailoring_.2F_Piping

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: 1 year 2 months ago by Joffm.

1 year 2 months ago #160505
marektondryk replied the 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 '{}'...

1 year 2 months ago #160525
marektondryk replied the topic: Email score problem
LimeSurvey
version 2.67.3+170728

curly braces doesn't work...

1 year 2 months ago #160529 by Joffm
Joffm replied the topic: Email score problem
Hi,

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

1 year 2 months ago #160538
marektondryk replied the 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'?

1 year 2 months ago - 1 year 2 months ago #160540 by tpartner
tpartner replied the 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.

```{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: 1 year 2 months ago by tpartner.

1 year 2 months ago #160542 by tpartner
tpartner replied the topic: Email score problem
...or, slightly simplified:

```{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.

1 year 2 months ago #160546
marektondryk replied the 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:
```{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:
`{(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....

1 year 2 months ago #160548 by Joffm
Joffm replied the 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

1 year 2 months ago #160576 by Joffm
Joffm replied the topic: Email score problem
Hi,
Sometimes the editor changes "<=" to the HTML "&le;"
In that case you should use "le" instead of "<=".
https://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

1 year 2 months ago - 1 year 2 months ago #160588
marektondryk replied the topic: Email score problem
Here is test survey (att). @ to admin - calculations
`{if(sumqb>80,"very good",if(sumqb>60,"good",if(sumqb>40,"average",if(sumqb>20,"poor","very poor"))))}`
doesn't work.
`{(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
##### Attachments:
Last Edit: 1 year 2 months ago by marektondryk.

1 year 2 months ago #160589 by tpartner
tpartner replied the topic: Email score problem
I don't see any equation question with code "sumqb".

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

1 year 2 months ago #160590
marektondryk replied the topic: Email score problem
Hi Joffm,
when I put
{(sum(qb1.value,qb2.value,qb3.value,qb4.value,qb5.value,qb6.value,qb7.value,qb8.value,qb9.value,qb10.value)/40)*100}
in the place of 'sumqb' still doesn't work...

1 year 2 months ago #160591
marektondryk replied the topic: Email score problem
Hi tpartner,
should I make equation question with code "sumqb" with calculation (inside the question):

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

???