version 1.1, 2007/03/30 22:57:39
|
version 1.4, 2007/04/25 00:32:49
|
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; |
|
|
|
sub is_student { |
|
return ($env{'request.role'}=~/^st\./); |
|
} |
|
|
$|=1; |
$|=1; |
if (! &LONCAPA::loncgi::check_cookie_and_load_env()) { |
if (! &LONCAPA::loncgi::check_cookie_and_load_env()) { |
Line 63 END
|
Line 66 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'}; |
$env{'request.role'} =~ m/^(.+)\./; |
my $courseid = $env{'cgi.'.$identifier.'.courseid'}; |
my $role = $1; |
my @stuchecked = split /\n/,$env{'cgi.'.$identifier.'.students'}; |
if ($role eq 'cc') { |
my @parts = split /\n/,$env{'cgi.'.$identifier.'.parts'}; |
my $symb = $env{'cgi.'.$identifier.'.symb'}; |
my ($partlist,$handgrade,$responseType) = &Apache::grades::response_type($symb); |
my $courseid = $env{'request.course.id'}; |
my @part_response_id = &Apache::grades::flatten_responseType($responseType); |
my @stuchecked = split(/\n/,$env{'cgi.'.$identifier.'.students'}); |
print "number of parts is: ".@parts."<br />"; |
my @parts = split(/\n/,$env{'cgi.'.$identifier.'.parts'}); |
my ($partlist,$handgrade,$responseType) = &Apache::grades::response_type($symb); |
my ($partlist,$handgrade,$responseType) = &Apache::grades::response_type($symb); |
print "in the CGI script <br />"; |
my @part_response_id = &Apache::grades::flatten_responseType($responseType); |
foreach (@stuchecked) { |
my $doc_zip_root = $Apache::lonnet::perlvar{'lonZipDir'}; |
my ($uname,$udom,$fullname) = split(/:/); |
my ($partlist,$handgrade,$responseType) = &Apache::grades::response_type($symb); |
my %record = &Apache::lonnet::restore($symb,$courseid,$udom,$uname); |
mkdir($doc_zip_root."/zipdir",0777); |
print $uname."<br />"; |
foreach my $stu (@stuchecked) { |
foreach my $part(@part_response_id) { |
my ($uname,$udom,$fullname) = split(/:/,$stu); |
print $part."<br />"; |
mkdir($doc_zip_root."/zipdir/$uname",0777); |
my ($partid,$respid) = @{ $part }; |
my %record = &Apache::lonnet::restore($symb,$courseid,$udom,$uname); |
my $files = &Apache::grades::get_submitted_files($udom,$uname,$partid,$respid,\%record); |
foreach my $part (@part_response_id) { |
foreach my $file(@$files) { |
my ($partid,$respid) = @{$part}; |
print $file."<br />"; |
mkdir($doc_zip_root."/zipdir/$uname/part$partid",0777); |
|
mkdir($doc_zip_root."/zipdir/$uname/part$partid/resp$respid",0777); |
|
my $files = &Apache::grades::get_submitted_files($udom,$uname,$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/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/* > /dev/null"; |
|
system($statement); |
|
$statement = "rm -rf $doc_zip_root/zipdir"; |
|
system($statement); |
|
print('<a href="../zipout/output.zip">Click to download</a><br />'); |
|
} else { |
|
print('You are not authorized to download student submissions.'); |
} |
} |
|
# print($env{'request.role'}.' == roles <br />'); |
die; |
return 1; |