Hello,
I wrote a Perl script to identify straightlining behavior in CBC-Tasks. The CBC-questions contain 10 tasks with 3 choice sets each. The script looks like this:
<input type="hidden" name="SetStraightlinerCBC_Dummy" id="SetStraightlinerCBC_Dummy" value="[% Begin Unverified Perl
# Parameters
my $exer = 'CBC';
my $tasks = 10;
my $resp1 = 0;
my $resp2 = 0;
my $resp3 = 0;
# Run
for (my $i = 1; $i <= $tasks; $i++) {
if (GETVALUE($exer . '_Random' . $i) == 1) {
$resp1++;
}
elsif (GETVALUE($exer . '_Random' . $i) == 2) {
$resp2++;
}
else (GETVALUE($exer . '_Random' . $i) == 3) {
$resp3++;
}
}
if (($resp1 or $resp2 or $resp3) >= 8) {
return 1;
}
else {
return 0;
}
End Unverified %]"/>
The idea is, to count how often a respondent is choosing the first, the second and the third choice set. This is done by using the variables $resp1, $resp2 and $resp3. If one of the variables is higher than or equals 8, then SetStraightlinerCBC_Dummy = 1, otherwise it should equal 0.
Unfortunately the code isn't working and I do not know what the mistake could be.
I am looking forward for your help!