Sum of values
I am trying to make simple test app. I have questions, lets say 5, and all answers should be Text. After I answer all questions it should automatically give points for every question. I set up this as (for answer 1 - a_1):
if (q_1=="Moon") return 1 else 0
Etc for other 4 questions.
And it seems it is working. But, in next step which should be sum of all points, my answers are all calculated as 0 again (which is their default values) so the sum (defined as script: a_1+a_2+a_3+a_4+a_5) is always 0 . How to solve this to get real sum of correct answers? Or, better say, how to save values of answers (a_1, a_2, a_3, a_4, a_5) to not return to their default values?
P.S. I tried to remove default values, but then last step brings error.
Thank you all in advance.
If you use process variables (instead of transient variables) as bindings to your fields, then you can use a groovy script to do your calculations using the variables' content