\n";
}
@@ -282,306 +1330,7 @@ sub build_option_index {
#########################################################
#########################################################
##
-## Tries Analysis
-##
-#########################################################
-#########################################################
-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);
- #
- # Compute the data neccessary to make the plots
- 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 = 'Percent Choosing Option';
- 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 = $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 (! defined($maxstu));
- $minstu = 0 if (! defined($minstu));
- my $title;
- if ($maxstu == $minstu) {
- $title = 'Attempt '.$i.', '.$maxstu.' students';
- } else {
- $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!
- while (my $plotlink = shift(@Plots)) {
- $table .= '
'.$plotlink.'
'.$extrakey."
\n";
- }
- $table .= "
\n";
- return ($table);
-}
-
-sub analyze_option_data_by_tries {
- my ($PerformanceData,$mintries,$maxtries) = @_;
- my %Trydata;
- $mintries = 1 if (! defined($mintries) || $mintries < 1);
- $maxtries = $mintries if (! defined($maxtries) || $maxtries < $mintries);
- 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) {
- for (my $i=0;$i<=$#Foilgrades;$i++) {
- my ($foilid,$correct) = split('=',$Foilgrades[$i]);
- my (undef,$submission) = split('=',$Foilsubs[$i]);
- $submission = &Apache::lonnet::unescape($submission);
- if ($correct) {
- $Trydata{$foilid}->[$numtries]->{'_correct'}++;
- } else {
- $Trydata{$foilid}->[$numtries]->{$submission}++;
- }
- $Trydata{$foilid}->[$numtries]->{'_total'}++;
- }
- }
- }
- }
- return %Trydata;
-}
-
-#########################################################
-#########################################################
-##
-## Time Analysis
-##
-#########################################################
-#########################################################
-sub time_analysis {
- my ($PerformanceData,$ORdata) = @_;
- my $num_plots = $ENV{'form.NumPlots'};
- 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 .= "
\n";
- for (my $i=0;$i<$num_plots;$i++) {
- my $starttime = &Apache::lonhtmlcommon::get_date_from_form
- ('startdate_'.$i);
- my $endtime = &Apache::lonhtmlcommon::get_date_from_form
- ('enddate_'.$i);
- my ($begin_index,$end_index,$plottitle,$plothtml,$data);
- if (! defined($starttime) || ! defined($endtime)) {
- $begin_index = $i*int($num_data/$num_plots);
- $end_index = ($i+1)*int($num_data/$num_plots);
- my $lownum = sprintf('%2.1f',$i*$percent);
- $lownum =~ s/(\.0)$//;
- my $highnum = sprintf('%2.1f',($i+1)*$percent);
- $highnum =~ s/(\.0)$//;
- $plottitle = $lownum.'% to '.$highnum.'% of submissions';
- } else {
- my $j;
- while (++$j < scalar(@$PerformanceData)) {
- last if ($PerformanceData->[$j]->[2] > $starttime);
- }
- $begin_index = $j;
- while (++$j < scalar(@$PerformanceData)) {
- last if ($PerformanceData->[$j]->[2] > $endtime);
- }
- $end_index = $j;
- $plottitle = $ENV{'form.plottitle_'.$i};
- }
- ($plothtml,$starttime,$endtime,$data) =
- &analyze_option_data_by_time($PerformanceData,
- $begin_index,$end_index,
- $plottitle,$Foils,
- $Concepts,$ORdata);
- my $startdateform = &Apache::lonhtmlcommon::date_setter
- ('Statistics','startdate_'.$i,$starttime);
- my $enddateform = &Apache::lonhtmlcommon::date_setter
- ('Statistics','enddate_'.$i,$endtime);
- $table.="