version 1.45, 2002/06/28 19:34:12
|
version 1.48, 2002/07/01 15:39:55
|
Line 55 use Apache::loncommon();
|
Line 55 use Apache::loncommon();
|
use HTML::TokeParser; |
use HTML::TokeParser; |
use GDBM_File; |
use GDBM_File; |
|
|
#my $jr; |
my $jr; |
# ----- FORMAT PRINT DATA ---------------------------------------------- |
# ----- FORMAT PRINT DATA ---------------------------------------------- |
|
|
sub FormatStudentInformation { |
sub FormatStudentInformation { |
Line 244 sub CreateTableHeadings {
|
Line 244 sub CreateTableHeadings {
|
return $Str; |
return $Str; |
} |
} |
|
|
|
sub CreateColumnSelectors { |
|
my ($CacheData,$studentInformation,$headings,$spacePadding)=@_; |
|
my $Str=''; |
|
|
|
$Str .= '<form name="stat" method="post" action="/adm/chart" >'."\n"; |
|
$Str .= '<input type="submit" name="sort" value="Refresh Chart"/>'; |
|
$Str .= '</form>'."\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 { |
sub CreateForm { |
my $OpSel1=''; |
my $OpSel1=''; |
my $OpSel2=''; |
my $OpSel2=''; |
Line 393 sub ProcessTopResourceMap {
|
Line 425 sub ProcessTopResourceMap {
|
my ($currentSequence, $currentResourceID, $lastResourceID); |
my ($currentSequence, $currentResourceID, $lastResourceID); |
|
|
$currentResourceID=$hash{'ids_/res/'.$ENV{'request.course.uri'}}; |
$currentResourceID=$hash{'ids_/res/'.$ENV{'request.course.uri'}}; |
|
push(@currentResource, $currentResourceID); |
$lastResourceID=-1; |
$lastResourceID=-1; |
$currentSequence=-1; |
$currentSequence=-1; |
my $topLevelSequenceNumber = $currentSequence; |
my $topLevelSequenceNumber = $currentSequence; |
Line 466 sub ProcessTopResourceMap {
|
Line 499 sub ProcessTopResourceMap {
|
if($currentResourceID eq $lastResourceID) { |
if($currentResourceID eq $lastResourceID) { |
#pop off last resource of sequence |
#pop off last resource of sequence |
$currentResourceID=pop(@currentResource); |
$currentResourceID=pop(@currentResource); |
#pop to get last resource in previous sequence |
|
$currentResourceID=pop(@currentResource); |
|
$lastResourceID=pop(@finishResource); |
$lastResourceID=pop(@finishResource); |
|
|
if(defined($CacheData{$currentSequence.':problems'})) { |
if(defined($CacheData{$currentSequence.':problems'})) { |
Line 482 sub ProcessTopResourceMap {
|
Line 513 sub ProcessTopResourceMap {
|
$hash{'title_'.$currentResourceID}; |
$hash{'title_'.$currentResourceID}; |
|
|
my $totalProblems=0; |
my $totalProblems=0; |
foreach (split(/\:/,$CacheData{$currentSequence. |
foreach my $currentProblem (split(/\:/, |
|
$CacheData{$currentSequence. |
':problems'})) { |
':problems'})) { |
foreach ($CacheData{$currentSequence.':'.$_.':parts'}) { |
foreach (split(/\:/,$CacheData{$currentSequence.':'. |
|
$currentProblem. |
|
':parts'})) { |
$totalProblems++; |
$totalProblems++; |
} |
} |
} |
} |
Line 519 sub ProcessTopResourceMap {
|
Line 553 sub ProcessTopResourceMap {
|
foreach (split(/\,/,$hash{'to_'.$currentResourceID})) { |
foreach (split(/\,/,$hash{'to_'.$currentResourceID})) { |
push(@nextResources, $hash{'goesto_'.$_}); |
push(@nextResources, $hash{'goesto_'.$_}); |
} |
} |
pop(@currentResource); |
|
push(@currentResource, @nextResources); |
push(@currentResource, @nextResources); |
# Set the next resource to be popped(processed) |
# Set the next resource to be processed |
$currentResourceID=$currentResource[-1]; |
$currentResourceID=pop(@currentResource); |
} |
} |
|
|
unless (untie(%hash)) { |
unless (untie(%hash)) { |
Line 635 sub ProcessClassList {
|
Line 668 sub ProcessClassList {
|
my %CacheData; |
my %CacheData; |
if(tie(%CacheData,'GDBM_File',$ChartDB,&GDBM_WRCREAT,0640)) { |
if(tie(%CacheData,'GDBM_File',$ChartDB,&GDBM_WRCREAT,0640)) { |
foreach my $name (keys(%$classlist)) { |
foreach my $name (keys(%$classlist)) { |
if($name =~ /\:section/ || $name =~ /\:studentInformation/) { |
if($name =~ /\:section/ || $name =~ /\:studentInformation/ || |
|
$name eq '') { |
next; |
next; |
} |
} |
if($c->aborted()) { |
if($c->aborted()) { |
Line 650 sub ProcessClassList {
|
Line 684 sub ProcessClassList {
|
$name,$courseID,$c); |
$name,$courseID,$c); |
} |
} |
|
|
$CacheData{'NamesOfStudents'}=join(":::",@names); |
|
# $CacheData{'NamesOfStudents'}=&Apache::lonnet::arrayref2str(\@names); |
|
untie(%CacheData); |
untie(%CacheData); |
} |
} |
|
|
Line 730 sub ProcessFullName {
|
Line 762 sub ProcessFullName {
|
} |
} |
|
|
sub SortStudents { |
sub SortStudents { |
my ($CacheData)=@_; |
my ($students,$CacheData)=@_; |
my @students = split(/:::/,$CacheData->{'NamesOfStudents'}); |
|
# my @students=&Apache::lonnet::str2array($CacheData->{'NamesOfStudents'}); |
|
|
|
my @sorted1Students=(); |
my @sorted1Students=(); |
foreach (@students) { |
foreach (@$students) { |
my ($end,$start)=split(/\:/,$CacheData->{$_.':date'}); |
my ($end,$start)=split(/\:/,$CacheData->{$_.':date'}); |
my $active=1; |
my $active=1; |
my $now=time; |
my $now=time; |
Line 772 sub SortStudents {
|
Line 802 sub SortStudents {
|
} |
} |
|
|
my @order = (); |
my @order = (); |
foreach my $key (sort keys(%sortData)) { |
foreach my $key (sort(keys(%sortData))) { |
push (@order,$sortData{$key}); |
push (@order,$sortData{$key}); |
} |
} |
|
|
Line 825 sub ExtractStudentData {
|
Line 855 sub ExtractStudentData {
|
foreach my $key (keys (%$courseData)) { |
foreach my $key (keys (%$courseData)) { |
$CacheData{$name.':'.$key}=$courseData->{$key}; |
$CacheData{$name.':'.$key}=$courseData->{$key}; |
} |
} |
|
if(defined($CacheData{'NamesOfStudents'})) { |
|
$CacheData{'NamesOfStudents'}.=':::'.$name; |
|
} else { |
|
$CacheData{'NamesOfStudents'}=$name; |
|
} |
} |
} |
untie(%CacheData); |
untie(%CacheData); |
} |
} |
Line 858 sub BuildChart {
|
Line 893 sub BuildChart {
|
} |
} |
|
|
# Download class list information if not using cached data |
# Download class list information if not using cached data |
|
my %CacheData; |
my @students=(); |
my @students=(); |
my @studentInformation=('username','domain','section','id','fullname'); |
my @studentInformation=('username','domain','section','id','fullname'); |
my @headings=('User Name','Domain','Section','PID','Full Name'); |
my @headings=('User Name','Domain','Section','PID','Full Name'); |
Line 881 sub BuildChart {
|
Line 917 sub BuildChart {
|
&SpaceColumns(\@students,\@studentInformation,\@headings, |
&SpaceColumns(\@students,\@studentInformation,\@headings, |
$ChartDB); |
$ChartDB); |
if($c->aborted()) { return; } |
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 |
# Sort students and print out table desciptive data |
my %CacheData; |
|
if(tie(%CacheData,'GDBM_File',$ChartDB,&GDBM_READER,0640)) { |
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(&CreateLegend()); } |
if(!$c->aborted()) { $r->print(&CreateForm()); } |
if(!$c->aborted()) { $r->print(&CreateForm()); } |
if(!$c->aborted()) { $r->print('<h3>'.(scalar @students). |
if(!$c->aborted()) { $r->print('<h3>'.(scalar @students). |
' students</h3>'); } |
' students</h3>'); } |
if(!$c->aborted()) { $r->rflush(); } |
if(!$c->aborted()) { $r->rflush(); } |
|
# if(!$c->aborted()) { $r->print(&CreateColumnSelectors( |
|
# \%CacheData, |
|
# \@studentInformation, |
|
# \@headings, |
|
# $spacePadding)); } |
if(!$c->aborted()) { $r->print(&CreateTableHeadings( |
if(!$c->aborted()) { $r->print(&CreateTableHeadings( |
\%CacheData, |
\%CacheData, |
\@studentInformation, |
\@studentInformation, |
Line 938 sub BuildChart {
|
Line 983 sub BuildChart {
|
|
|
sub handler { |
sub handler { |
my $r=shift; |
my $r=shift; |
# $jr=$r; |
$jr=$r; |
unless(&Apache::lonnet::allowed('vgr',$ENV{'request.course.id'})) { |
unless(&Apache::lonnet::allowed('vgr',$ENV{'request.course.id'})) { |
$ENV{'user.error.msg'}= |
$ENV{'user.error.msg'}= |
$r->uri.":vgr:0:0:Cannot view grades for complete course"; |
$r->uri.":vgr:0:0:Cannot view grades for complete course"; |