Diff for /loncom/interface/loncoursedata.pm between versions 1.13 and 1.21

version 1.13, 2002/08/13 00:37:18 version 1.21, 2002/08/28 18:29:22
Line 61  use GDBM_File; Line 61  use GDBM_File;
   
 This section contains all the files that get data from other servers   This section contains all the files that get data from other servers 
 and/or itself.  There is one function that has a call to get remote  and/or itself.  There is one function that has a call to get remote
 information but isn't included here which is ProcessTopLevelMap.  The  information but is not included here which is ProcessTopLevelMap.  The
 usage was small enough to be ignored, but that portion may be moved  usage was small enough to be ignored, but that portion may be moved
 here in the future.  here in the future.
   
Line 79  collecting a classlist for the course th Line 79  collecting a classlist for the course th
   
 =over 4  =over 4
   
 Input: $courseID, $c  Input: $courseID, $lastDownloadTime, $c
   
 $courseID:  The id of the course  $courseID:  The id of the course
   
   $lastDownloadTime: I am not sure.
   
 $c: The connection class that can determine if the browser has aborted.  It  $c: The connection class that can determine if the browser has aborted.  It
 is used to short circuit this function so that it doesn't continue to   is used to short circuit this function so that it does not continue to 
 get information when there is no need.  get information when there is no need.
   
 Output: \%classlist  Output: \%classlist
Line 119  sub DownloadClasslist { Line 121  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)) {
         if($c->aborted()) {          if((defined($c) && ($c->aborted())) {
             $classlist{'error'}='aborted';              $classlist{'error'}='aborted';
             return \%classlist;              return \%classlist;
         }          }
Line 396  sub ProcessTopResourceMap { Line 399  sub ProcessTopResourceMap {
                         $beenHere{'o:'.$partId.$currentResourceID}++;                          $beenHere{'o:'.$partId.$currentResourceID}++;
                         if(defined($cache->{'OptionResponses'})) {                          if(defined($cache->{'OptionResponses'})) {
                             $cache->{'OptionResponses'}.= ':::'.                              $cache->{'OptionResponses'}.= ':::'.
                                 $currentResourceID.':'.                                  $currentSequence.':'.$currentResourceID.':'.
                                 $partId.':'.$responseId;                                  $partId.':'.$responseId;
                         } else {                          } else {
                             $cache->{'OptionResponses'}= $currentResourceID.                              $cache->{'OptionResponses'}= $currentSequence.':'.
                                 ':'.$partId.':'.$responseId;                                  $currentResourceID.':'.
                                   $partId.':'.$responseId;
                         }                          }
                     }                      }
                 }                  }
Line 545  sub ProcessClasslist { Line 549  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 559  sub ProcessClasslist { Line 562  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 680  sub ExtractStudentData { Line 687  sub ExtractStudentData {
     my $totalProblems   = 0;      my $totalProblems   = 0;
     my $problemsSolved  = 0;      my $problemsSolved  = 0;
     my $numberOfParts   = 0;      my $numberOfParts   = 0;
       my $totalAwarded    = 0;
     foreach my $sequence (split(':', $data->{'orderedSequences'})) {      foreach my $sequence (split(':', $data->{'orderedSequences'})) {
         foreach my $problemID (split(':', $data->{$sequence.':problems'})) {          foreach my $problemID (split(':', $data->{$sequence.':problems'})) {
             my $problem = $data->{$problemID.':problem'};              my $problem = $data->{$problemID.':problem'};
Line 691  sub ExtractStudentData { Line 699  sub ExtractStudentData {
                 foreach my $part (split(/\:/,$data->{$sequence.':'.                  foreach my $part (split(/\:/,$data->{$sequence.':'.
                                                       $problemID.                                                        $problemID.
                                                       ':parts'})) {                                                        ':parts'})) {
                       $output->{$name.':'.$problemID.':'.$part.':tries'} = 0;
                       $output->{$name.':'.$problemID.':'.$part.':awarded'} = 0;
                       $output->{$name.':'.$problemID.':'.$part.':code'} = ' ';
                     $totalProblems++;                      $totalProblems++;
                 }                  }
                 $output->{$name.':'.$problemID.':NoVersion'} = 'true';                  $output->{$name.':'.$problemID.':NoVersion'} = 'true';
Line 791  sub ExtractStudentData { Line 802  sub ExtractStudentData {
                     $partData{$part.':code'};                      $partData{$part.':code'};
                 $output->{$name.':'.$problemID.':'.$part.':awarded'} =                  $output->{$name.':'.$problemID.':'.$part.':awarded'} =
                     $partData{$part.':awarded'};                      $partData{$part.':awarded'};
                   $totalAwarded += $partData{$part.':awarded'};
                 $output->{$name.':'.$problemID.':'.$part.':timestamp'} =                  $output->{$name.':'.$problemID.':'.$part.':timestamp'} =
                     $partData{$part.':timestamp'};                      $partData{$part.':timestamp'};
                 foreach my $response (split(':', $data->{$sequence.':'.                  foreach my $response (split(':', $data->{$sequence.':'.
Line 813  sub ExtractStudentData { Line 825  sub ExtractStudentData {
   
     $output->{$name.':problemsSolved'} = $problemsSolved;      $output->{$name.':problemsSolved'} = $problemsSolved;
     $output->{$name.':totalProblems'} = $totalProblems;      $output->{$name.':totalProblems'} = $totalProblems;
       $output->{$name.':totalAwarded'} = $totalAwarded;
   
     return;      return;
 }  }
Line 1006  sub DownloadStudentCourseData { Line 1019  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 1055  sub DownloadStudentCourseData { Line 1073  sub DownloadStudentCourseData {
                 next;                  next;
             }              }
         }          }
         $count++;  
     }      }
     if($status eq 'true') { &Apache::lonhtmlcommon::Close_PrgWin($r); }      if($status eq 'true') { &Apache::lonhtmlcommon::Close_PrgWin($r); }
   
Line 1069  sub DownloadStudentCourseDataSeparate { Line 1086  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 1078  sub DownloadStudentCourseDataSeparate { Line 1095  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 1107  sub DownloadStudentCourseDataSeparate { Line 1121  sub DownloadStudentCourseDataSeparate {
         }          }
   
         if($c->aborted()) {          if($c->aborted()) {
             untie(%downloadData);  
             return 'Aborted';              return 'Aborted';
         }          }
   
Line 1116  sub DownloadStudentCourseDataSeparate { Line 1129  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 1129  sub DownloadStudentCourseDataSeparate { Line 1147  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 1143  sub CheckForResidualDownload { Line 1161  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 1177  sub CheckForResidualDownload { Line 1198  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 1186  sub CheckForResidualDownload { Line 1207  sub CheckForResidualDownload {
         } else {          } else {
             &ProcessStudentData(\%cache, \%downloadData, $name);              &ProcessStudentData(\%cache, \%downloadData, $name);
         }          }
         foreach (@dataKeys) {  
             if(/^$name/) {  
                 delete $downloadData{$_};  
             }  
         }  
         $count++;          $count++;
     }      }
   

Removed from v.1.13  
changed lines
  Added in v.1.21


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