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

albertel lon-capa-cvs@mail.lon-capa.org
Fri, 16 May 2003 19:00:23 -0000


albertel		Fri May 16 15:00:23 2003 EDT

  Modified files:              
    /loncom/homework	grades.pm 
  Log:
  - grade entire class was dysfunctional when trying to assign grades to a class which had users with the same name but different domains
  
  
Index: loncom/homework/grades.pm
diff -u loncom/homework/grades.pm:1.88 loncom/homework/grades.pm:1.89
--- loncom/homework/grades.pm:1.88	Wed Apr 30 16:16:02 2003
+++ loncom/homework/grades.pm	Fri May 16 15:00:23 2003
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # The LON-CAPA Grading handler
 #
-# $Id: grades.pm,v 1.88 2003/04/30 20:16:02 www Exp $
+# $Id: grades.pm,v 1.89 2003/05/16 19:00:23 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -1302,7 +1302,7 @@
 	my $lastone = pop @col_fullnames;
 	$msgfor .= ', '.(join ', ',@col_fullnames).' and '.$lastone.'.';
     }
-    $msgfor =~ s/\'/\\'/g; #\'
+    $msgfor =~ s/\'/\\'/g; #' stupid emacs
     $result.='<tr><td bgcolor="#ffffff">'."\n".
 	'&nbsp;<a href="javascript:msgCenter(document.SCORE,'.$counter.
 	',\''.$msgfor.'\')"; TARGET=_self>'.
@@ -1914,7 +1914,7 @@
     my $ctr = 0;
     foreach (sort {lc($$fullname{$a}) cmp lc($$fullname{$b}) } keys %$fullname) {
 	my ($uname,$udom) = split(/:/);
-	$result.='<input type="hidden" name="ctr'.$ctr.'" value="'.$uname.'" />'."\n";
+	$result.='<input type="hidden" name="ctr'.$ctr.'" value="'.$_.'" />'."\n";
 	$result.=&viewstudentgrade($url,$symb,$ENV{'request.course.id'},
 				   $_,$$fullname{$_},\@parts,\%weight);
 	$ctr++;
@@ -1942,19 +1942,19 @@
 	if ($type eq 'awarded') {
 	    my $pts = $score eq '' ? '' : $score*$$weight{$part};
 	    $result.='<input type="hidden" name="'.
-		'GD_'.$uname.'_'.$part.'_awarded_s" value="'.$pts.'" />'."\n";
+		'GD_'.$student.'_'.$part.'_awarded_s" value="'.$pts.'" />'."\n";
 	    $result.='<td align="middle"><input type="text" name="'.
-		'GD_'.$uname.'_'.$part.'_awarded" '.
-		'onChange="javascript:changeSelect(\''.$part.'\',\''.$uname.
+		'GD_'.$student.'_'.$part.'_awarded" '.
+		'onChange="javascript:changeSelect(\''.$part.'\',\''.$student.
 		'\')" value="'.$pts.'" size="4" /></td>'."\n";
 	} elsif ($type eq 'solved') {
 	    my ($status,$foo)=split(/_/,$score,2);
 	    $status = 'nothing' if ($status eq '');
-	    $result.='<input type="hidden" name="'.'GD_'.$uname.'_'.
+	    $result.='<input type="hidden" name="'.'GD_'.$student.'_'.
 		$part.'_solved_s" value="'.$status.'" />'."\n";
 	    $result.='<td align="middle"><select name="'.
-		'GD_'.$uname.'_'.$part.'_solved" '.
-		'onChange="javascript:changeOneScore(\''.$part.'\',\''.$uname.'\')" >'."\n";
+		'GD_'.$student.'_'.$part.'_solved" '.
+		'onChange="javascript:changeOneScore(\''.$part.'\',\''.$student.'\')" >'."\n";
 	    my $optsel = '<option selected="on"> </option><option>excused</option>'."\n";
 	    $optsel = '<option> </option><option selected="on">excused</option>'."\n"
 		if ($status eq 'excused');
@@ -1962,10 +1962,10 @@
 	    $result.="</select></td>\n";
 	} else {
 	    $result.='<input type="hidden" name="'.
-		'GD_'.$uname.'_'.$part.'_'.$type.'_s" value="'.$score.'" />'.
+		'GD_'.$student.'_'.$part.'_'.$type.'_s" value="'.$score.'" />'.
 		    "\n";
 	    $result.='<td align="middle"><input type="text" name="'.
-		'GD_'.$uname.'_'.$part.'_'.$type.'" '.
+		'GD_'.$student.'_'.$part.'_'.$type.'" '.
 		'value="'.$score.'" size="4" /></td>'."\n";
 	}
     }
@@ -1985,7 +1985,7 @@
     $title.='<font size=+1><b>Section: </b>'.$ENV{'form.section'}.'</font>'."\n";
     my $result= '<table border="0"><tr><td bgcolor="#777777">'."\n";
     $result.= '<table border="0"><tr bgcolor="#deffff">'.
-	'<td rowspan=2><b>Username</b></td><td rowspan=2><b>Fullname</b></td>'."\n";
+	'<td rowspan=2><b>Username</b></td><td rowspan=2><b>Domain</b></td><td rowspan=2><b>Fullname</b></td>'."\n";
 
     my %scoreptr = (
 		    'correct'  =>'correct_by_override',
@@ -2036,13 +2036,13 @@
 
     for ($i=0; $i<$ENV{'form.total'}; $i++) {
 	my $user = $ENV{'form.ctr'.$i};
+	my ($uname,$udom)=split(/:/,$user);
 	my %newrecord;
 	my $updateflag = 0;
-	my @userdom = grep /^$user:/,keys %$classlist;
-	my (undef,$udom) = split(/:/,$userdom[0]);
 
-	$result .= '<tr bgcolor="#ffffde"><td>'.$user.'&nbsp;</td><td>'.
-	    $$fullname{$userdom[0]}.'&nbsp;</td>';
+	$result .= '<tr bgcolor="#ffffde"><td>'.$uname.'&nbsp;</td><td>'.
+	    $udom.'&nbsp;</td><td>'.
+		$$fullname{$user}.'&nbsp;</td>';
 	foreach (@partid) {
 	    my $old_aw    = $ENV{'form.GD_'.$user.'_'.$_.'_awarded_s'};
 	    my $old_part_pcr = $old_aw/($weight{$_} ne '0' ? $weight{$_}:1);
@@ -2093,7 +2093,7 @@
 	if ($updateflag) {
 	    $count++;
 	    &Apache::lonnet::cstore(\%newrecord,$symb,$ENV{'request.course.id'},
-				    $udom,$user);
+				    $udom,$uname);
 	}
     }
     $result .= '</table></td></tr></table>'."\n".