If I have a multiple choice question, say q1, how can I count how many of the answers have been selected? Thanks
Stephane,
this is some Perl magic.
Create a derived value with the following code.
my $name= "q1";
my $levels = 13;
my $count = 0; map {$count++ if ((eval(sprintf('$%s_%d',$name,$_))||0) == 2)} (1..10);
return $count;
config:
Put the name of the multiple choice variable in where 'q1 is
Put the number of levels where ‘10’ is
How it works - it generates the names of the multiple choice variables ($q1_1, $q1_2 etc) and runs an eval - which is robust against missing values and tests for the selection condition (‘2’) incrementing a counter.