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

ng lon-capa-cvs@mail.lon-capa.org
Thu, 31 Jul 2003 15:08:41 -0000


This is a MIME encoded message

--ng1059664121
Content-Type: text/plain

ng		Thu Jul 31 11:08:41 2003 EDT

  Modified files:              
    /loncom/homework	grades.pm 
  Log:
  fix bug 2010 - students with no names (first, middle & initial) display
  username instead in javascript prompt.
  fix an unreported bug that creep in with change to grading all parts.
  Filtering of only those with submissions - useful in essay grading
  was incorrect.
  
  
--ng1059664121
Content-Type: text/plain
Content-Disposition: attachment; filename="ng-20030731110841.txt"

Index: loncom/homework/grades.pm
diff -u loncom/homework/grades.pm:1.128 loncom/homework/grades.pm:1.129
--- loncom/homework/grades.pm:1.128	Tue Jul 29 16:54:39 2003
+++ loncom/homework/grades.pm	Thu Jul 31 11:08:41 2003
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # The LON-CAPA Grading handler
 #
-# $Id: grades.pm,v 1.128 2003/07/29 20:54:39 ng Exp $
+# $Id: grades.pm,v 1.129 2003/07/31 15:08:41 ng Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -96,6 +96,18 @@
     return $fullname;
 }
 
