--- loncom/homework/grades.pm 2007/01/04 14:59:57 1.386
+++ loncom/homework/grades.pm 2007/04/25 00:16:51 1.396
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# The LON-CAPA Grading handler
#
-# $Id: grades.pm,v 1.386 2007/01/04 14:59:57 raeburn Exp $
+# $Id: grades.pm,v 1.396 2007/04/25 00:16:51 banghart Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -117,8 +117,12 @@ sub response_type {
my $navmap = Apache::lonnavmaps::navmap->new();
my $res = $navmap->getBySymb($symb);
my $partlist = $res->parts();
+ my %vPart =
+ map { $_ => 1 } (&Apache::loncommon::get_env_multiple('form.vPart'));
my (%response_types,%handgrade);
foreach my $part (@{ $partlist }) {
+ next if (%vPart && !exists($vPart{$part}));
+
my @types = $res->responseType($part);
my @ids = $res->responseIds($part);
for (my $i=0; $i < scalar(@ids); $i++) {
@@ -599,7 +603,8 @@ sub verifyreceipt {
my (undef,undef,$fullname) = &getclasslist('all','0');
my $receiptparts=0;
- if ($env{"course.$courseid.receiptalg"} eq 'receipt2') { $receiptparts=1; }
+ if ($env{"course.$courseid.receiptalg"} eq 'receipt2' ||
+ $env{"course.$courseid.receiptalg"} eq 'receipt3') { $receiptparts=1; }
my $parts=['0'];
if ($receiptparts) { ($parts)=&response_type($symb); }
foreach (sort
@@ -948,8 +953,8 @@ sub processGroup {
my @stuchecked = &Apache::loncommon::get_env_multiple('form.stuinfo');
my $total = scalar(@stuchecked)-1;
- foreach (@stuchecked) {
- my ($uname,$udom,$fullname) = split(/:/);
+ foreach my $student (@stuchecked) {
+ my ($uname,$udom,$fullname) = split(/:/,$student);
$env{'form.student'} = $uname;
$env{'form.userdom'} = $udom;
$env{'form.fullname'} = $fullname;
@@ -1621,6 +1626,41 @@ sub show_problem {
$result.='
';
return $result;
}
+sub files_exist {
+ my ($r, $symb) = @_;
+ my $files_exist = 0;
+ my @students = &Apache::loncommon::get_env_multiple('form.stuinfo');
+ foreach my $student (@students) {
+ my ($uname,$udom,$fullname) = split(/:/,$student);
+ my %record = &Apache::lonnet::restore($symb,$env{'request.course.id'},$udom,$uname);
+ my ($string,$timestamp)= &get_last_submission(\%record);
+ foreach (@$string) {
+ my ($partid,$respid) = /^resource\.([^\.]*)\.([^\.]*)\.submission/;
+ my $files=&get_submitted_files($udom,$uname,$partid,$respid,\%record);
+ if (@$files) {
+ $files_exist = 1;
+ return $files_exist;
+ }
+ }
+ }
+ return $files_exist;
+}
+sub download_all_link {
+ my ($r,$symb) = @_;
+ my $all_students =
+ join("\n", &Apache::loncommon::get_env_multiple('form.stuinfo'));
+
+ my $parts =
+ join("\n",&Apache::loncommon::get_env_multiple('form.vPart'));
+
+ my $identifier = &Apache::loncommon::get_cgi_id();
+ &Apache::lonnet::appenv('cgi.'.$identifier.'.students' => $all_students,
+ 'cgi.'.$identifier.'.symb' => $symb,
+ 'cgi.'.$identifier.'.parts' => $parts,);
+ $r->print(''.
+ &mt('Download All Submitted Documents').'');
+ return
+}
# --------------------------- show submissions of a student, option to grade
sub submission {
@@ -1656,7 +1696,9 @@ sub submission {
&sub_page_kw_js($request) if ($env{'form.handgrade'} eq 'yes');
$env{'form.probTitle'} = $env{'form.probTitle'} eq '' ?
&Apache::lonnet::gettitle($symb) : $env{'form.probTitle'};
-
+ if (&files_exist($request, $symb)) {
+ &download_all_link($request, $symb);
+ }
$request->print('