Diff for /loncom/interface/loncoursedata.pm between versions 1.16 and 1.20

version 1.16, 2002/08/14 16:18:55 version 1.20, 2002/08/15 18:16:29
Line 119  sub DownloadClasslist { Line 119  sub DownloadClasslist {
     }      }
   
     %classlist=&Apache::lonnet::dump('classlist',$courseDomain, $courseNumber);      %classlist=&Apache::lonnet::dump('classlist',$courseDomain, $courseNumber);
     my ($checkForError)=keys (%classlist);      foreach(keys (%classlist)) {
     if($checkForError =~ /^(con_lost|error|no_such_host)/i) {          if(/^(con_lost|error|no_such_host)/i) {
         return \%classlist;              return \%classlist;
           }
     }      }
   
     foreach my $name (keys(%classlist)) {      foreach my $name (keys(%classlist)) {
Line 546  sub ProcessClasslist { Line 547  sub ProcessClasslist {
         if($c->aborted()) {          if($c->aborted()) {
             return ();              return ();
         }          }
         push(@names,$name);  
         my $studentInformation = $classlist->{$name.':studentInformation'},          my $studentInformation = $classlist->{$name.':studentInformation'},
         my $sectionData = $classlist->{$name.':sections'},          my $sectionData = $classlist->{$name.':sections'},
         my $date = $classlist->{$name},          my $date = $classlist->{$name},
Line 560  sub ProcessClasslist { Line 560  sub ProcessClasslist {
             $cache->{$name.':updateTime'}=' Not updated';              $cache->{$name.':updateTime'}=' Not updated';
         }          }
   
         my ($checkForError)=keys(%$studentInformation);          my $error = 0;
         if($checkForError =~ /^(con_lost|error|no_such_host)/i) {          foreach(keys(%$studentInformation)) {
             $cache->{$name.':error'}=              if(/^(con_lost|error|no_such_host)/i) {
                 'Could not download student environment data.';                  $cache->{$name.':error'}=
             $cache->{$name.':fullname'}='';                      'Could not download student environment data.';
             $cache->{$name.':id'}='';                  $cache->{$name.':fullname'}='';
         } else {                  $cache->{$name.':id'}='';
             $cache->{$name.':fullname'}=&ProcessFullName(                  $error = 1;
               }
           }
           next if($error);
           push(@names,$name);
           $cache->{$name.':fullname'}=&ProcessFullName(
                                           $studentInformation->{'lastname'},                                            $studentInformation->{'lastname'},
                                           $studentInformation->{'generation'},                                            $studentInformation->{'generation'},
                                           $studentInformation->{'firstname'},                                            $studentInformation->{'firstname'},
                                           $studentInformation->{'middlename'});                                            $studentInformation->{'middlename'});
             $cache->{$name.':id'}=$studentInformation->{'id'};          $cache->{$name.':id'}=$studentInformation->{'id'};
         }  
   
         my ($end, $start)=split(':',$date);          my ($end, $start)=split(':',$date);
         $courseID=~s/\_/\//g;          $courseID=~s/\_/\//g;
Line 1013  sub DownloadStudentCourseData { Line 1017  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 .= ')';
   #    $WhatIWant = '.';
   
     if($status eq 'true') {      if($status eq 'true') {
         &Apache::lonhtmlcommon::Create_PrgWin($r, $title, $heading);          &Apache::lonhtmlcommon::Create_PrgWin($r, $title, $heading);
     }      }
     my $count=1;  
       my $displayString;
       my $count=0;
     foreach (@$students) {      foreach (@$students) {
         if($c->aborted()) { return 'Aborted'; }          if($c->aborted()) { return 'Aborted'; }
   
         if($status eq 'true') {          if($status eq 'true') {
               $count++;
             my $displayString = $count.'/'.$studentCount.': '.$_;              my $displayString = $count.'/'.$studentCount.': '.$_;
             &Apache::lonhtmlcommon::Update_PrgWin($displayString, $r);              &Apache::lonhtmlcommon::Update_PrgWin($displayString, $r);
         }          }
Line 1062  sub DownloadStudentCourseData { Line 1071  sub DownloadStudentCourseData {
                 next;                  next;
             }              }
         }          }
         $count++;  
     }      }
     if($status eq 'true') { &Apache::lonhtmlcommon::Close_PrgWin($r); }      if($status eq 'true') { &Apache::lonhtmlcommon::Close_PrgWin($r); }
   
Line 1076  sub DownloadStudentCourseDataSeparate { Line 1084  sub DownloadStudentCourseDataSeparate {
     my $heading = 'Download Course Data';      my $heading = 'Download Course Data';
   
     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 1085  sub DownloadStudentCourseDataSeparate { Line 1093  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') {
         &Apache::lonhtmlcommon::Create_PrgWin($r, $title, $heading);          &Apache::lonhtmlcommon::Create_PrgWin($r, $title, $heading);
     }      }
     my $count=1;      my $count=0;
       my $displayString='';
     foreach (@$students) {      foreach (@$students) {
         if($c->aborted()) {          if($c->aborted()) {
             untie(%downloadData);  
             return 'Aborted';              return 'Aborted';
         }          }
   
         if($status eq 'true') {          if($status eq 'true') {
             my $displayString = $count.'/'.$studentCount.': '.$_;              $count++;
               $displayString = $count.'/'.$studentCount.': '.$_;
             &Apache::lonhtmlcommon::Update_PrgWin($displayString, $r);              &Apache::lonhtmlcommon::Update_PrgWin($displayString, $r);
         }          }
   
Line 1114  sub DownloadStudentCourseDataSeparate { Line 1119  sub DownloadStudentCourseDataSeparate {
         }          }
   
         if($c->aborted()) {          if($c->aborted()) {
             untie(%downloadData);  
             return 'Aborted';              return 'Aborted';
         }          }
   
Line 1123  sub DownloadStudentCourseDataSeparate { Line 1127  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 1136  sub DownloadStudentCourseDataSeparate { Line 1145  sub DownloadStudentCourseDataSeparate {
                 }                  }
                 $downloadData{$_.':error'} = 'No course data for '.$_;                  $downloadData{$_.':error'} = 'No course data for '.$_;
             }              }
               untie(%downloadData);
         }          }
         $count++;  
     }      }
     if($status eq 'true') { &Apache::lonhtmlcommon::Close_PrgWin($r); }      if($status eq 'true') { &Apache::lonhtmlcommon::Close_PrgWin($r); }
   
Line 1150  sub CheckForResidualDownload { Line 1159  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;          return 'OK';
     }      }
   
     my %downloadData;      my %downloadData;
     my %cache;      my %cache;
     unless(tie(%downloadData,'GDBM_File',$residualFile,&GDBM_READER(),0640) &&      unless(tie(%downloadData,'GDBM_File',$residualFile,&GDBM_READER(),0640)) {
            tie(%cache,'GDBM_File',$cacheDB,&GDBM_WRCREAT(),0640)) {          return 'Can not tie database for check for residual download: tempDB';
         return;      }
       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 @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 1184  sub CheckForResidualDownload { Line 1196  sub CheckForResidualDownload {
         last if($c->aborted());          last if($c->aborted());
   
         if($status eq 'true') {          if($status eq 'true') {
             my $displayString = $count.'/'.$studentCount.': '.$_;              my $displayString = $count.'/'.$studentCount.': '.$name;
             &Apache::lonhtmlcommon::Update_PrgWin($displayString, $r);              &Apache::lonhtmlcommon::Update_PrgWin($displayString, $r);
         }          }
   
Line 1193  sub CheckForResidualDownload { Line 1205  sub CheckForResidualDownload {
         } else {          } else {
             &ProcessStudentData(\%cache, \%downloadData, $name);              &ProcessStudentData(\%cache, \%downloadData, $name);
         }          }
         foreach (@dataKeys) {  
             if(/^$name/) {  
                 delete $downloadData{$_};  
             }  
         }  
         $count++;          $count++;
     }      }
   

Removed from v.1.16  
changed lines
  Added in v.1.20


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