Diff for /loncom/interface/multidownload.pl between versions 1.38 and 1.40

version 1.38, 2008/12/30 23:18:24 version 1.40, 2017/11/03 18:08:54
Line 74  sub get_part_resp_path { Line 74  sub get_part_resp_path {
 $|=1;  $|=1;
 &Apache::lonlocal::get_language_handle();  &Apache::lonlocal::get_language_handle();
 &Apache::loncommon::content_type(undef,'text/html');  &Apache::loncommon::content_type(undef,'text/html');
   my ($nocookie,$identifier,$unique_path,$scope);
 if (! &LONCAPA::loncgi::check_cookie_and_load_env()) {  if (! &LONCAPA::loncgi::check_cookie_and_load_env()) {
     print(&LONCAPA::loncgi::missing_cookie_msg());      print(&LONCAPA::loncgi::missing_cookie_msg());
     return;      $nocookie = 1;
 }  }
   
 my $identifier = $ENV{'QUERY_STRING'};  unless ($nocookie) {
 my $unique_path = $identifier.time();      $scope = $env{'request.course.id'};
 print(&Apache::loncommon::start_page('Multiple Downloads'));      if ($env{'request.course.sec'}) {
               $scope .= '/'.$env{'request.course.sec'};
       }
 my $scope = $env{'request.course.id'};      if ($ENV{'QUERY_STRING'} =~ /^\d+_\d+_\d+$/) {
 if ($env{'request.course.sec'}) {          $identifier = $ENV{'QUERY_STRING'};
     $scope .= '/'.$env{'request.course.sec'};          $unique_path = $identifier.time();
       }
       print(&Apache::loncommon::start_page('Multiple Downloads'));
 }  }
 if (&Apache::lonnet::allowed('vgr',$scope) eq 'F') {  if ($scope eq '') {
       print(&mt('Invalid course context: you need to reselect your course role.'));
   } elsif ($identifier eq '') {
       unless ($nocookie) {
           if (&Apache::lonnet::allowed('vgr',$scope) eq 'F') {
               print(&mt('Invalid query string; unable to download submissions.'));
           } else {
               print(&mt('You are not authorized to download student submissions.'));
           }
       }
   } elsif (&Apache::lonnet::allowed('vgr',$scope) eq 'F') {
     my $symb = $env{'cgi.'.$identifier.'.symb'};      my $symb = $env{'cgi.'.$identifier.'.symb'};
     my $navmap = Apache::lonnavmaps::navmap->new();      my $navmap = Apache::lonnavmaps::navmap->new();
     my $res = $navmap->getBySymb($symb);      my $res = $navmap->getBySymb($symb);
Line 100  if (&Apache::lonnet::allowed('vgr',$scop Line 113  if (&Apache::lonnet::allowed('vgr',$scop
     my $courseid = $env{'request.course.id'};      my $courseid = $env{'request.course.id'};
     my @stuchecked = split(/\n/,$env{'cgi.'.$identifier.'.students'});      my @stuchecked = split(/\n/,$env{'cgi.'.$identifier.'.students'});
     my $number_of_students = scalar(@stuchecked);      my $number_of_students = scalar(@stuchecked);
     my %prog_state=&Apache::lonhtmlcommon::Create_PrgWin('','Processing Status',      my %prog_state=&Apache::lonhtmlcommon::Create_PrgWin('',$number_of_students);
                                                     'Preparing Zip File',$number_of_students,'inline','80');  
     my @parts = split(/\n/,$env{'cgi.'.$identifier.'.parts'});      my @parts = split(/\n/,$env{'cgi.'.$identifier.'.parts'});
     my $doc_zip_root = $Apache::lonnet::perlvar{'lonZipDir'};      my $doc_zip_root = $Apache::lonnet::perlvar{'lonZipDir'};
     my $uname = $env{'user.name'};      my $uname = $env{'user.name'};
     my $udom = $env{'user.domain'};      my $udom = $env{'user.domain'};
     my $unique_user = $uname.":".$udom;      my $unique_user = $uname.":".$udom;
       my $manifest;
     &mkpath($doc_zip_root."/zipdir/$unique_user/$unique_path",0,0700);      &mkpath($doc_zip_root."/zipdir/$unique_user/$unique_path",0,0700);
     if (!open(MANIFEST, ">$doc_zip_root/zipdir/$unique_user/$unique_path/manifest.txt")) {      if (open(MANIFEST, ">$doc_zip_root/zipdir/$unique_user/$unique_path/manifest.txt")) {
           $manifest = 1;
           print MANIFEST (&mt("Zip file generated on [_1]",&Apache::lonlocal::locallocaltime(time()))."\n");
           print MANIFEST (&mt("Course: [_1]",$env{"course.$courseid.description"})."\n");
           print MANIFEST (&mt("Problem: [_1]",$res->compTitle)."\n");
           print MANIFEST (&mt("Files contained in this zip:")."\n");
       } else {
         &Apache::lonnet::logthis("Problem making manifest");          &Apache::lonnet::logthis("Problem making manifest");
     }      }
     print MANIFEST (&mt("Zip file generated on [_1]",&Apache::lonlocal::locallocaltime(time()))."\n");  
     print MANIFEST (&mt("Course: [_1]",$env{"course.$courseid.description"})."\n");  
     print MANIFEST (&mt("Problem: [_1]",$res->compTitle)."\n");  
     print MANIFEST (&mt("Files contained in this zip:")."\n");  
     my $file_problem = 0;      my $file_problem = 0;
     my $current_student = 0;      my $current_student = 0;
     foreach my $stu (@stuchecked) {      foreach my $stu (@stuchecked) {
         $current_student ++;          $current_student ++;
         &Apache::lonhtmlcommon::Update_PrgWin('',\%prog_state,"Processing student $current_student of $number_of_students");          &Apache::lonhtmlcommon::Update_PrgWin('',\%prog_state,&mt("Processing student [_1] of [_2]",$current_student,$number_of_students));
         my %files_saved;          my %files_saved;
         my ($stuname,$studom,$fullname) = split(/:/,$stu);          my ($stuname,$studom,$fullname) = split(/:/,$stu);
         my %record = &Apache::lonnet::restore($symb,$courseid,$studom,$stuname);          my %record = &Apache::lonnet::restore($symb,$courseid,$studom,$stuname);
         my $port_url = '/uploaded/'.$studom.'/'.$stuname.'/portfolio';          my $port_url = '/uploaded/'.$studom.'/'.$stuname.'/portfolio';
         print MANIFEST ($fullname."\n");          if ($manifest) {
               print MANIFEST ($fullname."\n");
           }
                     
         my $submission_count = 0;          my $submission_count = 0;
         foreach my $partid (@$partlist) {          foreach my $partid (@$partlist) {
Line 146  if (&Apache::lonnet::allowed('vgr',$scop Line 163  if (&Apache::lonnet::allowed('vgr',$scop
                             $file = $port_url.$file;                              $file = $port_url.$file;
                         }                          }
                         my ($file_name_only) = ($file =~ m{.*/([^/]+)$});                          my ($file_name_only) = ($file =~ m{.*/([^/]+)$});
                         print MANIFEST ("\t$file_name_only (".&mt("Part [_1]",$partid).                          if ($manifest) {
                                         ") (".&mt("Response [_1]",$respid).")"."\n");                              print MANIFEST ("\t$file_name_only (".&mt("Part [_1]",$partid).
                                               ") (".&mt("Response [_1]",$respid).")"."\n");
                           }
                         $submission_count ++;                          $submission_count ++;
                         &Apache::lonnet::repcopy($file);                          &Apache::lonnet::repcopy($file);
                         my $source = &Apache::lonnet::filelocation("",$file);                          my $source = &Apache::lonnet::filelocation("",$file);
Line 171  if (&Apache::lonnet::allowed('vgr',$scop Line 190  if (&Apache::lonnet::allowed('vgr',$scop
                 }                  }
             }              }
         }          }
         if (!$submission_count) {          if ((!$submission_count) && ($manifest)) {
             print MANIFEST ("\t".&mt("No Files Submitted")."\n");              print MANIFEST ("\t".&mt("No Files Submitted")."\n");
         }          }
     }      }
Line 191  if (&Apache::lonnet::allowed('vgr',$scop Line 210  if (&Apache::lonnet::allowed('vgr',$scop
     &Apache::lonhtmlcommon::Close_PrgWin('',\%prog_state);      &Apache::lonhtmlcommon::Close_PrgWin('',\%prog_state);
     print('<p><a href="/zipspool/zipout/'.$unique_user.'/'.$zipout.'">'.      print('<p><a href="/zipspool/zipout/'.$unique_user.'/'.$zipout.'">'.
             &mt("Click to download").'</a></p><br />');              &mt("Click to download").'</a></p><br />');
     close(MANIFEST);      if ($manifest) {
           close(MANIFEST);
       }
 } else {  } else {
     print(&mt('You are not authorized to download student submissions.'));      print(&mt('You are not authorized to download student submissions.'));
 }  }
   unless ($nocookie) {
       print(&Apache::loncommon::end_page());
   }
 1;  1;
 __END__;  __END__;

Removed from v.1.38  
changed lines
  Added in v.1.40


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