--- loncom/homework/grades.pm 2003/11/04 19:38:09 1.146
+++ loncom/homework/grades.pm 2003/11/06 15:22:33 1.147
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# The LON-CAPA Grading handler
#
-# $Id: grades.pm,v 1.146 2003/11/04 19:38:09 albertel Exp $
+# $Id: grades.pm,v 1.147 2003/11/06 15:22:33 albertel Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -133,9 +133,9 @@ sub response_type {
$symb=($ENV{'form.symb'} ne '' ? $ENV{'form.symb'} : (&Apache::lonnet::symbread($url))) if ($symb eq '');
my $allkeys = &Apache::lonnet::metadata($url,'keys');
my %seen = ();
- my (@partlist,%handgrade);
+ my (@partlist,%handgrade,%responseType);
foreach (split(/,/,&Apache::lonnet::metadata($url,'packages'))) {
- if (/^\w+response_\w+.*/) {
+ if (/^\w+response_.*/) {
my ($responsetype,$part) = split(/_/,$_,2);
my ($partid,$respid) = split(/_/,$part);
if (&Apache::loncommon::check_if_partid_hidden($partid,$symb)) {
@@ -143,13 +143,15 @@ sub response_type {
}
$responsetype =~ s/response$//; # make it compatible w/ navmaps - should move to that!!
my ($value) = &Apache::lonnet::EXT('resource.'.$part.'.handgrade',$symb);
- $handgrade{$part} = $responsetype.':'.($value eq 'yes' ? 'yes' : 'no');
+ $handgrade{$part} = ($value eq 'yes' ? 'yes' : 'no');
+ if (!exists($responseType{$partid})) { $responseType{$partid}={}; }
+ $responseType{$partid}->{$respid}=$responsetype;
next if ($seen{$partid} > 0);
$seen{$partid}++;
push @partlist,$partid;
}
}
- return \@partlist,\%handgrade;
+ return \@partlist,\%handgrade,\%responseType;
}
#--- Show resource title
@@ -158,20 +160,21 @@ sub showResourceInfo {
my ($url,$probTitle) = @_;
my $result ='
'.
'Current Resource: '.$probTitle.' |
'."\n";
- my ($partlist,$handgrade) = &response_type($url);
+ my ($partlist,$handgrade,$responseType) = &response_type($url);
my %resptype = ();
my $hdgrade='no';
- for (sort keys(%$handgrade)) {
- my ($responsetype,$handgrade)=split(/:/,$$handgrade{$_});
- my $partID = (split(/_/))[0];
- $resptype{$partID} = $responsetype;
+ for my $part_resID (sort keys(%$handgrade)) {
+ my $handgrade=$$handgrade{$part_resID};
+ my ($partID,$resID) = split(/_/,$part_resID);
+ my $responsetype = $responseType->{$partID}->{$resID};
$hdgrade = $handgrade if ($handgrade eq 'yes');
- $result.='Part '.$partID.' | '.
+ $result.='
Part '.$partID.' '.
+ $resID.' | '.
'Type: '.$responsetype.' |
';
# 'Handgrade: '.$handgrade.' | ';
}
$result.='
'."\n";
- return $result,\%resptype,$hdgrade,$partlist,$handgrade;
+ return $result,$responseType,$hdgrade,$partlist,$handgrade;
}
#--- Clean response type for display
@@ -1421,7 +1424,7 @@ KEYWORDS
my %record = &Apache::lonnet::restore($symb,$ENV{'request.course.id'},$udom,$uname);
- my ($partlist,$handgrade) = &response_type($url,$symb);
+ my ($partlist,$handgrade,$responseType) = &response_type($url,$symb);
# Display student info
$request->print(($counter == 0 ? '' : '
'));
@@ -1504,7 +1507,7 @@ KEYWORDS
$$fullname{$ENV{'form.'.$uname.':'.$udom.':submitted_by'}}.'';
$request->print($submitby);
} else {
- my ($string,$timestamp)= &get_last_submission (\%record);
+ my ($string,$timestamp)= &get_last_submission(\%record);
my $lastsubonly=''.
($$timestamp eq '' ? '' : 'Date Submitted: '.
$$timestamp)."\n";
@@ -1512,8 +1515,8 @@ KEYWORDS
$lastsubonly.=''.$$string[0];
} else {
for my $part (sort keys(%$handgrade)) {
- my ($responsetype,$foo) = split(/:/,$$handgrade{$part});
my ($partid,$respid) = split(/_/,$part);
+ my $responsetype = $responseType->{$partid}->{$respid};
if (!exists($record{'resource.'.$partid.'.'.$respid.'.submission'})) {
$lastsubonly.=' |
Part '.
$partid.' ( ID '.$respid.
@@ -2172,7 +2175,7 @@ sub viewgrades {
my ($partid,$respid) = split (/_/,$_,2);
next if $seen{$partid};
$seen{$partid}++;
- my ($responsetype,$handgrade)=split(/:/,$$handgrade{$_});
+ my $handgrade=$$handgrade{$_};
my $wgt = &Apache::lonnet::EXT('resource.'.$partid.'.weight',$symb);
$weight{$partid} = $wgt eq '' ? '1' : $wgt;
@@ -2991,9 +2994,16 @@ sub displayPage {
} else {
my %responseType = ();
foreach my $partid (@{$parts}) {
- $responseType{$partid} = $curRes->responseType($partid);
+ my @responseIds =$curRes->responseIds($partid);
+ my @responseType =$curRes->responseType($partid);
+ my %responseIds;
+ for (my $i=0;$i<=$#responseIds;$i++) {
+ $responseIds{$responseIds[$i]}=$responseType[$i];
+ }
+ $responseType{$partid} = \%responseIds;
}
$studentTable.= &displaySubByDates(\$symbx,\%record,$parts,\%responseType,$checkIcon);
+
}
} elsif ($ENV{'form.lastSub'} eq 'all') {
my $last = ($ENV{'form.lastSub'} eq 'last' ? 'last' : '');
@@ -3037,32 +3047,56 @@ sub displaySubByDates {
my ($version);
my %mark;
$mark{'correct_by_student'} = $checkIcon;
- return ' Nothing submitted - no attempts '
- if (!exists($$record{'1:timestamp'}));
+ if (!exists($$record{'1:timestamp'})) {
+ return ' Nothing submitted - no attempts ';
+ }
for ($version=1;$version<=$$record{'version'};$version++) {
my $timestamp = scalar(localtime($$record{$version.':timestamp'}));
$studentTable.=''.$timestamp.' | ';
my @versionKeys = split(/\:/,$$record{$version.':keys'});
my @displaySub = ();
foreach my $partid (@{$parts}) {
- my @matchKey = grep /^resource\.$partid\..*?\.submission$/,@versionKeys;
+ my @matchKey = sort(grep /^resource\.\Q$partid\E\..*?\.submission$/,@versionKeys);
# next if ($$record{"$version:resource.$partid.solved"} eq '');
- $displaySub[0].=(exists $$record{$version.':'.$matchKey[0]}) ?
- 'Part '.$partid.' '.
- ($$record{"$version:resource.$partid.tries"} eq '' ? 'Trial not counted' :
- 'Trial '.$$record{"$version:resource.$partid.tries"}).' '.
- &cleanRecord($$record{$version.':'.$matchKey[0]},$$responseType{$partid},$$symbx).' ' : '';
- $displaySub[1].=(exists $$record{"$version:resource.$partid.award"}) ?
- 'Part '.$partid.' '.
- lc($$record{"$version:resource.$partid.award"}).' '.
- $mark{$$record{"$version:resource.$partid.solved"}}.' ' : '';
- $displaySub[2].=(exists $$record{"$version:resource.$partid.regrader"}) ?
- $$record{"$version:resource.$partid.regrader"}.' (Part: '.$partid.')' : '';
- }
- $displaySub[2].=(exists $$record{"$version:resource.regrader"}) ?
- $$record{"$version:resource.regrader"} : ''; # needed because old essay regrader has not parts info
- $studentTable.=''.$displaySub[0].' | '.$displaySub[1].
- ($displaySub[2] eq '' ? '' : 'Manually graded by '.$displaySub[2]).' | ';
+ foreach my $matchKey (@matchKey) {
+ if (exists $$record{$version.':'.$matchKey}) {
+ my ($responseId)=($matchKey=~ /^resource\.\Q$partid\E\.(.*?)\.submission$/);
+ $displaySub[0].='Part '.$partid.' ';
+ $displaySub[0].='(ID '.
+ $responseId.') ';
+ if ($$record{"$version:resource.$partid.tries"} eq '') {
+ $displaySub[0].='Trial not counted';
+ } else {
+ $displaySub[0].='Trial '.
+ $$record{"$version:resource.$partid.tries"};
+ }
+ &Apache::lonnet::logthis("Part is $partid responseType is ".join(':',%$responseType));
+ my $responseType=$responseType->{$partid}->{$responseId};
+ $displaySub[0].=' '.
+ &cleanRecord($$record{$version.':'.$matchKey},$responseType,$$symbx).' ';
+ }
+ }
+ if (exists $$record{"$version:resource.$partid.award"}) {
+ $displaySub[1].='Part '.$partid.' '.
+ lc($$record{"$version:resource.$partid.award"}).' '.
+ $mark{$$record{"$version:resource.$partid.solved"}}.
+ ' ';
+ }
+ if (exists $$record{"$version:resource.$partid.regrader"}) {
+ $displaySub[2].=$$record{"$version:resource.$partid.regrader"}.
+ ' (Part: '.$partid.')';
+ }
+ }
+ # needed because old essay regrader has not parts info
+ if (exists $$record{"$version:resource.regrader"}) {
+ $displaySub[2].=$$record{"$version:resource.regrader"};
+ }
+ $studentTable.=' | '.$displaySub[0].' | '.$displaySub[1];
+ if ($displaySub[2]) {
+ $studentTable.='Manually graded by '.$displaySub[2];
+ }
+ $studentTable.=' |
';
+
}
$studentTable.='';
return $studentTable;