+#--- Format fullname, username:domain if different for display
+#--- Use anywhere where the student names are listed
+sub nameUserString {
+    my ($type,$fullname,$uname,$udom) = @_;
+    if ($type eq 'header') {
+	return '<b>&nbsp;Fullname&nbsp;</b><font color="#999999">(Username)</font>&nbsp;';
+    } else {
+	return '&nbsp;'.$fullname.'<font color="#999999">&nbsp;('.$uname.
+	    ($ENV{'user.domain'} eq $udom ? '' : ' ('.$udom.')').')</font>';
+    }
+}
+
 #--- Get the partlist and the response type for a given problem. ---
 #--- Indicate if a response type is coded handgraded or not. ---
 sub response_type {
@@ -539,8 +551,7 @@
     my $loop = 0;
     while ($loop < 2) {
 	$gradeTable.='<td><b>&nbsp;No.</b>&nbsp;</td><td><b>&nbsp;Select&nbsp;</b></td>'.
-	    '<td><b>&nbsp;Fullname&nbsp;</b>'.
-	    '<font color="#999999">(Username)</font>&nbsp;</td>';
+	    '<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>';
@@ -577,8 +588,7 @@
 	    $gradeTable.='<td align="right">'.$ctr.'&nbsp;</td>'.
 		'<td align="center"><input type=checkbox name="stuinfo" value="'.
 		$student.':'.$$fullname{$student}.'&nbsp;"></td>'."\n".
-		'<td>&nbsp;'.$$fullname{$student}.'&nbsp;'."\n".
-		'<font color="#999999">('.$uname.')</font></td>'."\n";
+		'<td>'.&nameUserString(undef,$$fullname{$student},$uname,$udom).'</td>'."\n";
 
 	    if ($ENV{'form.showgrading'} eq 'yes' && $submitonly ne 'all') {
 		foreach (sort keys(%status)) {
@@ -758,7 +768,9 @@
 			var points = formname["GD_BOX"+i+"_"+partid].value;
 			if (points == "") {
 			    var name = formname["name"+i].value;
-			    var resp = confirm("You did not assign a score for "+name+", part "+partid+". Continue?");
+			    var studentID = (name != '' ? name : formname["unamedom"+i].value);
+			    var resp = confirm("You did not assign a score for "+studentID+
+					       ", part "+partid+". Continue?");
 			    if (resp == false) {
 				formname["GD_BOX"+i+"_"+partid].focus();
 				return false;
@@ -1351,9 +1363,7 @@
     my $result='<table border="0" width=100%><tr><td bgcolor="#777777">'."\n".
 	'<table border="0" width=100%><tr bgcolor="#edffff"><td>'."\n";
 
-    $result.='<b>Fullname: </b>'.$ENV{'form.fullname'}.
-	'<font color="#999999">&nbsp; &nbsp;Username: '.$uname.
-	($ENV{'user.domain'} eq $udom ? '' : ' ('.$udom.')').'</font><br />'."\n";
+    $result.='<b>Fullname: </b>'.&nameUserString(undef,$ENV{'form.fullname'},$uname,$udom).'<br />'."\n";
     $result.='<input type="hidden" name="name'.$counter.
 	'" value="'.$ENV{'form.fullname'}.'" />'."\n";
 
@@ -1531,17 +1541,21 @@
 
     my %seen = ();
     my @partlist;
+    my @gradePartRespid;
     for (sort keys(%$handgrade)) {
 	my ($partid,$respid) = split(/_/);
 	next if ($seen{$partid} > 0);
 	$seen{$partid}++;
 	next if ($$handgrade{$_} =~ /:no$/ && $ENV{'form.lastSub'} =~ /^(hdgrade)$/);
 	push @partlist,$partid;
+	push @gradePartRespid,$partid.'.'.$respid;
 
 	$request->print(&gradeBox($request,$symb,$uname,$udom,$counter,$partid,\%record));
     }
     $result='<input type="hidden" name="partlist'.$counter.
 	'" value="'.(join ":",@partlist).'" />'."\n";
+    $result.='<input type="hidden" name="gradePartRespid'.
+	'" value="'.(join ":",@gradePartRespid).'" />'."\n" if ($counter == 0);
     my $ctr = 0;
     while ($ctr < scalar(@partlist)) {
 	$result.='<input type="hidden" name="partid'.$counter.'_'.$ctr.'" value="'.
@@ -1773,12 +1787,13 @@
 	if ($ENV{'form.submitonly'} eq 'yes') {
 	    my %record = &Apache::lonnet::restore($symb,$ENV{'request.course.id'},$udom,$uname);
 	    my $statusflg = '';
-	    foreach (split(/:/,$ENV{'form.partlist0'})){
-		$statusflg = 1 if (exists ($record{'resource.'.$_.'.solved'}));
+	    foreach (split(/:/,$ENV{'form.gradePartRespid'})){
+		$statusflg = 1 if (exists ($record{'resource.'.$_.'.submission'}));
 	    }
 	    next if ($statusflg eq '');
 	}
 	push @nextlist,$student if ($ctr < $ntstu);
+	last if ($ctr == $ntstu);
 	$ctr++;
     }
 
@@ -2116,7 +2131,7 @@
     $result.= '<h3>Assign Grade to Specific Students in '.$sectionClass;
     $result.= '<table border=0><tr><td bgcolor="#777777">'."\n".
 	'<table border=0><tr bgcolor="#deffff"><td>&nbsp;<b>No.</b>&nbsp;</td>'.
-	'<td>&nbsp;<b>Fullname</b> <font color="#999999">(Username)</font></td>'."\n";
+	'<td>'.&nameUserString('header')."</td>\n";
     my (@parts) = sort(&getpartlist($url));
     foreach my $part (@parts) {
 	my $display=&Apache::lonnet::metadata($url,$part.'.display');
@@ -2216,8 +2231,9 @@
     $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>&nbsp;<b>No.</b>&nbsp;</td>'.
-	'<td rowspan=2>&nbsp;<b>Fullname</b>&nbsp;<font color="#999999">(username)</font></td>'."\n";
+    $result.= '<table border="0"><tr bgcolor="#deffff">'.
+	'<td rowspan=2 valign="center">&nbsp;<b>No.</b>&nbsp;</td>'.
+	'<td rowspan=2 valign="center">'.&nameUserString('header')."</td>\n";
 
     my %scoreptr = (
 		    'correct'  =>'correct_by_override',
@@ -2276,8 +2292,7 @@
 	my ($uname,$udom)=split(/_/,$user);
 	my %newrecord;
 	my $updateflag = 0;
-	$line .= '<td>&nbsp;'.$$fullname{$usercolon}.
-	    '&nbsp<font color="#999999">('.$uname.($udom eq $ENV{'user.domain'} ? '' : '$udom').')</font></td>';
+	$line .= '<td>'.&nameUserString(undef,$$fullname{$usercolon},$uname,$udom).'</td>';
 	my $usec=$classlist->{"$uname:$udom"}[5];
 	if (!&canmodify($usec)) {
 	    my $numcols=scalar(@partid)*4+2;
@@ -2756,9 +2771,9 @@
 	'<table border="0"><tr><td bgcolor="#777777">'.
 	'<table border="0"><tr bgcolor="#e6ffff">'.
 	'<td align="right">&nbsp;<b>No.</b></td>'.
-	'<td><b>&nbsp;Fullname <font color="#999999">(username)</font></b></td>'.
+	'<td>'.&nameUserString('header').'</td>'.
 	'<td align="right">&nbsp;<b>No.</b></td>'.
-	'<td><b>&nbsp;Fullname <font color="#999999">(username)</font></b></td></tr>';
+	'<td>'.&nameUserString('header').'</td></tr>';
  
     my (undef,undef,$fullname) = &getclasslist($getsec,'1');
     my $ptr = 1;
@@ -2766,8 +2781,8 @@
 	my ($uname,$udom) = split(/:/,$student);
 	$studentTable.=($ptr%2 == 1 ? '<tr bgcolor="#ffffe6">' : '</td>');
 	$studentTable.='<td align="right">'.$ptr.'&nbsp;</td>';
-	$studentTable.='<td>&nbsp;<input type="radio" name="student" value="'.$student.'" /> '.$$fullname{$student}.
-	    '<font color="#999999"> ('.$uname.($udom eq $cdom ? '':':'.$udom).')</font>'."\n";
+	$studentTable.='<td>&nbsp;<input type="radio" name="student" value="'.$student.'" /> '
+	    .&nameUserString(undef,$$fullname{$student},$uname,$udom)."\n";
 	$studentTable.=($ptr%2 == 0 ? '</td></tr>' : '');
 	$ptr++;
     }
@@ -2826,9 +2841,8 @@
 	return;
     }
     my $result='<h3><font color="#339933">&nbsp;'.$ENV{'form.title'}.'</font></h3>';
-    $result.='<h3>&nbsp;Student: '.$$fullname{$ENV{'form.student'}}.
-	'<font color="#999999"> ('.$uname.($udom eq $cdom ? '':':'.$udom).')</font></h3>'."\n";
-
+    $result.='<h3>&nbsp;Student: '.&nameUserString(undef,$$fullname{$ENV{'form.student'}},$uname,$udom).
+	'</h3>'."\n";
     &sub_page_js($request);
     $request->print($result);
 
@@ -2990,8 +3004,8 @@
 	return;
     }
     my $result='<h3><font color="#339933">&nbsp;'.$ENV{'form.title'}.'</font></h3>';
-    $result.='<h3>&nbsp;Student: '.$ENV{'form.fullname'}.
-	'<font color="#999999"> ('.$uname.($udom eq $cdom ? '':':'.$udom).')</font></h3>'."\n";
+    $result.='<h3>&nbsp;Student: '.&nameUserString(undef,$ENV{'form.fullname'},$uname,$udom).
+	'</h3>'."\n";
 
     $request->print($result);
 

--ng1059664121--