[LON-CAPA-cvs] cvs: loncom /homework grades.pm
albertel
lon-capa-cvs@mail.lon-capa.org
Wed, 27 Sep 2006 22:09:18 -0000
albertel Wed Sep 27 18:09:18 2006 EDT
Modified files:
/loncom/homework grades.pm
Log:
- parts with _ in them were not being handled correctly, changing to use
navmaps to get partinfo correctly
Index: loncom/homework/grades.pm
diff -u loncom/homework/grades.pm:1.376 loncom/homework/grades.pm:1.377
--- loncom/homework/grades.pm:1.376 Fri Sep 22 17:11:55 2006
+++ loncom/homework/grades.pm Wed Sep 27 18:09:16 2006
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# The LON-CAPA Grading handler
#
-# $Id: grades.pm,v 1.376 2006/09/22 21:11:55 albertel Exp $
+# $Id: grades.pm,v 1.377 2006/09/27 22:09:16 albertel Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -112,36 +112,22 @@
#--- Indicate if a response type is coded handgraded or not. ---
sub response_type {
my ($symb) = shift;
- my (undef,undef,$url) = &Apache::lonnet::decode_symb($symb);
- my $allkeys = &Apache::lonnet::metadata($url,'keys');
- my %vPart;
- foreach my $partid (&Apache::loncommon::get_env_multiple('form.vPart')) {
- $vPart{$partid}=1;
- }
- my %seen = ();
- my (@partlist,%handgrade,%responseType);
- foreach (split(/,/,&Apache::lonnet::metadata($url,'packages'))) {
- if (/^\w+response_.*/ || /^Task_/) {
- my ($responsetype,$part) = split(/_/,$_,2);
- my ($partid,$respid) = split(/_/,$part,2);
- if ($responsetype eq 'Task') { $respid='0'; }
- if (&Apache::loncommon::check_if_partid_hidden($partid,$symb)) {
- next;
- }
- if (%vPart && !exists($vPart{$partid})) {
- next;
- }
- $responsetype =~ s/response$//; # make it compatible w/ navmaps - should move to that!!
- my ($value) = &Apache::lonnet::EXT('resource.'.$part.'.handgrade',$symb);
- $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;
+
+ my $navmap = Apache::lonnavmaps::navmap->new();
+ my $res = $navmap->getBySymb($symb);
+ my $partlist = $res->parts();
+ my (%response_types,%handgrade);
+ foreach my $part (@{ $partlist }) {
+ my @types = $res->responseType($part);
+ my @ids = $res->responseIds($part);
+ for (my $i=0; $i < scalar(@ids); $i++) {
+ $response_types{$part}{$ids[$i]} = $types[$i];
+ $handgrade{$part.'_'.$ids[$i]} =
+ &Apache::lonnet::EXT('resource.'.$part.'_'.$ids[$i].
+ '.handgrade',$symb);
}
}
- return (\@partlist,\%handgrade,\%responseType);
+ return ($partlist,\%handgrade,\%response_types);
}
sub flatten_responseType {
@@ -1918,7 +1904,7 @@
my $order=&get_order($partid,$respid,$symb,$uname,$udom);
if ($env{'form.lastSub'} eq 'lastonly' ||
($env{'form.lastSub'} eq 'hdgrade' &&
- $$handgrade{$part} eq 'yes')) {
+ $$handgrade{$$part[0].'_'.$$part[1]} eq 'yes')) {
my $display_part=&get_display_part($partid,$symb);
$lastsubonly.='<tr><td bgcolor="#ffffe6"><b>Part:</b> '.
$display_part.' <font color="#999999">( ID '.$respid.