I want to do a survey where for each question I give 2 options, but then I need to count how many K,A,E there are in the whole question group. Each question will be formed by two radio buttons and will have a code of K, A, E depending on the statement. Ultimately I need to count the total of Ks, As and Es chosen.
A working example is here:
matthewbarr.co.uk/bartle/
- probably it's better if one views the source. I have done it in PHP:
pastebin.com/sVASLzRz
and now want to move it to LimeSurvey.
This is what I did:
I created a Question Group - 'test'
Created 3 questions/variables: explorer, achiever, killer.
Created 3 pairs of multiple choice questions T1, T2, T3.
The answer codes are 'A' and 'E' for T1.
I created another variable called result, and did this logic in it:
Code:
{if(T1.NAOK == "A", achiever.NAOK = sum(achiever.NAOK, 1), if(T1.NAOK == "E", explorer.NAOK = sum(explorer.NAOK, 1)))}
I did another expression which shows the results.
This is result:
results
Code:
t1: {T1.NAOK}
t2: {T2.NAOK}
t3: {T3.NAOK}
explorer {explorer.NAOK}
achiever {achiever.NAOK}
killer {killer.NAOK}
I am noticing that when I load the question
explorer and achiever are already '2'.
The moment I choose an option, whatever the option, both increment by 2. Am flabbergasted as to why?
I am attaching the .lsg
Many thanks for your help!!