--- loncom/homework/grades.pm 2007/01/04 21:24:39 1.388
+++ 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.388 2007/01/04 21:24:39 raeburn Exp $
+# $Id: grades.pm,v 1.397 2007/04/26 22:29:50 albertel 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;
@@ -1622,6 +1627,43 @@ sub show_problem {
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 $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 {
my ($request,$counter,$total) = @_;
@@ -1656,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'};
-
+ if ($env{'form.handgrade'} eq 'yes' && &files_exist($request, $symb)) {
+ &download_all_link($request, $symb);
+ }
$request->print('
Submission Record
'."\n".
' Resource: '.$env{'form.probTitle'}.''."\n");
@@ -1867,6 +1911,9 @@ KEYWORDS
my %seenparts;
my @part_response_id = &flatten_responseType($responseType);
foreach my $part (@part_response_id) {
+ next if ($env{'form.lastSub'} eq 'hdgrade'
+ && $$handgrade{$$part[0].'_'.$$part[1]} ne 'yes');
+
my ($partid,$respid) = @{ $part };
my $display_part=&get_display_part($partid,$symb);
if ($env{"form.$uname:$udom:$partid:submitted_by"}) {
@@ -1913,8 +1960,8 @@ KEYWORDS
($env{'form.lastSub'} eq 'hdgrade' &&
$$handgrade{$$part[0].'_'.$$part[1]} eq 'yes')) {
my $display_part=&get_display_part($partid,$symb);
- $lastsubonly.='Part: '.
- $display_part.' ( ID '.$respid.
+ $lastsubonly.='Debug -'.'Part: '.
+ $display_part.' ( hhhh ID '.$respid.
' ) ';
my $files=&get_submitted_files($udom,$uname,$partid,$respid,\%record);
if (@$files) {
@@ -2007,7 +2054,8 @@ KEYWORDS
my $part_resp = join('_',@{ $part_response_id });
next if ($seen{$partid} > 0);
$seen{$partid}++;
- next if ($$handgrade{$part_resp} =~ /:no$/ && $env{'form.lastSub'} =~ /^(hdgrade)$/);
+ next if ($$handgrade{$part_resp} ne 'yes'
+ && $env{'form.lastSub'} eq 'hdgrade');
push @partlist,$partid;
push @gradePartRespid,$partid.'.'.$respid;
$request->print(&gradeBox($request,$symb,$uname,$udom,$counter,$partid,\%record));
@@ -2059,22 +2107,27 @@ sub get_last_submission {
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' ?
- 'Draft Copy ' : '';
- 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' ?
+ 'Draft Copy ' : '';
+ push(@string, join(':', $key, $draft.$lasthash{$key}));
}
}
- @string = $string[0] eq '' ? 'Nothing submitted - no attempts.' : @string;
- return \@string,\$timestamp;
+ if (!@string) {
+ $string[0] =
+ 'Nothing submitted - no attempts.';
+ }
+ return (\@string,\$timestamp);
}
#--- High light keywords, with style choosen by user.
@@ -2984,7 +3037,7 @@ sub viewgrades {
}
$result.=''.' | '.' |
'."\n".
'';
- $result.='';
#table listing all the students in a section/class
@@ -4638,6 +4691,7 @@ sub scantron_fixup_scanline {
$answer=$alphabet[$args->{'response'}];
} elsif ($on eq 'number') {
$answer=$args->{'response'}+1;
+ if ($answer == 10) { $answer = '0'; }
} else {
substr($answer,$args->{'response'},1)=$on;
}
@@ -4708,7 +4762,7 @@ sub scantron_parse_scanline {
|| $currentquest eq '*') {
push(@{$record{'scantron.doubleerror'}},$questnum);
$record{"scantron.$questnum.answer"}='';
- } elsif (!$currentquest
+ } elsif (!defined($currentquest)
|| $currentquest eq $$scantron_config{'Qoff'}
|| $currentquest !~ /^[A-Z]$/) {
$record{"scantron.$questnum.answer"}='';
@@ -4723,9 +4777,9 @@ sub scantron_parse_scanline {
|| $currentquest eq '*') {
push(@{$record{'scantron.doubleerror'}},$questnum);
$record{"scantron.$questnum.answer"}='';
- } elsif (!$currentquest
- || $currentquest eq $$scantron_config{'Qoff'}
- || $currentquest !~ /^\d$/) {
+ } elsif (!defined($currentquest)
+ || $currentquest eq $$scantron_config{'Qoff'}
+ || $currentquest !~ /^\d$/) {
$record{"scantron.$questnum.answer"}='';
if (!&scan_data($scan_data,"$whichline.no_bubble.$questnum")) {
push(@{$record{"scantron.missingerror"}},$questnum);