--- loncom/interface/statistics/lonproblemstatistics.pm 2002/08/14 13:13:37 1.24
+++ 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.24 2002/08/14 13:13:37 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,12 @@ 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)) {
@@ -127,6 +163,8 @@ sub BuildProblemStatisticsPage {
}
$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)) {
@@ -134,6 +172,7 @@ sub BuildProblemStatisticsPage {
return;
}
}
+
my $orderedProblems = &SortProblems(\%cache,
$cache{'ProblemStatisticsSort'},
$cache{'ProblemStatisticsAscend'});
@@ -170,7 +209,6 @@ sub BuildGraphicChart {
untie(%cache);
my $sendValues = join(',', @values);
-# my $sendCount = $#values;
my $sendCount = scalar(@values);
my $title = '';
@@ -236,8 +274,8 @@ sub BuildStatisticsTable {
my $count = 1;
foreach(@$orderedProblems) {
my ($sequence,$problem,$part)=split(':', $_);
- if($cache->{'ProblemStatisticsMaps'} ne 'All Maps' &&
- $cache->{'ProblemStatisticsMaps'} ne $cache->{$sequence.':title'}) {
+ if($cache->{'StatisticsMaps'} ne 'All Maps' &&
+ $cache->{'StatisticsMaps'} ne $cache->{$sequence.':title'}) {
next;
}
@@ -261,18 +299,6 @@ sub BuildStatisticsTable {
sprintf("%.2f", $cache->{$_.':discriminationFactor2'}),
0); # 0 is for discussion, need to figure out
-#6666666
-# $r->print('
'.$out.'&'.$DoD);
-# print (OUT $out.'@'.$DoD.'&');
-#6666666
-
-#check with Gerd
-# $urlres=~/^(\w+)\/(\w+)/;
-# if ($StdNo) {
-# &Apache::lonnet::put('nohist_resevaldata',\%storestats,
-# $1,$2);
-# }
-#-------------------------------- Row of statistical table
&TableRow($displayFormat,$tableData,$count,$r,$color);
$count++;
}
@@ -281,6 +307,11 @@ sub BuildStatisticsTable {
}
$r->print('');
#6666666
+# $r->print('
'.$out.'&'.$DoD);
+# print (OUT $out.'@'.$DoD.'&');
+#6666666
+
+#6666666
# close( OUT );
#666666
return;
@@ -647,13 +678,13 @@ sub CalculateStatistics {
foreach my $name (@upper1) {
$upper1Sum += $cache->{"$name:$problem:$part:awarded"};
}
- $upper1Sum /= (scalar(@upper1)) ? (scalar(@upper1)) : 0;
+ $upper1Sum = (scalar(@upper1)) ? ($upper1Sum/(scalar(@upper1))) : 0;
my $lower1Sum=0;
foreach my $name (@lower1) {
$lower1Sum += $cache->{"$name:$problem:$part:awarded"};
}
- $lower1Sum /= (scalar(@lower1)) ? (scalar(@lower1)) : 0;
+ $lower1Sum = (scalar(@lower1)) ? ($lower1Sum/(scalar(@lower1))) : 0;
$data->{$_.':discriminationFactor1'} = $upper1Sum - $lower1Sum;
@@ -665,13 +696,13 @@ sub CalculateStatistics {
foreach my $name (@upper2) {
$upper2Sum += $cache->{"$name:$problem:$part:awarded"};
}
- $upper2Sum /= (scalar(@upper2)) ? (scalar(@upper2)) : 0;
+ $upper2Sum = (scalar(@upper2)) ? ($upper2Sum/(scalar(@upper2))) : 0;
my $lower2Sum=0;
foreach my $name (@lower2) {
$lower2Sum += $cache->{"$name:$problem:$part:awarded"};
}
- $lower2Sum /= (scalar(@lower2)) ? (scalar(@lower2)) : 0;
+ $lower2Sum = (scalar(@lower2)) ? ($lower2Sum/(scalar(@lower2))) : 0;
$data->{$_.':discriminationFactor2'} = $upper2Sum - $lower2Sum;
}