\n";
- return ($table,@Foils);
}
#########################################################
@@ -175,83 +289,113 @@ sub tries_analysis {
my ($PerformanceData,$ORdata) = @_;
my $mintries = 1;
my $maxtries = $ENV{'form.NumPlots'};
+ my ($table,$Foils,$Concepts) = &build_foil_index($ORdata);
+ if ((@$Concepts < 2) && ($ENV{'form.AnalyzeAs'} ne 'Foils')) {
+ $table = '
'.
+ &mt('Not enough data for concept analysis. '.
+ 'Performing Foil Analysis').
+ '
'.$table;
+ $ENV{'form.AnalyzeAs'} = 'Foils';
+ }
my %ResponseData = &analyze_option_data_by_tries($PerformanceData,
- $mintries,$maxtries);
- my ($table,@Foils) = &build_foil_index($ORdata);
+ $mintries,$maxtries);
#
# Compute the data neccessary to make the plots
- my @PlotData;
- my @CumulativePlotData;
- foreach my $foilid (@Foils) {
- for (my $i=$mintries;$i<=$maxtries;$i++) {
- #
- # Gather the per-attempt data
- push (@{$PlotData[$i]->{'good'}},
- $ResponseData{$foilid}->[$i]->{'percent_corr'});
- push (@{$PlotData[$i]->{'bad'}},
- 100-$ResponseData{$foilid}->[$i]->{'percent_corr'});
- #
- # Someday we may need the cumulative data and I think
- # this is a neat way of computing it as we go along.
- push (@{$CumulativePlotData[$i]->{'good'}},
- $CumulativePlotData[-1]->{'good'}+
- $ResponseData{$foilid}->[$i]->{'correct'});
- push (@{$CumulativePlotData[$i]->{'bad'}},
- $CumulativePlotData[-1]->{'bad'}+
- $ResponseData{$foilid}->[$i]->{'incorrect'});
+ my @PlotData; # Array which holds the data for each plot
+ # @{$PlotData[$try]->{'datasetname'}} holds the data for
+ # try $try with respect to 'datasetname'. The array is
+ # filled either with per-foil or per-concept data.
+ my ($extrakey,$xlabel,$ylabel);
+ if ($ENV{'form.AnalyzeAs'} eq 'Foils') {
+ $extrakey = &build_option_index($ORdata);
+ $xlabel = 'Foil Number';
+ $ylabel = 'Option Chosen';
+ foreach my $foilid (@$Foils) {
+ for (my $i=$mintries;$i<=$maxtries;$i++) {
+ foreach my $option ('_correct',@{$ORdata->{'Options'}}) {
+ push(@{$PlotData[$i]->{'_total'}},
+ $ResponseData{$foilid}->[$i]->{'_total'});
+ if ($ResponseData{$foilid}->[$i]->{'_total'} == 0) {
+ push (@{$PlotData[$i]->{$option}},0);
+ } else {
+ push (@{$PlotData[$i]->{$option}},
+ 100 * $ResponseData{$foilid}->[$i]->{$option} /
+ $ResponseData{$foilid}->[$i]->{'_total'});
+ }
+ }
+ }
}
- }
+ } else {
+ # Concept analysis
+ #
+ # Note: we do not bother with characterizing the students incorrect
+ # answers at the concept level because an incorrect answer for one foil
+ # may be a correct answer for another foil.
+ $extrakey = '';
+ $xlabel = 'Concept Number';
+ $ylabel = 'Percent Correct';
+ my %ConceptData;
+ foreach my $concept (@{$Concepts}) {
+ for (my $i=$mintries;$i<=$maxtries;$i++) {
+ #
+ # Gather the per-attempt data
+ my $cdata = $ConceptData{$concept}->[$i];
+ foreach my $foilid (@{$concept->{'foils'}}) {
+ $cdata->{'_correct'} +=
+ $ResponseData{$foilid}->[$i]->{'_correct'};
+ $cdata->{'_total'} +=
+ $ResponseData{$foilid}->[$i]->{'_total'};
+ }
+ push (@{$PlotData[$i]->{'_total'}},$cdata->{'_total'});
+ if ($cdata->{'_total'} == 0) {
+ push (@{$PlotData[$i]->{'_correct'}},0);
+ } else {
+ push (@{$PlotData[$i]->{'_correct'}},
+ 100*$cdata->{'_correct'}/$cdata->{'_total'});
+ }
+ }
+ }
+ } # End of work to fill @PlotData
#
# Build a table for the plots
$table .= "
\n";
my @Plots;
for (my $i=$mintries;$i<=$maxtries;$i++) {
- my $minstu = $ResponseData{$Foils[0]}->[$i]->{'total'};
- my $maxstu = $ResponseData{$Foils[0]}->[$i]->{'total'};
- foreach my $foilid (@Foils) {
- if ($minstu > $ResponseData{$foilid}->[$i]->{'total'}) {
- $minstu = $ResponseData{$foilid}->[$i]->{'total'};
- }
- if ($maxstu < $ResponseData{$foilid}->[$i]->{'total'}) {
- $maxstu = $ResponseData{$foilid}->[$i]->{'total'};
+ my $minstu = $PlotData[$i]->{'_total'}->[0];
+ my $maxstu = $PlotData[$i]->{'_total'}->[0];
+ foreach my $count (@{$PlotData[$i]->{'_total'}}) {
+ if ($minstu > $count) {
+ $minstu = $count;
+ }
+ if ($maxstu < $count) {
+ $maxstu = $count;
}
}
- $maxstu = 0 if (! $maxstu);
- $minstu = 0 if (! $minstu);
- my $graphlink;
+ $maxstu = 0 if (! defined($maxstu));
+ $minstu = 0 if (! defined($minstu));
+ my $title;
if ($maxstu == $minstu) {
- $graphlink = &Apache::loncommon::DrawGraph
- ('Attempt '.$i.', '.$maxstu.' students',
- 'Foil Number',
- 'Percent Correct',
- 100,
- $PlotData[$i]->{'good'},
- $PlotData[$i]->{'bad'});
+ $title = 'Attempt '.$i.', '.$maxstu.' students';
} else {
- $graphlink = &Apache::loncommon::DrawGraph
- ('Attempt '.$i.', '.$minstu.'-'.$maxstu.
- ' students',
- 'Foil Number',
- 'Percent Correct',
- 100,
- $PlotData[$i]->{'good'},
- $PlotData[$i]->{'bad'});
+ $title = 'Attempt '.$i.', '.$minstu.'-'.$maxstu.' students';
}
+ my @Datasets;
+ foreach my $option ('_correct',@{$ORdata->{'Options'}}) {
+ next if (! exists($PlotData[$i]->{$option}));
+ push(@Datasets,$PlotData[$i]->{$option});
+ }
+ my $graphlink = &Apache::loncommon::DrawGraph($title,
+ $xlabel,
+ $ylabel,
+ 100,
+ $plotcolors,
+ @Datasets);
push(@Plots,$graphlink);
}
#
# Should this be something the user can set? Too many dialogs!
- my $plots_per_row = 2;
while (my $plotlink = shift(@Plots)) {
- $table .= '
'.$plotlink.'
';
- for (my $i=1;$i<$plots_per_row;$i++) {
- if ($plotlink = shift(@Plots)) {
- $table .= '
'.$plotlink.'
';
- } else {
- $table .= '
';
- }
- }
- $table .= "
\n";
+ $table .= '
'.$plotlink.'
'.$extrakey."
\n";
}
$table .= "
\n";
return ($table);
@@ -265,35 +409,26 @@ sub analyze_option_data_by_tries {
foreach my $row (@$PerformanceData) {
next if (! defined($row));
my ($grading,$submission,$time,$tries) = @$row;
+ next if ($grading eq 'MISSING_ANSWER');
my @Foilgrades = split('&',$grading);
my @Foilsubs = split('&',$submission);
for (my $numtries = 1; $numtries <= $maxtries; $numtries++) {
if ($tries == $numtries) {
- foreach my $foilgrade (@Foilgrades) {
- my ($foilid,$correct) = split('=',$foilgrade);
+ for (my $i=0;$i<=$#Foilgrades;$i++) {
+ my ($foilid,$correct) = split('=',$Foilgrades[$i]);
+ my (undef,$submission) = split('=',$Foilsubs[$i]);
+ $submission = &HTML::Entities::decode($submission);
+ $submission =~ s/\%20/ /g;
if ($correct) {
- $Trydata{$foilid}->[$numtries]->{'correct'}++;
+ $Trydata{$foilid}->[$numtries]->{'_correct'}++;
} else {
- $Trydata{$foilid}->[$numtries]->{'incorrect'}++;
+ $Trydata{$foilid}->[$numtries]->{$submission}++;
}
+ $Trydata{$foilid}->[$numtries]->{'_total'}++;
}
}
}
}
- foreach my $foilid (keys(%Trydata)) {
- foreach my $tryhash (@{$Trydata{$foilid}}) {
- next if ((! exists($tryhash->{'correct'}) &&
- ! exists($tryhash->{'incorrect'})) ||
- ($tryhash->{'correct'} < 1 &&
- $tryhash->{'incorrect'} < 1));
- $tryhash->{'total'} = $tryhash->{'correct'} +
- $tryhash->{'incorrect'};
- $tryhash->{'percent_corr'} = 100 *
- ($tryhash->{'correct'} /
- ($tryhash->{'correct'} + $tryhash->{'incorrect'})
- );
- }
- }
return %Trydata;
}
@@ -307,9 +442,14 @@ sub analyze_option_data_by_tries {
sub time_analysis {
my ($PerformanceData,$ORdata) = @_;
my $num_plots = $ENV{'form.NumPlots'};
- my ($table,@Foils) = &build_foil_index($ORdata);
+ my ($table,$Foils,$Concepts) = &build_foil_index($ORdata);
my $num_data = scalar(@$PerformanceData)-1;
my $percent = sprintf('%2f',100/$num_plots);
+ my $extratable = '';
+ if ($ENV{'form.AnalyzeAs'} eq 'Foils') {
+ $extratable = &build_option_index($ORdata);
+ }
+ $table .= "