expression manager problem.

  • limesun
  • limesun's Avatar Topic Author
  • Visitor
  • Visitor
3 years 8 months ago #100273 by limesun
limesun created the topic: expression manager problem.
i set assessment value for each question.
sometimes i use {sum(q1,q2)},can get the assessment value sum.
sometimes i can't. should change to {sum(q1.value,q2.value)}.
what's the problem.i am not sure about it.

Please Log in to join the conversation.

More
3 years 8 months ago #100278 by jonsen
jonsen replied the topic: expression manager problem.
Dear limesun,

q1 (same as q1.code and q1.NAOK) will return the answer code of the answer selected in q1. The function sum() ignores all values which are not numeric. Therefore, your assessment values will only be correct if your codes in q1 and q2 are numeric.

Example:
sum(1,2) = 3
sum(1,'a') = 1

Best
jonsen

Please Log in to join the conversation.

  • limesun
  • limesun's Avatar Topic Author
  • Visitor
  • Visitor
3 years 8 months ago #100280 by limesun
limesun replied the topic: expression manager problem.
normally, the q1.code is not number,like A1,L001.
when the assessment code is A1, i can get the sum(q1,q2)
when the assessment code is LOO1,the sum(q1,q2) is 0.
i guess it's a bug??

Please Log in to join the conversation.

More
3 years 8 months ago #100282 by jonsen
jonsen replied the topic: expression manager problem.
Using Version 2.00+ Build 130923 I entered the following formulas:

sum(1,2,7,'a') = {sum(1,2,7,'a')}
sum(1,2,7,'L1') = {sum(1,2,7,'L1')}
sum(1,2,7,'L001') = {sum(1,2,7,'L001')}
sum(1,2,7,'L001L') = {sum(1,2,7,'L001L')}
sum(1,2,7,'LOO1') = {sum(1,2,7,'LOO1')}
sum(1,2,7,'001') = {sum(1,2,7,'001')}
sum(1,2,7,'001a') = {sum(1,2,7,'001a')}

...and the result was:

sum(1,2,7,'a') = 10
sum(1,2,7,'L1') = 10
sum(1,2,7,'L001') = 10
sum(1,2,7,'L001L') = 10
sum(1,2,7,'LOO1') = 10
sum(1,2,7,'001') = 11
sum(1,2,7,'001a') = 11 <-- the chars are considered numeric until the first non-numeric string.

This is what I expected. I don't know why you would get anything else...

Please Log in to join the conversation.

  • limesun
  • limesun's Avatar Topic Author
  • Visitor
  • Visitor
3 years 8 months ago #100283 by limesun
limesun replied the topic: expression manager problem.
thanks for your reply.
i only calculate the assessment value.
then
{sum(q1.value,q2.value,q3.value,....q80.value)}
oh my god,such a long expression.
because LS doesnot support {sum(group1.value)}

Please Log in to join the conversation.

Start now!

Just create your account and start using Limesurvey today.

Register now