[LON-CAPA-cvs] cvs: loncom(version_1_2_X) /homework grades.pm

albertel lon-capa-cvs@mail.lon-capa.org
Fri, 06 Aug 2004 22:09:23 -0000


This is a MIME encoded message

--albertel1091830163
Content-Type: text/plain

albertel		Fri Aug  6 18:09:23 2004 EDT

  Modified files:              (Branch: version_1_2_X)
    /loncom/homework	grades.pm 
  Log:
  - backport 1.207
  
  
--albertel1091830163
Content-Type: text/plain
Content-Disposition: attachment; filename="albertel-20040806180923.txt"

Index: loncom/homework/grades.pm
diff -u loncom/homework/grades.pm:1.204.2.1 loncom/homework/grades.pm:1.204.2.2
--- loncom/homework/grades.pm:1.204.2.1	Tue Jul 27 11:16:10 2004
+++ loncom/homework/grades.pm	Fri Aug  6 18:09:22 2004
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # The LON-CAPA Grading handler
 #
-# $Id: grades.pm,v 1.204.2.1 2004/07/27 15:16:10 albertel Exp $
+# $Id: grades.pm,v 1.204.2.2 2004/08/06 22:09:22 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -167,6 +167,21 @@
     return \@partlist,\%handgrade,\%responseType;
 }
 
+sub get_display_part {
+    my ($partID,$url,$symb)=@_;
+    if (!defined($symb) || $symb eq '') {
+	$symb=$ENV{'form.symb'};
+	if ($symb eq '') { $symb=&Apache::lonnet::symbread($url) }
+    }
+    my $display=&Apache::lonnet::EXT('resource.'.$partID.'.display',$symb);
+    &Apache::lonnet::logthis("\nsymb $symb\n url  $url\npartID $partID\ndisplay $display \n");
+    if (defined($display) and $display ne '') {
+	$display.= " (<font color=\"#999900\">id $partID</font>)";
+    } else {
+	$display=$partID;
+    }
+    return $display;
+}
 #--- Show resource title
 #--- and parts and response type
 sub showResourceInfo {
@@ -194,7 +209,8 @@
 	    }
 	    $partsseen{$partID}=1;
 	}
-	$result.='<td><b>Part </b>'.$partID.' <font color="#999999">'.
+	my $display_part=&get_display_part($partID,$url);
+	$result.='<td><b>Part: </b>'.$display_part.' <font color="#999999">'.
 	    $resID.'</font></td>'.
 	    '<td><b>Type: </b>'.$responsetype.'</td></tr>';
 #	    '<td><b>Handgrade: </b>'.$handgrade.'</td></tr>';
@@ -682,7 +698,9 @@
 	    '<td>'.&nameUserString('header').'</td>';
 	if ($ENV{'form.showgrading'} eq 'yes' && $submitonly ne 'all') {
 	    foreach (sort(@$partlist)) {
-		$gradeTable.='<td><b>&nbsp;Part '.(split(/_/))[0].' Status&nbsp;</b></td>';
+		my $display_part=&get_display_part((split(/_/))[0],$url,$symb);
+		$gradeTable.='<td><b>&nbsp;Part: '.$display_part.
+		    ' Status&nbsp;</b></td>';
 	    }
 	}
 	$loop++;
@@ -1289,8 +1307,9 @@
 		  '' : $$record{'resource.'.$partid.'.awarded'}*$wgt);
     my $result='<input type="hidden" name="WGT'.$counter.'_'.$partid.'" value="'.$wgt.'" />'."\n";
 
+    my $display_part=&get_display_part($partid,undef,$symb);
     $result.='<table border="0"><tr><td>'.
-	'<b>Part </b>'.$partid.' <b>Points: </b></td><td>'."\n";
+	'<b>Part: </b>'.$display_part.' <b>Points: </b></td><td>'."\n";
 
     my $ctr = 0;
     $result.='<table border="0"><tr>'."\n";  # display radio buttons in a nice table 10 across
