Survey test suite now functional.

Tests are defined via a JSON-encoded spec, through Web Crud interface
Test results are TAP encoded, and TAP parsed and prettified into HTML
Added i18n, help and tests
This commit is contained in:
Patrick Donelan 2009-05-15 10:33:47 +00:00
parent fd5f53e628
commit 7829d708ea
9 changed files with 720 additions and 23 deletions

View file

@ -332,6 +332,49 @@ sub surveyOrder {
return $self->response->{surveyOrder};
}
#-------------------------------------------------------------------
=head2 surveyOrderIndexByVariableName
Returns a lookup table of variable names to surveyOrder index
Only questions with a defined variable name set are included.
=cut
sub surveyOrderIndexByVariableName {
my $self = shift;
my %lookup;
# Iterate over items in surveyOrder..
my $i = 0;
for my $address ( @{ $self->surveyOrder } ) {
next if !$address;
# Retreive the section and question for this address..
my $section = $self->survey->section($address);
my $question = $self->survey->question($address);
if (my $var = $section && $section->{variable} ) {
# Section variables appear for every question, only store lowest index
if (!exists $lookup{$var} || $lookup{$var} > $i) {
$lookup{$var} = $i;
}
}
if (my $var = $question && $question->{variable} ) {
$lookup{$var} = $i;
}
# Increment the item index counter
$i++;
}
return \%lookup;
}
#-------------------------------------------------------------------
=head2 nextResponse ([ $responseIndex ])