--- loncom/interface/loncoursedata.pm 2002/08/14 21:51:51 1.17 +++ loncom/interface/loncoursedata.pm 2002/08/15 16:11:34 1.19 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # (Publication Handler # -# $Id: loncoursedata.pm,v 1.17 2002/08/14 21:51:51 stredwic Exp $ +# $Id: loncoursedata.pm,v 1.19 2002/08/15 16:11:34 stredwic Exp $ # # Copyright Michigan State University Board of Trustees # @@ -201,6 +201,7 @@ sub DownloadCourseInformation { if(!defined($WhatIWant)) { $WhatIWant = '.'; } + $WhatIWant = '.'; %courseData=&Apache::lonnet::dump($courseID, $domain, $name, $WhatIWant); $courseData{'UpToDate'} = 'false'; $courseData{'lastDownloadTime'}=time; @@ -1013,9 +1014,10 @@ 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 .= ')'; @@ -1077,9 +1079,10 @@ sub DownloadStudentCourseDataSeparate { my $title = 'LON-CAPA Statistics'; my $heading = 'Download Course Data'; +# my $WhatIWant = '.'; 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 .= ')'; @@ -1087,10 +1090,6 @@ 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') { @@ -1100,7 +1099,6 @@ sub DownloadStudentCourseDataSeparate { my $displayString=''; foreach (@$students) { if($c->aborted()) { - untie(%downloadData); return 'Aborted'; } @@ -1118,7 +1116,6 @@ sub DownloadStudentCourseDataSeparate { } if($c->aborted()) { - untie(%downloadData); return 'Aborted'; } @@ -1127,6 +1124,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) { @@ -1140,11 +1142,11 @@ sub DownloadStudentCourseDataSeparate { } $downloadData{$_.':error'} = 'No course data for '.$_; } + untie(%downloadData); } } if($status eq 'true') { &Apache::lonhtmlcommon::Close_PrgWin($r); } - untie(%downloadData); return &CheckForResidualDownload($cacheDB, 'true', 'true', $courseID, $r, $c); } @@ -1154,7 +1156,7 @@ sub CheckForResidualDownload { my $residualFile = '/home/httpd/perl/tmp/'.$courseID.'DownloadFile.db'; if(!-e $residualFile) { - return 'File does not exist'; + return 'OK'; } my %downloadData; @@ -1167,11 +1169,11 @@ sub CheckForResidualDownload { 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}++; @@ -1186,12 +1188,12 @@ sub CheckForResidualDownload { &Apache::lonhtmlcommon::Create_PrgWin($r, $title, $heading); } - my $count=1; + my c$ount=1; foreach my $name (@students) { last if($c->aborted()); if($status eq 'true') { - my $displayString = $count.'/'.$studentCount.': '.$_; + my $displayString = $count.'/'.$studentCount.': '.$name; &Apache::lonhtmlcommon::Update_PrgWin($displayString, $r); } @@ -1200,11 +1202,6 @@ sub CheckForResidualDownload { } else { &ProcessStudentData(\%cache, \%downloadData, $name); } - foreach (@dataKeys) { - if(/^$name/) { - delete $downloadData{$_}; - } - } $count++; }