[LON-CAPA-cvs] cvs: loncom /metadata_database/LONCAPA lonmetadata.pm
albertel
lon-capa-cvs-allow@mail.lon-capa.org
Sat, 12 May 2007 23:24:56 -0000
albertel Sat May 12 19:24:56 2007 EDT
Modified files:
/loncom/metadata_database/LONCAPA lonmetadata.pm
Log:
- BUG#5248, correct student counting in the avg calculations, also throw out any saved NaN items
Index: loncom/metadata_database/LONCAPA/lonmetadata.pm
diff -u loncom/metadata_database/LONCAPA/lonmetadata.pm:1.20 loncom/metadata_database/LONCAPA/lonmetadata.pm:1.21
--- loncom/metadata_database/LONCAPA/lonmetadata.pm:1.20 Sat May 12 19:03:30 2007
+++ loncom/metadata_database/LONCAPA/lonmetadata.pm Sat May 12 19:24:56 2007
@@ -1,6 +1,6 @@
# The LearningOnline Network with CAPA
#
-# $Id: lonmetadata.pm,v 1.20 2007/05/12 23:03:30 albertel Exp $
+# $Id: lonmetadata.pm,v 1.21 2007/05/12 23:24:56 albertel Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -795,23 +795,17 @@
# Get the statistical data - Use a weighted average
foreach my $type (qw/avetries difficulty disc/) {
my $studentcount;
+ my %course_counted;
my $sum;
my @Values;
my @Students;
#
- # Old data
- foreach my $coursedata (values(%{$resdata->{'statistics'}}),
- values(%{$resdata->{'stats'}})) {
- if (ref($coursedata) eq 'HASH' && exists($coursedata->{$type})) {
- $studentcount += $coursedata->{'stdno'};
- $sum += ($coursedata->{$type}*$coursedata->{'stdno'});
- push(@Values,$coursedata->{$type});
- push(@Students,$coursedata->{'stdno'});
- }
- }
+ # New data
if (exists($resdata->{'stats'})) {
foreach my $identifier (sort(keys(%{$resdata->{'stats'}}))) {
my $coursedata = $resdata->{'stats'}->{$identifier};
+ next if (lc($coursedata->{$type}) eq 'nan');
+ $course_counted{$coursedata->{'course'}}++;
$studentcount += $coursedata->{'stdno'};
$sum += $coursedata->{$type}*$coursedata->{'stdno'};
push(@Values,$coursedata->{$type});
@@ -819,7 +813,18 @@
}
}
#
- # New data
+ # Old data
+ foreach my $course (keys(%{$resdata->{'statistics'}})) {
+ next if (exists($course_counted{$course}));
+ my $coursedata = $resdata->{'statistics'}{$course};
+ if (ref($coursedata) eq 'HASH' && exists($coursedata->{$type})) {
+ next if (lc($coursedata->{$type}) eq 'nan');
+ $studentcount += $coursedata->{'stdno'};
+ $sum += ($coursedata->{$type}*$coursedata->{'stdno'});
+ push(@Values,$coursedata->{$type});
+ push(@Students,$coursedata->{'stdno'});
+ }
+ }
if (defined($studentcount) && $studentcount>0) {
$data{$type} = $sum/$studentcount;
$data{$type.'_list'} = join(',',@Values);