\n";
+ return $analysis_html;
+}
+
+sub Tries_Concept_Analysis {
+ my ($mintries,$maxtries,$Concepts,$respdat,$ORdata) = @_;
+ my %ResponseData = %$respdat;
+ my $analysis_html = "
\n";
+ #
+ # Compute the data neccessary to make the plots
+ my @PlotData;
+ # 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.
+ 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];
@@ -375,31 +441,22 @@ sub tries_analysis {
$maxstu = 0 if (! defined($maxstu));
$minstu = 0 if (! defined($minstu));
my $title;
- if ($maxstu == $minstu) {
- $title = 'Attempt '.$i.', '.$maxstu.' students';
+ my $count = $ResponseData{'_total'}->[$i];
+ if ($count == 0) {
+ $count = 'no submissions';
+ } elsif ($count == 1) {
+ $count = '1 submission';
} else {
- $title = 'Attempt '.$i.', '.$minstu.'-'.$maxstu.' students';
+ $count = $count.' submissions';
}
- 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);
+ $title = 'Attempt '.$i.', '.$count;
+ my $graphlink = &Apache::loncommon::DrawGraph
+ ($title,'Concept Number','Percent Correct',
+ 100,$plotcolors,$PlotData[$i]->{'_correct'});
+ $analysis_html.= '
'.$graphlink."
\n";
}
- #
- # Should this be something the user can set? Too many dialogs!
- while (my $plotlink = shift(@Plots)) {
- $table .= '
'.$plotlink.'
'.$extrakey."
\n";
- }
- $table .= "
\n";
- return ($table);
+ $analysis_html .= "
\n";
+ return $analysis_html;
}
sub analyze_option_data_by_tries {
@@ -409,23 +466,15 @@ sub analyze_option_data_by_tries {
$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'}++;
- }
+ my $tries = &get_tries_from_row($row);
+ my %Row = &Process_Row($row);
+ while (my ($foilid,$href) = each(%Row)) {
+ if (! ref($href)) {
+ $Trydata{$foilid}->[$tries] += $href;
+ next;
+ }
+ while (my ($option,$value) = each(%$href)) {
+ $Trydata{$foilid}->[$tries]->{$option}+=$value;
}
}
}
@@ -441,141 +490,242 @@ sub analyze_option_data_by_tries {
#########################################################
sub time_analysis {
my ($PerformanceData,$ORdata) = @_;
- my $num_plots = $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 $num_plots = $ENV{'form.NumPlots'};
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 $sec_in_day = 86400;
+ my $last_sub_time = &get_time_from_row($PerformanceData->[-1]);
+ my ($sday,$smon,$syear);
+ (undef,undef,undef,$sday,$smon,$syear) =
+ localtime($last_sub_time - $sec_in_day*$i);
+ $starttime = &Time::Local::timelocal(0,0,0,$sday,$smon,$syear);
+ $endtime = $starttime + $sec_in_day;
+ if ($i == ($num_plots -1 )) {
+ $starttime = &get_time_from_row($PerformanceData->[0]);
+ }
+ }
my $startdateform = &Apache::lonhtmlcommon::date_setter
('Statistics','startdate_'.$i,$starttime);
my $enddateform = &Apache::lonhtmlcommon::date_setter
('Statistics','enddate_'.$i,$endtime);
- $table.="