[LON-CAPA-cvs] cvs: loncom /homework grades.pm
albertel
lon-capa-cvs-allow@mail.lon-capa.org
Thu, 26 Apr 2007 22:29:51 -0000
albertel Thu Apr 26 18:29:51 2007 EDT
Modified files:
/loncom/homework grades.pm
Log:
- some style
- only do check for files if it's a problem that might have files
Index: loncom/homework/grades.pm
diff -u loncom/homework/grades.pm:1.396 loncom/homework/grades.pm:1.397
--- loncom/homework/grades.pm:1.396 Tue Apr 24 20:16:51 2007
+++ loncom/homework/grades.pm Thu Apr 26 18:29:50 2007
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# The LON-CAPA Grading handler
#
-# $Id: grades.pm,v 1.396 2007/04/25 00:16:51 banghart Exp $
+# $Id: grades.pm,v 1.397 2007/04/26 22:29:50 albertel Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -1626,25 +1626,27 @@
$result.='</td></tr></table><br />';
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 %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;
- }
+ 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 $files_exist;
+ return 0;
}
+
sub download_all_link {
my ($r,$symb) = @_;
my $all_students =
@@ -1696,7 +1698,7 @@
&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)) {
+ if ($env{'form.handgrade'} eq 'yes' && &files_exist($request, $symb)) {
&download_all_link($request, $symb);
}
$request->print('<h3> <font color="#339933">Submission Record</font></h3>'."\n".
@@ -2105,22 +2107,27 @@
my %lasthash=();
my ($version);
for ($version=1;$version<=$$returnhash{'version'};$version++) {
- foreach (sort(split(/\:/,$$returnhash{$version.':keys'}))) {
- $lasthash{$_}=$$returnhash{$version.':'.$_};
- $timestamp = scalar(localtime($$returnhash{$version.':timestamp'}));
+ foreach my $key (sort(split(/\:/,
+ $$returnhash{$version.':keys'}))) {
+ $lasthash{$key}=$$returnhash{$version.':'.$key};
+ $timestamp =
+ scalar(localtime($$returnhash{$version.':timestamp'}));
}
}
- foreach ((keys %lasthash)) {
- if ($_ =~ /\.submission$/) {
- my ($partid,$foo) = split(/submission$/,$_);
- my $draft = $lasthash{$partid.'awarddetail'} eq 'DRAFT' ?
- '<font color="red">Draft Copy</font> ' : '';
- push @string, (join(':',$_,$draft.$lasthash{$_}));
- }
+ foreach my $key (keys(%lasthash)) {
+ next if ($key !~ /\.submission$/);
+
+ my ($partid,$foo) = split(/submission$/,$key);
+ my $draft = $lasthash{$partid.'awarddetail'} eq 'DRAFT' ?
+ '<font color="red">Draft Copy</font> ' : '';
+ push(@string, join(':', $key, $draft.$lasthash{$key}));
}
}
- @string = $string[0] eq '' ? '<font color="red">Nothing submitted - no attempts.</font>' : @string;
- return \@string,\$timestamp;
+ if (!@string) {
+ $string[0] =
+ '<font color="red">Nothing submitted - no attempts.</font>';
+ }
+ return (\@string,\$timestamp);
}
#--- High light keywords, with style choosen by user.