--- loncom/homework/grades.pm 2007/04/15 18:25:56 1.394
+++ loncom/homework/grades.pm 2007/04/26 22:29:50 1.397
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# The LON-CAPA Grading handler
#
-# $Id: grades.pm,v 1.394 2007/04/15 18:25:56 banghart Exp $
+# $Id: grades.pm,v 1.397 2007/04/26 22:29:50 albertel Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -953,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;
@@ -1626,27 +1626,44 @@ sub show_problem {
$result.='
';
return $result;
}
+
+sub files_exist {
+ my ($r, $symb) = @_;
+ 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 my $submission (@$string) {
+ my ($partid,$respid) =
+ ($submission =~ /^resource\.([^\.]*)\.([^\.]*)\.submission/);
+ my $files=&get_submitted_files($udom,$uname,$partid,$respid,
+ \%record);
+ return 1 if (@$files);
+ }
+ }
+ return 0;
+}
+
sub download_all_link {
my ($r,$symb) = @_;
- my $courseid=$env{'request.course.id'};
- my @stuchecked = &Apache::loncommon::get_env_multiple('form.stuinfo');
- my $parts;
- my $total = scalar(@stuchecked)-1;
- my $all_students;
- foreach my $stu_info (@stuchecked) {
- $all_students .= $stu_info."\n";
- }
- foreach my $part (&Apache::loncommon::get_env_multiple('form.vPart')) {
- $parts .= $part."\n";
- }
+ 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,
- 'cgi.'.$identifier.'.courseid' => $courseid);
- $r->print('Download All Submitted Documents');
+ 'cgi.'.$identifier.'.parts' => $parts,);
+ $r->print(''.
+ &mt('Download All Submitted Documents').'');
return
}
+
# --------------------------- show submissions of a student, option to grade
sub submission {
my ($request,$counter,$total) = @_;
@@ -1681,7 +1698,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'};
- &download_all_link($request,$symb);
+ if ($env{'form.handgrade'} eq 'yes' && &files_exist($request, $symb)) {
+ &download_all_link($request, $symb);
+ }
$request->print('