Diff for /loncom/interface/loncoursedata.pm between versions 1.17 and 1.18

version 1.17, 2002/08/14 21:51:51 version 1.18, 2002/08/15 16:03:11
Line 1013  sub DownloadStudentCourseData { Line 1013  sub DownloadStudentCourseData {
     my $studentCount = scalar(@$students);      my $studentCount = scalar(@$students);
     my %cache;      my %cache;
   
   
     my $WhatIWant;      my $WhatIWant;
     $WhatIWant = '(^version:(\w|\/|\.|-)+?$|';      $WhatIWant = '(^version:.+?$|';
     $WhatIWant .= '^\d+:(\w|\/|\.|-)+?:(resource\.\d+\.';      $WhatIWant .= '^\d+:.+?:(resource\.\d+\.';
     $WhatIWant .= '(solved|tries|previous|awarded|(\d+\.submission))\s*$';      $WhatIWant .= '(solved|tries|previous|awarded|(\d+\.submission))\s*$';
     $WhatIWant .= '|timestamp)';      $WhatIWant .= '|timestamp)';
     $WhatIWant .= ')';      $WhatIWant .= ')';
Line 1077  sub DownloadStudentCourseDataSeparate { Line 1078  sub DownloadStudentCourseDataSeparate {
     my $title = 'LON-CAPA Statistics';      my $title = 'LON-CAPA Statistics';
     my $heading = 'Download Course Data';      my $heading = 'Download Course Data';
   
   #    my $WhatIWant = '.';
     my $WhatIWant;      my $WhatIWant;
     $WhatIWant = '(^version:(\w|\/|\.|-)+?$|';      $WhatIWant = '(^version:.+?$|';
     $WhatIWant .= '^\d+:(\w|\/|\.|-)+?:(resource\.\d+\.';      $WhatIWant .= '^\d+:.+?:(resource\.\d+\.';
     $WhatIWant .= '(solved|tries|previous|awarded|(\d+\.submission))\s*$';      $WhatIWant .= '(solved|tries|previous|awarded|(\d+\.submission))\s*$';
     $WhatIWant .= '|timestamp)';      $WhatIWant .= '|timestamp)';
     $WhatIWant .= ')';      $WhatIWant .= ')';
Line 1087  sub DownloadStudentCourseDataSeparate { Line 1089  sub DownloadStudentCourseDataSeparate {
     &CheckForResidualDownload($courseID, $cacheDB, $students, $c);      &CheckForResidualDownload($courseID, $cacheDB, $students, $c);
   
     my %cache;      my %cache;
     my %downloadData;  
     unless(tie(%downloadData,'GDBM_File',$residualFile,&GDBM_NEWDB(),0640)) {  
         return 'Failed to tie temporary download hash.';  
     }  
   
     my $studentCount = scalar(@$students);      my $studentCount = scalar(@$students);
     if($status eq 'true') {      if($status eq 'true') {
Line 1100  sub DownloadStudentCourseDataSeparate { Line 1098  sub DownloadStudentCourseDataSeparate {
     my $displayString='';      my $displayString='';
     foreach (@$students) {      foreach (@$students) {
         if($c->aborted()) {          if($c->aborted()) {
             untie(%downloadData);  
             return 'Aborted';              return 'Aborted';
         }          }
   
Line 1118  sub DownloadStudentCourseDataSeparate { Line 1115  sub DownloadStudentCourseDataSeparate {
         }          }
   
         if($c->aborted()) {          if($c->aborted()) {
             untie(%downloadData);  
             return 'Aborted';              return 'Aborted';
         }          }
   
Line 1127  sub DownloadStudentCourseDataSeparate { Line 1123  sub DownloadStudentCourseDataSeparate {
             my $courseData =               my $courseData = 
                 &DownloadCourseInformation($_, $courseID, $downloadTime,                  &DownloadCourseInformation($_, $courseID, $downloadTime,
                                            $WhatIWant);                                             $WhatIWant);
               my %downloadData;
               unless(tie(%downloadData,'GDBM_File',$residualFile,
                          &GDBM_WRCREAT(),0640)) {
                   return 'Failed to tie temporary download hash.';
               }
             foreach my $key (keys(%$courseData)) {              foreach my $key (keys(%$courseData)) {
                 $downloadData{$key} = $courseData->{$key};                  $downloadData{$key} = $courseData->{$key};
                 if($key =~ /^(con_lost|error|no_such_host)/i) {                  if($key =~ /^(con_lost|error|no_such_host)/i) {
Line 1140  sub DownloadStudentCourseDataSeparate { Line 1141  sub DownloadStudentCourseDataSeparate {
                 }                  }
                 $downloadData{$_.':error'} = 'No course data for '.$_;                  $downloadData{$_.':error'} = 'No course data for '.$_;
             }              }
               untie(%downloadData);
         }          }
     }      }
     if($status eq 'true') { &Apache::lonhtmlcommon::Close_PrgWin($r); }      if($status eq 'true') { &Apache::lonhtmlcommon::Close_PrgWin($r); }
   
     untie(%downloadData);  
     return &CheckForResidualDownload($cacheDB, 'true', 'true',       return &CheckForResidualDownload($cacheDB, 'true', 'true', 
                                      $courseID, $r, $c);                                       $courseID, $r, $c);
 }  }
Line 1154  sub CheckForResidualDownload { Line 1155  sub CheckForResidualDownload {
   
     my $residualFile = '/home/httpd/perl/tmp/'.$courseID.'DownloadFile.db';      my $residualFile = '/home/httpd/perl/tmp/'.$courseID.'DownloadFile.db';
     if(!-e $residualFile) {      if(!-e $residualFile) {
         return 'File does not exist';          return 'OK';
     }      }
   
     my %downloadData;      my %downloadData;
Line 1167  sub CheckForResidualDownload { Line 1168  sub CheckForResidualDownload {
         return 'Can not tie database for check for residual download: cacheDB';          return 'Can not tie database for check for residual download: cacheDB';
     }      }
   
     my @dataKeys=keys(%downloadData);  
     my @students=();      my @students=();
     my %checkStudent;      my %checkStudent;
     foreach(@dataKeys) {      my $key;
         my @temp = split(':', $_);      while(($key, undef) = each %downloadData) {
           my @temp = split(':', $key);
         my $student = $temp[0].':'.$temp[1];          my $student = $temp[0].':'.$temp[1];
         if(!defined($checkStudent{$student})) {          if(!defined($checkStudent{$student})) {
             $checkStudent{$student}++;              $checkStudent{$student}++;
Line 1200  sub CheckForResidualDownload { Line 1201  sub CheckForResidualDownload {
         } else {          } else {
             &ProcessStudentData(\%cache, \%downloadData, $name);              &ProcessStudentData(\%cache, \%downloadData, $name);
         }          }
         foreach (@dataKeys) {  
             if(/^$name/) {  
                 delete $downloadData{$_};  
             }  
         }  
         $count++;          $count++;
     }      }
   

Removed from v.1.17  
changed lines
  Added in v.1.18


FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>