--- loncom/interface/Attic/lonchart.pm 2002/06/28 18:06:14 1.44
+++ loncom/interface/Attic/lonchart.pm 2002/07/01 15:39:55 1.48
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# (Publication Handler
#
-# $Id: lonchart.pm,v 1.44 2002/06/28 18:06:14 stredwic Exp $
+# $Id: lonchart.pm,v 1.48 2002/07/01 15:39:55 stredwic Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -55,7 +55,7 @@ use Apache::loncommon();
use HTML::TokeParser;
use GDBM_File;
-#my $jr;
+my $jr;
# ----- FORMAT PRINT DATA ----------------------------------------------
sub FormatStudentInformation {
@@ -244,6 +244,38 @@ sub CreateTableHeadings {
return $Str;
}
+sub CreateColumnSelectors {
+ my ($CacheData,$studentInformation,$headings,$spacePadding)=@_;
+ my $Str='';
+
+ $Str .= '
'."\n";
+ return $Str;
+
+ for(my $index=0; $index<(scalar @$headings); $index++) {
+ my $data=$$headings[$index];
+ $Str .= $data;
+
+ my @dataLength=split(//,$data);
+ my $length=scalar @dataLength;
+ $Str .= (' 'x($CacheData->{$$studentInformation[$index].'Length'}-
+ $length));
+ $Str .= $spacePadding;
+ }
+
+ foreach my $sequence (split(/\:/,$CacheData->{'orderedSequences'})) {
+ $Str .= $CacheData->{$sequence.':title'};
+ my @titleLength=split(//,$CacheData->{$sequence.':title'});
+ my $leftover=$CacheData->{$sequence.':columnWidth'}-
+ (scalar @titleLength);
+ $Str .= (' 'x$leftover);
+ $Str .= $spacePadding;
+ }
+
+ return $Str;
+}
+
sub CreateForm {
my $OpSel1='';
my $OpSel2='';
@@ -267,9 +299,12 @@ sub CreateForm {
''."\n".
''."\n".
' '."\n";
- $Ptr .= ' ';
+ $Ptr .= '
';
$Ptr .= '';
$Ptr .= "\n";
+ $Ptr .= ' ';
+ $Ptr .= '';
+ $Ptr .= "\n";
$Ptr .= ''."\n";
return $Ptr;
@@ -390,6 +425,7 @@ sub ProcessTopResourceMap {
my ($currentSequence, $currentResourceID, $lastResourceID);
$currentResourceID=$hash{'ids_/res/'.$ENV{'request.course.uri'}};
+ push(@currentResource, $currentResourceID);
$lastResourceID=-1;
$currentSequence=-1;
my $topLevelSequenceNumber = $currentSequence;
@@ -463,8 +499,6 @@ sub ProcessTopResourceMap {
if($currentResourceID eq $lastResourceID) {
#pop off last resource of sequence
$currentResourceID=pop(@currentResource);
- #pop to get last resource in previous sequence
- $currentResourceID=pop(@currentResource);
$lastResourceID=pop(@finishResource);
if(defined($CacheData{$currentSequence.':problems'})) {
@@ -479,9 +513,12 @@ sub ProcessTopResourceMap {
$hash{'title_'.$currentResourceID};
my $totalProblems=0;
- foreach (split(/\:/,$CacheData{$currentSequence.
+ foreach my $currentProblem (split(/\:/,
+ $CacheData{$currentSequence.
':problems'})) {
- foreach ($CacheData{$currentSequence.':'.$_.':parts'}) {
+ foreach (split(/\:/,$CacheData{$currentSequence.':'.
+ $currentProblem.
+ ':parts'})) {
$totalProblems++;
}
}
@@ -516,10 +553,9 @@ sub ProcessTopResourceMap {
foreach (split(/\,/,$hash{'to_'.$currentResourceID})) {
push(@nextResources, $hash{'goesto_'.$_});
}
- pop(@currentResource);
push(@currentResource, @nextResources);
- # Set the next resource to be popped(processed)
- $currentResourceID=$currentResource[-1];
+ # Set the next resource to be processed
+ $currentResourceID=pop(@currentResource);
}
unless (untie(%hash)) {
@@ -632,7 +668,8 @@ sub ProcessClassList {
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()) {
@@ -647,8 +684,6 @@ sub ProcessClassList {
$name,$courseID,$c);
}
- $CacheData{'NamesOfStudents'}=join(":::",@names);
-# $CacheData{'NamesOfStudents'}=&Apache::lonnet::arrayref2str(\@names);
untie(%CacheData);
}
@@ -727,12 +762,10 @@ sub ProcessFullName {
}
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;
@@ -769,7 +802,7 @@ sub SortStudents {
}
my @order = ();
- foreach my $key (sort keys(%sortData)) {
+ foreach my $key (sort(keys(%sortData))) {
push (@order,$sortData{$key});
}
@@ -822,6 +855,11 @@ sub ExtractStudentData {
foreach my $key (keys (%$courseData)) {
$CacheData{$name.':'.$key}=$courseData->{$key};
}
+ if(defined($CacheData{'NamesOfStudents'})) {
+ $CacheData{'NamesOfStudents'}.=':::'.$name;
+ } else {
+ $CacheData{'NamesOfStudents'}=$name;
+ }
}
untie(%CacheData);
}
@@ -855,6 +893,7 @@ sub BuildChart {
}
# 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');
@@ -878,17 +917,26 @@ sub BuildChart {
&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(''.(scalar @students).
' students
'); }
if(!$c->aborted()) { $r->rflush(); }
+# if(!$c->aborted()) { $r->print(&CreateColumnSelectors(
+# \%CacheData,
+# \@studentInformation,
+# \@headings,
+# $spacePadding)); }
if(!$c->aborted()) { $r->print(&CreateTableHeadings(
\%CacheData,
\@studentInformation,
@@ -935,7 +983,7 @@ sub BuildChart {
sub handler {
my $r=shift;
-# $jr=$r;
+ $jr=$r;
unless(&Apache::lonnet::allowed('vgr',$ENV{'request.course.id'})) {
$ENV{'user.error.msg'}=
$r->uri.":vgr:0:0:Cannot view grades for complete course";