@@ -1622,11 +1641,12 @@
 	    my %seenparts;
 	    for my $part (sort keys(%$handgrade)) {
 		my ($partid,$respid) = split(/_/,$part);
+		my $display_part=&get_display_part($partid,$url,$symb);
 		if ($ENV{"form.$uname:$udom:$partid:submitted_by"}) {
 		    if (exists($seenparts{$partid})) { next; }
 		    $seenparts{$partid}=1;
-		    my $submitby='<b>Part '.$partid.
-			' Collaborative submission by: </b>'.
+		    my $submitby='<b>Part:</b> '.$display_part.
+			' <b>Collaborative submission by:</b> '.
 			'<a href="javascript:viewSubmitter(\''.
 			$ENV{"form.$uname:$udom:$partid:submitted_by"}.
 			'\')"; TARGET=_self>'.
@@ -1636,8 +1656,8 @@
 		}
 		my $responsetype = $responseType->{$partid}->{$respid};
 		if (!exists($record{"resource.$partid.$respid.submission"})) {
-		    $lastsubonly.='<tr><td bgcolor="#ffffe6"><b>Part '.
-			$partid.'</b> <font color="#999999">( ID '.$respid.
+		    $lastsubonly.='<tr><td bgcolor="#ffffe6"><b>Part:</b> '.
+			$display_part.' <font color="#999999">( ID '.$respid.
 			' )</font>&nbsp; &nbsp;'.
 			'<font color="red">Nothing submitted - no attempts</font><br /><br />';
 		    next;
@@ -1665,8 +1685,9 @@
 		    if ($ENV{'form.lastSub'} eq 'lastonly' || 
 			($ENV{'form.lastSub'} eq 'hdgrade' && 
 			 $$handgrade{$part} eq 'yes')) {
-			$lastsubonly.='<tr><td bgcolor="#ffffe6"><b>Part '.
-			    $partid.'</b> <font color="#999999">( ID '.$respid.
+			my $display_part=&get_display_part($partid,$url,$symb);
+			$lastsubonly.='<tr><td bgcolor="#ffffe6"><b>Part:</b> '.
+			    $display_part.' <font color="#999999">( ID '.$respid.
 			    ' )</font>&nbsp; &nbsp;';
 			if ($record{"resource.$partid.$respid.uploadedurl"}) {
 			    &Apache::lonnet::allowuploaded('/adm/grades',
@@ -2326,7 +2347,8 @@
 	    $ctsparts.'" value="'.$partid.'" />'."\n";
 	$result.='<input type="hidden" name="weight_'.
 	    $partid.'" value="'.$weight{$partid}.'" />'."\n";
-	$result.='<tr><td><b>Part  '.$partid.'&nbsp; &nbsp;Point:</b> </td><td>';
+	my $display_part=&get_display_part($partid,$url,$symb);
+	$result.='<tr><td><b>Part:</b> '.$display_part.'&nbsp; &nbsp;<b>Point:</b> </td><td>';
 	$result.='<table border="0"><tr>';  
 	my $ctr = 0;
 	while ($ctr<=$weight{$partid}) { # display radio buttons in a nice table 10 across
@@ -2365,14 +2387,17 @@
 	my $display=&Apache::lonnet::metadata($url,$part.'.display');
 	$display =~ s|^Number of Attempts|Tries<br />|; # makes the column narrower
 	if  (!$display) { $display = &Apache::lonnet::metadata($url,$part.'.name'); }
+	my ($partid) = &split_part_type($part);
+	my $display_part=&get_display_part($partid,$url,$symb);
 	if ($display =~ /^Partial Credit Factor/) {
-	    my ($partid) = &split_part_type($part);
-	    $result.='<td><b>Score Part '.$partid.'<br />(weight = '.
-		$weight{$partid}.')</b></td>'."\n";
+	    $result.='<td><b>Score Part:</b> '.$display_part.
+		' <br /><b>(weight = '.$weight{$partid}.')</b></td>'."\n";
 	    next;
+	} else {
+	    $display =~s/\[Part: \Q$partid\E\]/Part:<\/b> $display_part/;
 	}
 	$display =~ s|Problem Status|Grade Status<br />|;
-	$result.='<td><b>'.$display.'</b></td>'."\n";
+	$result.='<td><b>'.$display.'</td>'."\n";
     }
     $result.='</tr>';
 
@@ -2502,9 +2527,10 @@
 	}
     }
     foreach my $partid (@partid) {
+	my $display_part=&get_display_part($partid,$url,$symb);
 	$result .= '<td colspan="'.$columns{$partid}.
-	    '" align="center"><b>Part '.$partid.
-	    '</b> (Weight = '.$weight{$partid}.')</td>';
+	    '" align="center"><b>Part:</b> '.$display_part.
+	    ' (Weight = '.$weight{$partid}.')</td>';
 
     }
     $result .= '</tr><tr bgcolor="#deffff">';
@@ -3213,13 +3239,14 @@
 	foreach my $partid (@{$parts}) {
 	    my @matchKey = sort(grep /^resource\.\Q$partid\E\..*?\.submission$/,@versionKeys);
 #	    next if ($$record{"$version:resource.$partid.solved"} eq '');
+	    my $display_part=&get_display_part($partid,undef,$symb);
 	    foreach my $matchKey (@matchKey) {
 		if (exists($$record{$version.':'.$matchKey}) &&
 		    $$record{$version.':'.$matchKey} ne '') {
 		    my ($responseId)=($matchKey=~ /^resource\.\Q$partid\E\.(.*?)\.submission$/);
-		    $displaySub[0].='<b>Part&nbsp;'.$partid.'&nbsp;';
+		    $displaySub[0].='<b>Part:</b>&nbsp;'.$display_part.'&nbsp;';
 		    $displaySub[0].='<font color="#999999">(ID&nbsp;'.
-			$responseId.')</font>&nbsp;';
+			$responseId.')</font>&nbsp;<b>';
 		    if ($$record{"$version:resource.$partid.tries"} eq '') {
 			$displaySub[0].='Trial&nbsp;not&nbsp;counted';
 		    } else {
@@ -3237,14 +3264,14 @@
 		}
 	    }
 	    if (exists $$record{"$version:resource.$partid.award"}) {
-		$displaySub[1].='<b>Part&nbsp;'.$partid.'</b> &nbsp;'.
+		$displaySub[1].='<b>Part:</b>&nbsp;'.$display_part.' &nbsp;'.
 		    lc($$record{"$version:resource.$partid.award"}).' '.
 		    $mark{$$record{"$version:resource.$partid.solved"}}.
 		    '<br />';
 	    }
 	    if (exists $$record{"$version:resource.$partid.regrader"}) {
 		$displaySub[2].=$$record{"$version:resource.$partid.regrader"}.
-		    ' (<b>'.&mt('Part').':</b> '.$partid.')';
+		    ' (<b>'.&mt('Part').':</b> '.$display_part.')';
 	    }
 	}
 	# needed because old essay regrader has not parts info
@@ -3341,12 +3368,13 @@
 		    $changeflag++;
 		    $newpts = '';
 		}
-
+		my $display_part=&get_display_part($partid,undef,
+						   $curRes->symb());
 		my $oldstatus = $ENV{'form.solved'.$question.'_'.$partid};
-		$displayPts[0].='&nbsp;<b>Part</b> '.$partid.' = '.
+		$displayPts[0].='&nbsp;<b>Part:</b> '.$display_part.' = '.
 		    (($oldstatus eq 'excused') ? 'excused' : $oldpts).
 		    '&nbsp;<br>';
-		$displayPts[1].='&nbsp;<b>Part</b> '.$partid.' = '.
+		$displayPts[1].='&nbsp;<b>Part:</b> '.$display_part.' = '.
 		     (($score eq 'excused') ? 'excused' : $newpts).
 		    '&nbsp;<br>';
 

--albertel1091830163--