--- loncom/interface/statistics/lonproblemstatistics.pm 2002/08/13 15:01:07 1.22
+++ loncom/interface/statistics/lonproblemstatistics.pm 2002/08/14 16:18:55 1.25
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# (Publication Handler
#
-# $Id: lonproblemstatistics.pm,v 1.22 2002/08/13 15:01:07 stredwic Exp $
+# $Id: lonproblemstatistics.pm,v 1.25 2002/08/14 16:18:55 stredwic Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -56,6 +56,30 @@ sub BuildProblemStatisticsPage {
return;
}
+ # Remove students who don't have the proper section.
+ my @sectionsSelected = split(':',$cache{'sectionsSelected'});
+ for(my $studentIndex=((scalar @$students)-1); $studentIndex>=0;
+ $studentIndex--) {
+ my $value = $cache{$students->[$studentIndex].':section'};
+ my $found = 0;
+ foreach (@sectionsSelected) {
+ if($_ eq 'none') {
+ if($value eq '' || !defined($value) || $value eq ' ') {
+ $found = 1;
+ last;
+ }
+ } else {
+ if($value eq $_) {
+ $found = 1;
+ last;
+ }
+ }
+ }
+ if($found == 0) {
+ splice(@$students, $studentIndex, 1);
+ }
+ }
+
my $Ptr = '';
$Ptr .= '
';
$Ptr .= 'Select Map | '."\n";
@@ -70,6 +94,14 @@ sub BuildProblemStatisticsPage {
'ProblemStatistics',
'Statistics');
$Ptr .= '
'."\n";
+ $Ptr .= 'Select Sections';
+ $Ptr .= ' | '."\n";
+ $Ptr .= ''."\n";
+ my @sections = split(':',$cache{'sectionList'});
+ $Ptr .= &Apache::lonhtmlcommon::MultipleSectionSelect(\@sections,
+ \@sectionsSelected,
+ 'Statistics');
+ $Ptr .= ' |
'."\n";
$Ptr .= &ProblemStatisticsButtons($cache{'DisplayFormat'},
$cache{'DisplayLegend'});
$Ptr .= '
';
@@ -85,8 +117,25 @@ sub BuildProblemStatisticsPage {
my $color=&setbgcolor(0);
# my %Discuss=&Apache::loncoursedata::LoadDiscussion($courseID);
-# my ($upper, $lower) = &Discriminant(\%discriminant,$r);
- if(!defined($cache{'StatisticsCached'})) {
+ my $lastStatus = (defined($cache{'StatisticsLastStatus'})) ?
+ $cache{'StatisticsLastStatus'} : 'Nothing';
+ my $whichStudents = join(':::',sort(@$students));
+ if(!defined($cache{'StatisticsCached'}) ||
+ $lastStatus ne $cache{'Status'} ||
+ $whichStudents ne $cache{'StatisticsWhichStudents'}) {
+ if(defined($cache{'StatisticsCached'})) {
+ untie(%cache);
+ unless(tie(%cache,'GDBM_File',$cacheDB,&GDBM_WRCREAT(),0640)) {
+ $r->print('Unable to tie database.');
+ return;
+ }
+ my @statkeys = split(':::', $cache{'StatisticsKeys'});
+ delete $cache{'StatisticsKeys'};
+ delete $cache{'StatisticsCached'};
+ foreach(@statkeys) {
+ delete $cache{$_};
+ }
+ }
untie(%cache);
&Apache::loncoursedata::DownloadStudentCourseDataSeparate($students,
'true',
@@ -102,7 +151,7 @@ sub BuildProblemStatisticsPage {
return;
}
my ($problemData) = &ExtractStudentData(\%cache, $students);
- &CalculateStatistics($problemData);
+ &CalculateStatistics($problemData, \%cache);
untie(%cache);
unless(tie(%cache,'GDBM_File',$cacheDB,&GDBM_WRCREAT(),0640)) {
@@ -112,7 +161,10 @@ sub BuildProblemStatisticsPage {
foreach(keys(%$problemData)) {
$cache{$_} = $problemData->{$_};
}
+ $cache{'StatisticsKeys'} = join(':::', keys(%$problemData));
$cache{'StatisticsCached'} = 'true';
+ $cache{'StatisticsLastStatus'} = $cache{'Status'};
+ $cache{'StatisticsWhichStudents'} = $whichStudents;
untie(%cache);
unless(tie(%cache,'GDBM_File',$cacheDB,&GDBM_READER(),0640)) {
@@ -120,6 +172,7 @@ sub BuildProblemStatisticsPage {
return;
}
}
+
my $orderedProblems = &SortProblems(\%cache,
$cache{'ProblemStatisticsSort'},
$cache{'ProblemStatisticsAscend'});
@@ -130,6 +183,49 @@ sub BuildProblemStatisticsPage {
return;
}
+sub BuildGraphicChart {
+ my ($graph,$cacheDB,$courseDescription,$r)=@_;
+ my %cache;
+ my $max = 0;
+
+ unless(tie(%cache,'GDBM_File',$cacheDB,&GDBM_READER(),0640)) {
+ return 'Unable to tie database.';
+ }
+
+ my @problems = split(':::', $cache{'problemList'});
+ my @values = ();
+ foreach (@problems) {
+ my $data = 0;
+ if($graph eq 'DoDiffGraph') {
+ $data = sprintf("%.2f", $cache{$_.':degreeOfDifficulty'}),
+ } else {
+ $data = sprintf("%.1f", $cache{$_.':percentWrong'}),
+ }
+ if($max < $data) {
+ $max = $data;
+ }
+ push(@values, $data);
+ }
+ untie(%cache);
+
+ my $sendValues = join(',', @values);
+ my $sendCount = scalar(@values);
+
+ my $title = '';
+ if($graph eq 'DoDiffGraph') {
+ $title = 'Degree-of-Difficulty';
+ } else {
+ $title = 'Wrong-Percentage';
+ }
+ my @GData = ($courseDescription, 'Problems', $title, $max, $sendCount,
+ $sendValues);
+
+ $r->print(''."\n");
+ $r->print('');
+ $r->print(''."\n");
- $r->print('');
- $r->print('