[LON-CAPA-cvs] cvs: loncom /interface lonchart.pm
stredwic
lon-capa-cvs@mail.lon-capa.org
Mon, 01 Jul 2002 15:39:55 -0000
stredwic Mon Jul 1 11:39:55 2002 EDT
Modified files:
/loncom/interface lonchart.pm
Log:
See bug 484. The stopping of the download of students works well now. These
changes make it so that students who don't have all their information
downloaded do not show up in the chart. When the list was created in
ProcessClassList, someone could stop it before an updated version could
be created. This meant that students with no data would show up but have
zeros for all their scores. Another side effect of the stop button code
is that now a user can hit the form buttons during download without
causing a problem with tieing the hash.
Index: loncom/interface/lonchart.pm
diff -u loncom/interface/lonchart.pm:1.47 loncom/interface/lonchart.pm:1.48
--- loncom/interface/lonchart.pm:1.47 Mon Jul 1 09:59:13 2002
+++ loncom/interface/lonchart.pm Mon Jul 1 11:39:55 2002
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# (Publication Handler
#
-# $Id: lonchart.pm,v 1.47 2002/07/01 13:59:13 stredwic Exp $
+# $Id: lonchart.pm,v 1.48 2002/07/01 15:39:55 stredwic Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -668,7 +668,8 @@
my %CacheData;
if(tie(%CacheData,'GDBM_File',$ChartDB,&GDBM_WRCREAT,0640)) {
foreach my $name (keys(%$classlist)) {
- if($name =~ /\:section/ || $name =~ /\:studentInformation/) {
+ if($name =~ /\:section/ || $name =~ /\:studentInformation/ ||
+ $name eq '') {
next;
}
if($c->aborted()) {
@@ -683,8 +684,6 @@
$name,$courseID,$c);
}
- $CacheData{'NamesOfStudents'}=join(":::",@names);
-# $CacheData{'NamesOfStudents'}=&Apache::lonnet::arrayref2str(\@names);
untie(%CacheData);
}
@@ -763,12 +762,10 @@
}
sub SortStudents {
- my ($CacheData)=@_;
- my @students = split(/:::/,$CacheData->{'NamesOfStudents'});
-# my @students=&Apache::lonnet::str2array($CacheData->{'NamesOfStudents'});
+ my ($students,$CacheData)=@_;
my @sorted1Students=();
- foreach (@students) {
+ foreach (@$students) {
my ($end,$start)=split(/\:/,$CacheData->{$_.':date'});
my $active=1;
my $now=time;
@@ -805,7 +802,7 @@
}
my @order = ();
- foreach my $key (sort keys(%sortData)) {
+ foreach my $key (sort(keys(%sortData))) {
push (@order,$sortData{$key});
}
@@ -858,6 +855,11 @@
foreach my $key (keys (%$courseData)) {
$CacheData{$name.':'.$key}=$courseData->{$key};
}
+ if(defined($CacheData{'NamesOfStudents'})) {
+ $CacheData{'NamesOfStudents'}.=':::'.$name;
+ } else {
+ $CacheData{'NamesOfStudents'}=$name;
+ }
}
untie(%CacheData);
}
@@ -891,6 +893,7 @@
}
# Download class list information if not using cached data
+ my %CacheData;
my @students=();
my @studentInformation=('username','domain','section','id','fullname');
my @headings=('User Name','Domain','Section','PID','Full Name');
@@ -914,12 +917,16 @@
&SpaceColumns(\@students,\@studentInformation,\@headings,
$ChartDB);
if($c->aborted()) { return; }
+ } else {
+ if(!$c->aborted() && tie(%CacheData,'GDBM_File',$ChartDB,
+ &GDBM_READER,0640)) {
+ @students=split(/:::/,$CacheData{'NamesOfStudents'});
+ }
}
# Sort students and print out table desciptive data
- my %CacheData;
if(tie(%CacheData,'GDBM_File',$ChartDB,&GDBM_READER,0640)) {
- if(!$c->aborted()) { @students=&SortStudents(\%CacheData); }
+ if(!$c->aborted()) { @students=&SortStudents(\@students,\%CacheData); }
if(!$c->aborted()) { $r->print(&CreateLegend()); }
if(!$c->aborted()) { $r->print(&CreateForm()); }
if(!$c->aborted()) { $r->print('<h3>'.(scalar @students).