--- loncom/interface/statistics/lonproblemanalysis.pm 2003/10/10 21:49:20 1.32
+++ loncom/interface/statistics/lonproblemanalysis.pm 2003/10/13 19:17:42 1.33
@@ -1,6 +1,7 @@
# The LearningOnline Network with CAPA
#
-# $Id: lonproblemanalysis.pm,v 1.32 2003/10/10 21:49:20 matthew Exp $
+
+# $Id: lonproblemanalysis.pm,v 1.33 2003/10/13 19:17:42 matthew Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -42,13 +43,27 @@ sub BuildProblemAnalysisPage {
#
my @Students = @Apache::lonstatistics::Students;
#
- if (exists($ENV{'form.problemchoice'}) && !exists($ENV{'SelectAnother'})) {
+ if (exists($ENV{'form.updatecaches'}) ||
+ (exists($ENV{'form.firstanalysis'}) &&
+ $ENV{'form.firstanalysis'} ne 'no')) {
+ &Apache::lonstatistics::Gather_Full_Student_Data($r);
+ }
+ if (! exists($ENV{'form.firstanalysis'})) {
+ $r->print('');
+ } else {
+ $r->print('');
+ }
+ if (exists($ENV{'form.problemchoice'}) &&
+ ! exists($ENV{'form.SelectAnother'})) {
$r->print('');
$r->print(' 'x5);
$r->print('');
$r->print(' 'x5);
+ $r->print('');
+ $r->print(' 'x5);
$r->print('');
$r->print('\n";
+ return ($table,@Foils);
+}
+
+#########################################################
+#########################################################
+##
+## Tries Analysis
+##
+#########################################################
+#########################################################
+sub tries_analysis {
+ my ($PerformanceData,$ORdata) = @_;
+ my $mintries = 1;
+ my $maxtries = $ENV{'form.NumPlots'};
+ my %ResponseData = &analyze_option_data_by_tries($PerformanceData,
+ $mintries,$maxtries);
+ my ($table,@Foils) = &build_foil_index($ORdata);
#
# Compute the data neccessary to make the plots
my @PlotData;
@@ -263,12 +297,105 @@ sub analyze_option_data_by_tries {
return %Trydata;
}
-sub get_problem_symb {
- my $problemstring = shift();
- my ($symb,$partid,$resid) = ($problemstring=~ /^(.*):([^:]*):([^:]*)$/);
- return ($symb,$partid,$resid);
+#########################################################
+#########################################################
+##
+## Time Analysis
+##
+#########################################################
+#########################################################
+sub time_analysis {
+ my ($PerformanceData,$ORdata) = @_;
+ my $num_plots = $ENV{'form.NumPlots'};
+ my ($table,@Foils) = &build_foil_index($ORdata);
+ my ($begin_index,$end_index);
+ my $num_data = scalar(@$PerformanceData)-1;
+ my $percent = sprintf('%2f',100/$num_plots);
+ for (my $i=0;$i<$num_plots;$i++) {
+ $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)$//;
+ my ($plothtml,$starttime,$endtime,$data) =
+ &analyze_option_data_by_time($PerformanceData,
+ $begin_index,$end_index,
+ $lownum.'% to '.$highnum.'% of submissions',
+ @Foils);
+ $table.=$plothtml;
+ }
+ return $table;
}
+sub analyze_option_data_by_time {
+ my ($PerformanceData,$begin_index,$end_index,$description,@Foils) = @_;
+ my %TimeData;
+ #
+ # Get the start and end times for this segment of the plot
+ my $starttime = $PerformanceData->[$begin_index]->[2];
+ my $endtime = $PerformanceData->[$end_index ]->[2];
+ #
+ # Compute the number getting the foils correct or incorrects
+ for (my $i=$begin_index;$i<=$end_index;$i++) {
+ my $row = $PerformanceData->[$i];
+ next if (! defined($row));
+ my ($grading,$submission,$time,$tries) = @$row;
+ my @Foilgrades = split('&',$grading);
+ my @Foilsubs = split('&',$submission);
+ foreach my $foilgrade (@Foilgrades) {
+ my ($foilid,$correct) = split('=',$foilgrade);
+ if ($correct) {
+ $TimeData{$foilid}->{'correct'}++;
+ } else {
+ $TimeData{$foilid}->{'incorrect'}++;
+ }
+ }
+ }
+ #
+ # Compute the total and percent correct
+ my @Plotdata1;
+ my @Plotdata2;
+ foreach my $foilid (@Foils) {
+ if (! exists($TimeData{$foilid}->{'correct'})) {
+ $TimeData{$foilid}->{'correct'} = 0;
+ }
+ if (! exists($TimeData{$foilid}->{'incorrect'})) {
+ $TimeData{$foilid}->{'incorrect'} = 0;
+ }
+ $TimeData{$foilid}->{'total'} = $TimeData{$foilid}->{'correct'} +
+ $TimeData{$foilid}->{'incorrect'};
+ $TimeData{$foilid}->{'percent_corr'} = 100 *
+ $TimeData{$foilid}->{'correct'} /
+ $TimeData{$foilid}->{'total'};
+ push (@Plotdata1, $TimeData{$foilid}->{'percent_corr'});
+ push (@Plotdata2,100-$TimeData{$foilid}->{'percent_corr'});
+ }
+ #
+ # Create the plot
+ my $graphlink = &Apache::loncommon::DrawGraph
+ ($description,#'Time Interval Analysis',
+ 'Foil Number',
+ 'Percent Correct / Incorrect',
+ 100,
+ \@Plotdata1,\@Plotdata2);
+ $graphlink .= "
\n".
+ "Start Time: ".localtime($starttime)."
\n".
+ "End Time: ".localtime($endtime)."
\n";
+ #
+ return ($graphlink,$starttime,$endtime,\%TimeData);
+}
+
+
+
+
+#########################################################
+#########################################################
+##
+## Interface
+##
+#########################################################
+#########################################################
sub CreateInterface {
##
## Environment variable initialization
@@ -329,7 +456,7 @@ sub CreateInterface {
if (! exists($ENV{'form.NumPlots'})
|| $ENV{'form.NumPlots'} < 1
|| $ENV{'form.NumPlots'} > 20) {
- $ENV{'form.NumPlots'} = 7;
+ $ENV{'form.NumPlots'} = 5;
}
foreach my $i (1,2,3,4,5,6,7,8,10,15,20) {
$Str .= '