Diff for /loncom/interface/multidownload.pl between versions 1.1 and 1.6

version 1.1, 2007/03/30 22:57:39 version 1.6, 2007/04/26 17:36:10
Line 40  use Apache::grades; Line 40  use Apache::grades;
 use Apache::loncommon();  use Apache::loncommon();
 use Apache::lonlocal;  use Apache::lonlocal;
 use Apache::lonmsg();  use Apache::lonmsg();
   use Apache::lonnet;
 use LONCAPA::Enrollment;  use LONCAPA::Enrollment;
   
 use strict;  use strict;
   
   
 $|=1;  $|=1;
 if (! &LONCAPA::loncgi::check_cookie_and_load_env()) {  if (! &LONCAPA::loncgi::check_cookie_and_load_env()) {
     print <<END;      print <<END;
Line 63  END Line 62  END
 &Apache::loncommon::content_type(undef,'text/html');  &Apache::loncommon::content_type(undef,'text/html');
 my $identifier = $ENV{'QUERY_STRING'};  my $identifier = $ENV{'QUERY_STRING'};
 print(&Apache::loncommon::start_page('Multiple Downloads'));  print(&Apache::loncommon::start_page('Multiple Downloads'));
 my $symb = $env{'cgi.'.$identifier.'.symb'};  
 my $courseid = $env{'cgi.'.$identifier.'.courseid'};  my $scope = $env{'request.course.id'};
 my @stuchecked = split /\n/,$env{'cgi.'.$identifier.'.students'};  if ($env{'request.course.sec'}) {
 my @parts = split /\n/,$env{'cgi.'.$identifier.'.parts'};      $scope .= '/'.$env{'request.course.sec'};
 my ($partlist,$handgrade,$responseType) = &Apache::grades::response_type($symb);  }
 my @part_response_id = &Apache::grades::flatten_responseType($responseType);  if (&Apache::lonnet::allowed('vgr',$scope) eq 'F') {
 print "number of parts is: ".@parts."<br />";      my $symb = $env{'cgi.'.$identifier.'.symb'};
 my ($partlist,$handgrade,$responseType) = &Apache::grades::response_type($symb);      my $courseid = $env{'request.course.id'};
 print "in the CGI script <br />";      my @stuchecked = split(/\n/,$env{'cgi.'.$identifier.'.students'});
 foreach (@stuchecked) {      my @parts = split(/\n/,$env{'cgi.'.$identifier.'.parts'});
     my ($uname,$udom,$fullname) = split(/:/);      my ($partlist,$handgrade,$responseType) = &Apache::grades::response_type($symb);
     my %record = &Apache::lonnet::restore($symb,$courseid,$udom,$uname);      my @part_response_id = &Apache::grades::flatten_responseType($responseType);
     print $uname."<br />";      my $doc_zip_root = $Apache::lonnet::perlvar{'lonZipDir'};
     foreach my $part(@part_response_id) {      my ($partlist,$handgrade,$responseType) = &Apache::grades::response_type($symb);
         print $part."<br />";      my $uname = $env{'user.name'};
         my ($partid,$respid) = @{ $part };      my $udom = $env{'user.domain'};
         my $files = &Apache::grades::get_submitted_files($udom,$uname,$partid,$respid,\%record);      mkdir($doc_zip_root."/zipdir",0700);
         foreach my $file(@$files) {      mkdir($doc_zip_root."/zipdir/$uname$udom",0700);
             print $file."<br />";      foreach my $stu (@stuchecked) {
           my ($stuname,$studom,$fullname) = split(/:/,$stu);
           mkdir($doc_zip_root."/zipdir/$uname$udom/$stuname",0700);
           my %record = &Apache::lonnet::restore($symb,$courseid,$studom,$stuname);
           foreach my $part (@part_response_id) {
               my ($partid,$respid) = @{$part};
               mkdir($doc_zip_root."/zipdir/$uname$udom/$stuname/part$partid",0700);
               mkdir($doc_zip_root."/zipdir/$uname$udom/$stuname/part$partid/resp$respid",0700);
               my $files = &Apache::grades::get_submitted_files($studom,$stuname,$partid,$respid,\%record);
               foreach my $file (@$files) {
                   $file =~ /(^.*\/)(.+$)/;
                   my $file_name_only = $2;
                   my $file_content = &Apache::lonnet::getfile($file);
                   if (open(my $fh,">$doc_zip_root/zipdir/$uname$udom/$stuname/part$partid/resp$respid/$file_name_only")) {
                       print($fh $file_content);
                       close($fh);
                   } else {
                       print("problem creating file <br />");
                   }
               }
         }          }
     }      }
       mkdir($doc_zip_root."/zipout",0777);
       my $statement = "zip -r $doc_zip_root/zipout/output.zip $doc_zip_root/zipdir/$uname$udom/* > /dev/null";
       system($statement);
       $statement = "rm -rf $doc_zip_root/zipdir/$uname$udom";
       system($statement);
       print('<a href="/zipspool/zipout/output.zip">Click to download</a><br />');
   } else {
       print('You are not authorized to download student submissions.');
 }  }
   1;
 die;  __END__;

Removed from v.1.1  
changed lines
  Added in v.1.6


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