--- loncom/interface/loncoursedata.pm 2002/08/14 16:18:55 1.16 +++ loncom/interface/loncoursedata.pm 2002/08/15 18:16:29 1.20 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # (Publication Handler # -# $Id: loncoursedata.pm,v 1.16 2002/08/14 16:18:55 stredwic Exp $ +# $Id: loncoursedata.pm,v 1.20 2002/08/15 18:16:29 stredwic Exp $ # # Copyright Michigan State University Board of Trustees # @@ -119,9 +119,10 @@ sub DownloadClasslist { } %classlist=&Apache::lonnet::dump('classlist',$courseDomain, $courseNumber); - my ($checkForError)=keys (%classlist); - if($checkForError =~ /^(con_lost|error|no_such_host)/i) { - return \%classlist; + foreach(keys (%classlist)) { + if(/^(con_lost|error|no_such_host)/i) { + return \%classlist; + } } foreach my $name (keys(%classlist)) { @@ -546,7 +547,6 @@ sub ProcessClasslist { if($c->aborted()) { return (); } - push(@names,$name); my $studentInformation = $classlist->{$name.':studentInformation'}, my $sectionData = $classlist->{$name.':sections'}, my $date = $classlist->{$name}, @@ -560,20 +560,24 @@ sub ProcessClasslist { $cache->{$name.':updateTime'}=' Not updated'; } - my ($checkForError)=keys(%$studentInformation); - if($checkForError =~ /^(con_lost|error|no_such_host)/i) { - $cache->{$name.':error'}= - 'Could not download student environment data.'; - $cache->{$name.':fullname'}=''; - $cache->{$name.':id'}=''; - } else { - $cache->{$name.':fullname'}=&ProcessFullName( + my $error = 0; + foreach(keys(%$studentInformation)) { + if(/^(con_lost|error|no_such_host)/i) { + $cache->{$name.':error'}= + 'Could not download student environment data.'; + $cache->{$name.':fullname'}=''; + $cache->{$name.':id'}=''; + $error = 1; + } + } + next if($error); + push(@names,$name); + $cache->{$name.':fullname'}=&ProcessFullName( $studentInformation->{'lastname'}, $studentInformation->{'generation'}, $studentInformation->{'firstname'}, $studentInformation->{'middlename'}); - $cache->{$name.':id'}=$studentInformation->{'id'}; - } + $cache->{$name.':id'}=$studentInformation->{'id'}; my ($end, $start)=split(':',$date); $courseID=~s/\_/\//g; @@ -1013,21 +1017,26 @@ sub DownloadStudentCourseData { my $studentCount = scalar(@$students); my %cache; + my $WhatIWant; - $WhatIWant = '(^version:(\w|\/|\.|-)+?$|'; - $WhatIWant .= '^\d+:(\w|\/|\.|-)+?:(resource\.\d+\.'; + $WhatIWant = '(^version:|'; + $WhatIWant .= '^\d+:.+?:(resource\.\d+\.'; $WhatIWant .= '(solved|tries|previous|awarded|(\d+\.submission))\s*$'; $WhatIWant .= '|timestamp)'; $WhatIWant .= ')'; +# $WhatIWant = '.'; if($status eq 'true') { &Apache::lonhtmlcommon::Create_PrgWin($r, $title, $heading); } - my $count=1; + + my $displayString; + my $count=0; foreach (@$students) { if($c->aborted()) { return 'Aborted'; } if($status eq 'true') { + $count++; my $displayString = $count.'/'.$studentCount.': '.$_; &Apache::lonhtmlcommon::Update_PrgWin($displayString, $r); } @@ -1062,7 +1071,6 @@ sub DownloadStudentCourseData { next; } } - $count++; } if($status eq 'true') { &Apache::lonhtmlcommon::Close_PrgWin($r); } @@ -1076,8 +1084,8 @@ sub DownloadStudentCourseDataSeparate { my $heading = 'Download Course Data'; my $WhatIWant; - $WhatIWant = '(^version:(\w|\/|\.|-)+?$|'; - $WhatIWant .= '^\d+:(\w|\/|\.|-)+?:(resource\.\d+\.'; + $WhatIWant = '(^version:|'; + $WhatIWant .= '^\d+:.+?:(resource\.\d+\.'; $WhatIWant .= '(solved|tries|previous|awarded|(\d+\.submission))\s*$'; $WhatIWant .= '|timestamp)'; $WhatIWant .= ')'; @@ -1085,24 +1093,21 @@ sub DownloadStudentCourseDataSeparate { &CheckForResidualDownload($courseID, $cacheDB, $students, $c); my %cache; - my %downloadData; - unless(tie(%downloadData,'GDBM_File',$residualFile,&GDBM_NEWDB(),0640)) { - return 'Failed to tie temporary download hash.'; - } my $studentCount = scalar(@$students); if($status eq 'true') { &Apache::lonhtmlcommon::Create_PrgWin($r, $title, $heading); } - my $count=1; + my $count=0; + my $displayString=''; foreach (@$students) { if($c->aborted()) { - untie(%downloadData); return 'Aborted'; } if($status eq 'true') { - my $displayString = $count.'/'.$studentCount.': '.$_; + $count++; + $displayString = $count.'/'.$studentCount.': '.$_; &Apache::lonhtmlcommon::Update_PrgWin($displayString, $r); } @@ -1114,7 +1119,6 @@ sub DownloadStudentCourseDataSeparate { } if($c->aborted()) { - untie(%downloadData); return 'Aborted'; } @@ -1123,6 +1127,11 @@ sub DownloadStudentCourseDataSeparate { my $courseData = &DownloadCourseInformation($_, $courseID, $downloadTime, $WhatIWant); + my %downloadData; + unless(tie(%downloadData,'GDBM_File',$residualFile, + &GDBM_WRCREAT(),0640)) { + return 'Failed to tie temporary download hash.'; + } foreach my $key (keys(%$courseData)) { $downloadData{$key} = $courseData->{$key}; if($key =~ /^(con_lost|error|no_such_host)/i) { @@ -1136,8 +1145,8 @@ sub DownloadStudentCourseDataSeparate { } $downloadData{$_.':error'} = 'No course data for '.$_; } + untie(%downloadData); } - $count++; } if($status eq 'true') { &Apache::lonhtmlcommon::Close_PrgWin($r); } @@ -1150,21 +1159,24 @@ sub CheckForResidualDownload { my $residualFile = '/home/httpd/perl/tmp/'.$courseID.'DownloadFile.db'; if(!-e $residualFile) { - return; + return 'OK'; } my %downloadData; my %cache; - unless(tie(%downloadData,'GDBM_File',$residualFile,&GDBM_READER(),0640) && - tie(%cache,'GDBM_File',$cacheDB,&GDBM_WRCREAT(),0640)) { - return; + unless(tie(%downloadData,'GDBM_File',$residualFile,&GDBM_READER(),0640)) { + return 'Can not tie database for check for residual download: tempDB'; + } + unless(tie(%cache,'GDBM_File',$cacheDB,&GDBM_WRCREAT(),0640)) { + untie(%downloadData); + return 'Can not tie database for check for residual download: cacheDB'; } - my @dataKeys=keys(%downloadData); my @students=(); my %checkStudent; - foreach(@dataKeys) { - my @temp = split(':', $_); + my $key; + while(($key, undef) = each %downloadData) { + my @temp = split(':', $key); my $student = $temp[0].':'.$temp[1]; if(!defined($checkStudent{$student})) { $checkStudent{$student}++; @@ -1184,7 +1196,7 @@ sub CheckForResidualDownload { last if($c->aborted()); if($status eq 'true') { - my $displayString = $count.'/'.$studentCount.': '.$_; + my $displayString = $count.'/'.$studentCount.': '.$name; &Apache::lonhtmlcommon::Update_PrgWin($displayString, $r); } @@ -1193,11 +1205,6 @@ sub CheckForResidualDownload { } else { &ProcessStudentData(\%cache, \%downloadData, $name); } - foreach (@dataKeys) { - if(/^$name/) { - delete $downloadData{$_}; - } - } $count++; }