|
Post by verena on Sept 3, 2020 6:36:06 GMT
Hello, i have a small question, is it possible to use/create a modulo operatuer within the calc() statement of a survey. If yes, could you please help me, how?
So, I calculate a score S. S could have values like 104, 203, 5, 204, 902, and several more.
What I need in my survey, is the last digit of this number. It should be either 1,2,3,4, or 5.
I need somehting like this:
l: S t: set - calc ( $q1 + $q2 + $q3 + $q4 + $q5 ) l: ModuloScore t: set - calc ( mod(S) )
l: jump t: jump - if $ModuloScore <4 then goto endExperient
I really appreciate your help! Best wishe and kind regards Verena
|
|
|
Post by PsyToolkit on Sept 3, 2020 12:02:35 GMT
Thanks for the question. This is a function that people might sometimes use to check if a number is even/odd. Why do you use it? Please try version 3.2.0 (the beta version). I have now added this. In you case, make sure to have a space between "<4", thus "< 4" otherwise it will not work. I have now added a modulo score for you. Thus 4 modulo 2 equals zero, whereas 3 modulo 2 equals a number greater than 0.
For modulo, you need two numbers. For example, in order to find out if a number is even (dividable by 2) you would do the following.
l: some_question t: radio q: Select a number - Number 1 (odd) - Number 2 (even) - Number 3 (odd)
l: check_it t: set - calc $some_question modulo 2
l: t: jump - if $check_it = 0 then goto report_even - if $check_it != 0 then goto report_odd
j: endquestion
l: report_odd t: info q: You selected value {$some_question}. That is an odd number!
j: endquestion
l: report_even t: info q: You selected value {$some_question}. That is an even number!
l: endquestion t: info o: end q: The end. Close browser (tab).
|
|