--- loncom/homework/grades.pm	2007/10/25 20:05:52	1.464
+++ loncom/homework/grades.pm	2007/10/30 01:04:31	1.472
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # The LON-CAPA Grading handler
 #
-# $Id: grades.pm,v 1.464 2007/10/25 20:05:52 albertel Exp $
+# $Id: grades.pm,v 1.472 2007/10/30 01:04:31 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -332,8 +332,8 @@ sub cleanRecord {
 	    $bottomrow.='<td>'.$grayFont.$foil.'</span>&nbsp;</td>';
 	}
 	return '<blockquote><table border="1">'.
-	    '<tr valign="top"><td>Answer</td>'.$toprow.'</tr>'.
-	    '<tr valign="top"><td>'.$grayFont.'Option ID</span></td>'.
+	    '<tr valign="top"><td>'.&mt('Answer').'</td>'.$toprow.'</tr>'.
+	    '<tr valign="top"><td>'.$grayFont.&mt('Option ID').'</span></td>'.
 	    $grayFont.$bottomrow.'</tr>'.'</table></blockquote>';
     } elsif ($response eq 'match') {
 	my %answer=&Apache::lonnet::str2hash($answer);
@@ -352,10 +352,10 @@ sub cleanRecord {
 	    $bottomrow.='<td>'.$grayFont.$foil.'</span>&nbsp;</td>';
 	}
 	return '<blockquote><table border="1">'.
-	    '<tr valign="top"><td>Answer</td>'.$toprow.'</tr>'.
-	    '<tr valign="top"><td>'.$grayFont.'Item ID</span></td>'.
+	    '<tr valign="top"><td>'.&mt('Answer').'</td>'.$toprow.'</tr>'.
+	    '<tr valign="top"><td>'.$grayFont.&mt('Item ID').'</span></td>'.
 	    $middlerow.'</tr>'.
-	    '<tr valign="top"><td>'.$grayFont.'Option ID</span></td>'.
+	    '<tr valign="top"><td>'.$grayFont.&mt('Option ID').'</span></td>'.
 	    $bottomrow.'</tr>'.'</table></blockquote>';
     } elsif ($response eq 'radiobutton') {
 	my %answer=&Apache::lonnet::str2hash($answer);
@@ -365,18 +365,18 @@ sub cleanRecord {
 	foreach my $foil (@$order) {
 	    if (exists($answer{$foil})) {
 		if ($foil eq $correct) {
-		    $toprow.='<td><b>true</b></td>';
+		    $toprow.='<td><b>'.&mt('true').'</b></td>';
 		} else {
-		    $toprow.='<td><i>true</i></td>';
+		    $toprow.='<td><i>'.&mt('true').'</i></td>';
 		}
 	    } else {
-		$toprow.='<td>false</td>';
+		$toprow.='<td>'.&mt('false').'</td>';
 	    }
 	    $bottomrow.='<td>'.$grayFont.$foil.'</span>&nbsp;</td>';
 	}
 	return '<blockquote><table border="1">'.
-	    '<tr valign="top"><td>Answer</td>'.$toprow.'</tr>'.
-	    '<tr valign="top"><td>'.$grayFont.'Option ID</span></td>'.
+	    '<tr valign="top"><td>'.&mt('Answer').'</td>'.$toprow.'</tr>'.
+	    '<tr valign="top"><td>'.$grayFont.&mt('Option ID').'</span></td>'.
 	    $grayFont.$bottomrow.'</tr>'.'</table></blockquote>';
     } elsif ($response eq 'essay') {
 	if (! exists ($env{'form.'.$symb})) {
@@ -1480,43 +1480,43 @@ INNERJS
 
     pDoc.write("<form action=\\"inactive\\" name=\\"msgcenter\\">");
     pDoc.write("<input value=\\""+usrctr+"\\" name=\\"usrctr\\" type=\\"hidden\\">");
-    pDoc.write("<h3><span class=\\"LC_info\\">&nbsp;Compose Message for \"+fullname+\"</span></h3><br /><br />");
+    pDoc.write("<h3><span class=\\"LC_info\\">&nbsp;Compose Message for \"+fullname+\"<\\/span><\\/h3><br /><br />");
 
     pDoc.write("<table border=0 width=100%><tr><td bgcolor=\\"#777777\\">");
     pDoc.write("<table border=0 width=100%><tr bgcolor=\\"#ddffff\\">");
-    pDoc.write("<td><b>Type</b></td><td><b>Include</b></td><td><b>Message</td></tr>");
+    pDoc.write("<td><b>Type<\\/b><\\/td><td><b>Include<\\/b><\\/td><td><b>Message<\\/td><\\/tr>");
 }
     function displaySubject(msg,shwsel) {
     pDoc = pWin.document;
     pDoc.write("<tr bgcolor=\\"#ffffdd\\">");
-    pDoc.write("<td>Subject</td>");
-    pDoc.write("<td align=\\"center\\"><input name=\\"subchk\\" type=\\"checkbox\\"" +shwsel+"></td>");
-    pDoc.write("<td><input name=\\"msgsub\\" type=\\"text\\" value=\\""+msg+"\\"size=\\"60\\" maxlength=\\"80\\"></td></tr>");
+    pDoc.write("<td>Subject<\\/td>");
+    pDoc.write("<td align=\\"center\\"><input name=\\"subchk\\" type=\\"checkbox\\"" +shwsel+"><\\/td>");
+    pDoc.write("<td><input name=\\"msgsub\\" type=\\"text\\" value=\\""+msg+"\\"size=\\"60\\" maxlength=\\"80\\"><\\/td><\\/tr>");
 }
 
   function displaySavedMsg(ctr,msg,shwsel) {
     pDoc = pWin.document;
     pDoc.write("<tr bgcolor=\\"#ffffdd\\">");
-    pDoc.write("<td align=\\"center\\">"+ctr+"</td>");
-    pDoc.write("<td align=\\"center\\"><input name=\\"msgn"+ctr+"\\" type=\\"checkbox\\"" +shwsel+"></td>");
-    pDoc.write("<td><textarea name=\\"msg"+ctr+"\\" cols=\\"60\\" rows=\\"3\\">"+msg+"</textarea></td></tr>");
+    pDoc.write("<td align=\\"center\\">"+ctr+"<\\/td>");
+    pDoc.write("<td align=\\"center\\"><input name=\\"msgn"+ctr+"\\" type=\\"checkbox\\"" +shwsel+"><\\/td>");
+    pDoc.write("<td><textarea name=\\"msg"+ctr+"\\" cols=\\"60\\" rows=\\"3\\">"+msg+"<\\/textarea><\\/td><\\/tr>");
 }
 
   function newMsg(newmsg,shwsel) {
     pDoc = pWin.document;
     pDoc.write("<tr bgcolor=\\"#ffffdd\\">");
-    pDoc.write("<td align=\\"center\\">New</td>");
-    pDoc.write("<td align=\\"center\\"><input name=\\"newmsgchk\\" type=\\"checkbox\\"" +shwsel+"></td>");
-    pDoc.write("<td><textarea name=\\"newmsg\\" cols=\\"60\\" rows=\\"3\\" onchange=\\"javascript:this.form.newmsgchk.checked=true\\" >"+newmsg+"</textarea></td></tr>");
+    pDoc.write("<td align=\\"center\\">New<\\/td>");
+    pDoc.write("<td align=\\"center\\"><input name=\\"newmsgchk\\" type=\\"checkbox\\"" +shwsel+"><\\/td>");
+    pDoc.write("<td><textarea name=\\"newmsg\\" cols=\\"60\\" rows=\\"3\\" onchange=\\"javascript:this.form.newmsgchk.checked=true\\" >"+newmsg+"<\\/textarea><\\/td><\\/tr>");
 }
 
   function msgTail() {
     pDoc = pWin.document;
-    pDoc.write("</table>");
-    pDoc.write("</td></tr></table>&nbsp;");
+    pDoc.write("<\\/table>");
+    pDoc.write("<\\/td><\\/tr><\\/table>&nbsp;");
     pDoc.write("<input type=\\"button\\" value=\\"Save\\" onClick=\\"javascript:checkInput()\\">&nbsp;&nbsp;");
     pDoc.write("<input type=\\"button\\" value=\\"Cancel\\" onClick=\\"self.close()\\"><br /><br />");
-    pDoc.write("</form>");
+    pDoc.write("<\\/form>");
     pDoc.write('$end_page_msg_central');
     pDoc.close();
 }
@@ -1565,32 +1565,32 @@ INNERJS
     hDoc.$docopen;
     hDoc.write('$start_page_highlight_central');
     hDoc.write("<form action=\\"inactive\\" name=\\"hlCenter\\">");
-    hDoc.write("<h3><span class=\\"LC_info\\">&nbsp;Keyword Highlight Options</span></h3><br /><br />");
+    hDoc.write("<h3><span class=\\"LC_info\\">&nbsp;Keyword Highlight Options<\\/span><\\/h3><br /><br />");
 
     hDoc.write("<table border=0 width=100%><tr><td bgcolor=\\"#777777\\">");
     hDoc.write("<table border=0 width=100%><tr bgcolor=\\"#ddffff\\">");
-    hDoc.write("<td><b>Text Color</b></td><td><b>Font Size</b></td><td><b>Font Style</td></tr>");
+    hDoc.write("<td><b>Text Color<\\/b><\\/td><td><b>Font Size<\\/b><\\/td><td><b>Font Style<\\/td><\\/tr>");
   }
 
   function highlightbody(clrval,clrtxt,clrsel,szval,sztxt,szsel,syval,sytxt,sysel) { 
     var hDoc = hwdWin.document;
     hDoc.write("<tr bgcolor=\\"#ffffdd\\">");
     hDoc.write("<td align=\\"left\\">");
-    hDoc.write("<input name=\\"kwdclr\\" type=\\"radio\\" value=\\""+clrval+"\\" "+clrsel+">&nbsp;"+clrtxt+"</td>");
+    hDoc.write("<input name=\\"kwdclr\\" type=\\"radio\\" value=\\""+clrval+"\\" "+clrsel+">&nbsp;"+clrtxt+"<\\/td>");
     hDoc.write("<td align=\\"left\\">");
-    hDoc.write("<input name=\\"kwdsize\\" type=\\"radio\\" value=\\""+szval+"\\" "+szsel+">&nbsp;"+sztxt+"</td>");
+    hDoc.write("<input name=\\"kwdsize\\" type=\\"radio\\" value=\\""+szval+"\\" "+szsel+">&nbsp;"+sztxt+"<\\/td>");
     hDoc.write("<td align=\\"left\\">");
-    hDoc.write("<input name=\\"kwdstyle\\" type=\\"radio\\" value=\\""+syval+"\\" "+sysel+">&nbsp;"+sytxt+"</td>");
-    hDoc.write("</tr>");
+    hDoc.write("<input name=\\"kwdstyle\\" type=\\"radio\\" value=\\""+syval+"\\" "+sysel+">&nbsp;"+sytxt+"<\\/td>");
+    hDoc.write("<\\/tr>");
   }
 
   function highlightend() { 
     var hDoc = hwdWin.document;
-    hDoc.write("</table>");
-    hDoc.write("</td></tr></table>&nbsp;");
+    hDoc.write("<\\/table>");
+    hDoc.write("<\\/td><\\/tr><\\/table>&nbsp;");
     hDoc.write("<input type=\\"button\\" value=\\"Save\\" onClick=\\"javascript:updateChoice(1)\\">&nbsp;&nbsp;");
     hDoc.write("<input type=\\"button\\" value=\\"Cancel\\" onClick=\\"self.close()\\"><br /><br />");
-    hDoc.write("</form>");
+    hDoc.write("<\\/form>");
     hDoc.write('$end_page_highlight_central');
     hDoc.close();
   }
@@ -1615,13 +1615,13 @@ sub gradeBox {
 	'" src="'.$request->dir_config('lonIconsURL').
 	'/check.gif" height="16" border="0" />';
     my $wgt    = &Apache::lonnet::EXT('resource.'.$partid.'.weight',$symb,$udom,$uname);
-    my $wgtmsg = ($wgt > 0 ? '(problem weight)' : 
-		  '<span class="LC_info">problem weight assigned by computer</span>');
+    my $wgtmsg = ($wgt > 0) ? &mt('(problem weight)') 
+                           : '<span class="LC_info">'.&mt('problem weight assigned by computer').'</span>';
     $wgt       = ($wgt > 0 ? $wgt : '1');
     my $score  = ($$record{'resource.'.$partid.'.awarded'} eq '' ?
 		  '' : &compute_points($$record{'resource.'.$partid.'.awarded'},$wgt));
     my $result='<input type="hidden" name="WGT'.$counter.'_'.$partid.'" value="'.$wgt.'" />'."\n";
-    my $display_part=&get_display_part($partid,$symb);
+    my $display_part= &get_display_part($partid,$symb);
     my %last_resets = &get_last_resets($symb,$env{'request.course.id'},
 				       [$partid]);
     my $aggtries = $$record{'resource.'.$partid.'.tries'};
@@ -1703,7 +1703,7 @@ sub handback_box {
     			 '<span class="LC_filename">'.$file_disp.'</span>');
     	        $result.='<input type="file"   name="'.$prefix.'returndoc'.$file_counter.'" />'."\n";
     	        $result.='<input type="hidden" name="'.$prefix.'origdoc'.$file_counter.'" value="'.$file.'" /><br />';
-    	        $result.='(File will be uploaded when you click on Save & Next below.)<br />';
+    	        $result.='(File will be uploaded when you click on Save &amp; Next below.)<br />';
     	        $file_counter++;
 	    }
 	}
@@ -1739,27 +1739,27 @@ sub show_problem {
 	$companswer=~s|</form>||g;
 	$companswer=~s|name="submit"|name="would_have_been_submit"|g;
     }
-    my $result.='<table border="0" width="100%"><tr><td bgcolor="#777777">';
-    $result.='<table border="0" width="100%">';
-    if ($viewon) {
-	$result.='<tr><td bgcolor="#e6ffff"><b> ';
-	if ($mode eq 'both' or $mode eq 'text') {
-	    $result.='View of the problem - ';
-	} else {
-	    $result.='Correct answer: ';
-	}
-	$result.=$env{'form.fullname'}.'</b></td></tr>';
-    }
+    $rendered=
+	'<div class="LC_grade_show_problem_header">'.
+	&mt('View of the problem').
+	'</div><div class="LC_grade_show_problem_problem">'.
+	$rendered.
+	'</div>';
+    $companswer=
+	'<div class="LC_grade_show_problem_header">'.
+	&mt('Correct answer').
+	'</div><div class="LC_grade_show_problem_problem">'.
+	$companswer.
+	'</div>';
+    my $result;
     if ($mode eq 'both') {
-	$result.='<tr><td bgcolor="#ffffff">'.$rendered.'<br />';
-	$result.='<b>Correct answer:</b><br />'.$companswer;
+	$result=$rendered.$companswer;
     } elsif ($mode eq 'text') {
-	$result.='<tr><td bgcolor="#ffffff">'.$rendered;
+	$result=$rendered;
     } elsif ($mode eq 'answer') {
-	$result.='<tr><td bgcolor="#ffffff">'.$companswer;
+	$result=$companswer;
     }
-    $result.='</td></tr></table>';
-    $result.='</td></tr></table><br />';
+    $result='<div class="LC_grade_show_problem">'.$result.'</div>';
     return $result;
 }
 
@@ -1852,12 +1852,6 @@ sub submission {
 	$request->print('<h3>&nbsp;<span class="LC_info">Submission Record</span></h3>'."\n".
 			'<h4>&nbsp;<b>Resource: </b>'.$env{'form.probTitle'}.'</h4>'."\n");
 
-	if ($env{'form.handgrade'} eq 'no') {
-	    my $checkMark='<br /><br />&nbsp;<b>Note:</b> Part(s) graded correct by the computer is marked with a '.
-		$checkIcon.' symbol.'."\n";
-	    $request->print($checkMark);
-	}
-
 	# option to display problem, only once else it cause problems 
         # with the form later since the problem has a form.
 	if ($env{'form.vProb'} eq 'yes' or $env{'form.vAns'} eq 'yes') {
@@ -1959,10 +1953,11 @@ KEYWORDS
     }
 
 # This is where output for one specific student would start
-    my $bgcolor='#DDEEDD';
-    if ($counter%2) { $bgcolor='#DDDDEE'; }
+    my $add_class = ($counter%2) ? 'LC_grade_show_user_odd_row' : '';
     $request->print("\n\n".
-                    '<p><table border="2"><tr><th bgcolor="'.$bgcolor.'">'.$env{'form.fullname'}.'</th></tr><tr><td bgcolor="'.$bgcolor.'">');
+                    '<div class="LC_grade_show_user '.$add_class.'">'.
+		    '<div class="LC_grade_user_name">'.&nameUserString(undef,$env{'form.fullname'},$uname,$udom).'</div>'.
+		    '<div class="LC_grade_show_user_body">'."\n");
 
     if ($env{'form.vProb'} eq 'all' or $env{'form.vAns'} eq 'all') {
 	my $mode;
@@ -1982,12 +1977,19 @@ KEYWORDS
 
     # Display student info
     $request->print(($counter == 0 ? '' : '<br />'));
-    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>'.&nameUserString(undef,$env{'form.fullname'},$uname,$udom).'<br />'."\n";
+    my $result='<div class="LC_grade_submissions">';
+    
+    $result.='<div class="LC_grade_submissions_header">';
+    $result.= &mt('Submissions');
     $result.='<input type="hidden" name="name'.$counter.
 	'" value="'.$env{'form.fullname'}.'" />'."\n";
+    if ($env{'form.handgrade'} eq 'no') {
+	$result.='<span class="LC_grade_check_note">'.
+	    &mt('Part(s) graded correct by the computer is marked with a [_1] symbol.',$checkIcon)."</span>\n";
+
+    }
+
+
 
     # If any part of the problem is an essay-response (handgraded), then check for collaborators
     my $fullname;
@@ -1999,7 +2001,7 @@ KEYWORDS
 	$result.=$sub_result;
     }
     $request->print($result."\n");
-
+    $request->print('</div>'."\n");
     # print student answer/submission
     # Options are (1) Handgaded submission only
     #             (2) Last submission, includes submission that is not handgraded 
@@ -2008,12 +2010,14 @@ KEYWORDS
     #             (4) The whole record for this student
     if ($env{'form.lastSub'} =~ /^(lastonly|hdgrade)$/) {
 	my ($string,$timestamp)= &get_last_submission(\%record);
-	my $lastsubonly=''.
-	    ($$timestamp eq '' ? '' : '<b>Date Submitted:</b> '.
-	     $$timestamp)."</td></tr>\n";
+	
+	my $lastsubonly;
+
 	if ($$timestamp eq '') {
-	    $lastsubonly.='<tr><td bgcolor="#ffffe6">'.$$string[0]; 
+	    $lastsubonly.='<div class="LC_grade_submissions_body">'.$$string[0].'</div>'; 
 	} else {
+	    $lastsubonly = '<div class="LC_grade_submissions_body"> <b>Date Submitted:</b> '.$$timestamp."\n";
+
 	    my %seenparts;
 	    my @part_response_id = &flatten_responseType($responseType);
 	    foreach my $part (@part_response_id) {
@@ -2036,16 +2040,16 @@ KEYWORDS
 		}
 		my $responsetype = $responseType->{$partid}->{$respid};
 		if (!exists($record{"resource.$partid.$respid.submission"})) {
-		    $lastsubonly.='<tr><td bgcolor="#ffffe6"><b>Part:</b> '.
+		    $lastsubonly.="\n".'<div class="LC_grade_submission_part"><b>Part:</b> '.
 			$display_part.' <span class="LC_internal_info">( ID '.$respid.
 			' )</span>&nbsp; &nbsp;'.
-			'<span class="LC_warning">Nothing submitted - no attempts</span><br /><br />';
+			'<span class="LC_warning">'.&mt('Nothing submitted - no attempts').'</span><br /><br /></div>';
 		    next;
 		}
-		foreach (@$string) {
-		    my ($partid,$respid) = /^resource\.([^\.]*)\.([^\.]*)\.submission/;
+		foreach my $submission (@$string) {
+		    my ($partid,$respid) = ($submission =~ /^resource\.([^\.]*)\.([^\.]*)\.submission/);
 		    if (join('_',@{$part}) ne ($partid.'_'.$respid)) { next; }
-		    my ($ressub,$subval) = split(/:/,$_,2);
+		    my ($ressub,$subval) = split(/:/,$submission,2);
 		    # Similarity check
 		    my $similar='';
 		    if($env{'form.checkPlag'}){
@@ -2075,31 +2079,32 @@ KEYWORDS
 			($env{'form.lastSub'} eq 'hdgrade' && 
 			 $$handgrade{$$part[0].'_'.$$part[1]} eq 'yes')) {
 			my $display_part=&get_display_part($partid,$symb);
-			$lastsubonly.='<tr><td bgcolor="#ffffe6"><b>Part:</b> '.
+			$lastsubonly.='<div class="LC_grade_submission_part"><b>Part:</b> '.
 			    $display_part.' <span class="LC_internal_info">( ID '.$respid.
 			    ' )</span>&nbsp; &nbsp;';
 			my $files=&get_submitted_files($udom,$uname,$partid,$respid,\%record);
 			if (@$files) {
-			    $lastsubonly.='<br /><span class="LC_warning">Like all files provided by users, this file may contain virusses</span><br />';
+			    $lastsubonly.='<br /><span class="LC_warning">'.&mt('Like all files provided by users, this file may contain virusses').'</span><br />';
 			    my $file_counter = 0;
 			    foreach my $file (@$files) {
-			        $file_counter ++;
+			        $file_counter++;
 				&Apache::lonnet::allowuploaded('/adm/grades',$file);
 				$lastsubonly.='<br /><a href="'.$file.'?rawmode=1" target="lonGRDs"><img src="'.&Apache::loncommon::icon($file).'" border=0"> '.$file.'</a>';
 			    }
 			    $lastsubonly.='<br />';
 			}
-			$lastsubonly.='<b>Submitted Answer: </b>'.
+			$lastsubonly.='<b>'.&mt('Submitted Answer:').' </b>'.
 			    &cleanRecord($subval,$responsetype,$symb,$partid,
 					 $respid,\%record,$order);
 			if ($similar) {$lastsubonly.="<br /><br />$similar\n";}
+			$lastsubonly.='</div>';
 		    }
 		}
 	    }
+	    $lastsubonly.='</div>'."\n";
 	}
-	$lastsubonly.='</td></tr><tr bgcolor="#ffffff"><td>'."\n";
 	$request->print($lastsubonly);
-    } elsif ($env{'form.lastSub'} eq 'datesub') {
+   } elsif ($env{'form.lastSub'} eq 'datesub') {
 	my (undef,$responseType,undef,$parts) = &showResourceInfo($symb);
 	$request->print(&displaySubByDates($symb,\%record,$parts,$responseType,$checkIcon,$uname,$udom));
     } elsif ($env{'form.lastSub'} =~ /^(last|all)$/) {
@@ -2111,13 +2116,12 @@ KEYWORDS
 
     $request->print('<input type="hidden" name="unamedom'.$counter.'" value="'.$uname.':'
 	.$udom.'" />'."\n");
-    
     # return if view submission with no grading option
     if ($env{'form.showgrading'} eq '' || (!&canmodify($usec))) {
 	my $toGrade.='<input type="button" value="Grade Student" '.
 	    'onClick="javascript:checksubmit(this.form,\'Grade Student\',\''
 	    .$counter.'\');" target="_self" /> &nbsp;'."\n" if (&canmodify($usec));
-	$toGrade.='</td></tr></table></td></tr></table>'."\n";
+	$toGrade.='</div>'."\n";
 	if (($env{'form.command'} eq 'submission') || 
 	    ($env{'form.command'} eq 'processGroup' && $counter == $total)) {
 	    $toGrade.='</form>'.&show_grading_menu_form($symb); 
@@ -2125,11 +2129,15 @@ KEYWORDS
 	$request->print($toGrade);
 	return;
     } else {
-	$request->print('</td></tr></table></td></tr></table>'."\n");
+	$request->print('</div>'."\n");
     }
 
     # essay grading message center
     if ($env{'form.handgrade'} eq 'yes') {
+	my $result='<div class="LC_grade_message_center">';
+    
+	$result.='<div class="LC_grade_message_center_header">'.
+	    &mt('Send Message').'</div><div class="LC_grade_message_center_body">';
 	my ($lastname,$givenn) = split(/,/,$env{'form.fullname'});
 	my $msgfor = $givenn.' '.$lastname;
 	if (scalar(@$col_fullnames) > 0) {
@@ -2137,7 +2145,7 @@ KEYWORDS
 	    $msgfor .= ', '.(join ', ',@$col_fullnames).' and '.$lastone.'.';
 	}
 	$msgfor =~ s/\'/\\'/g; #' stupid emacs - no! javascript
-	$result='<input type="hidden" name="includemsg'.$counter.'" value="" />'."\n".
+	$result.='<input type="hidden" name="includemsg'.$counter.'" value="" />'."\n".
 	    '<input type="hidden" name="newmsg'.$counter.'" value="" />'."\n";
 	$result.='&nbsp;<a href="javascript:msgCenter(document.SCORE,'.$counter.
 	    ',\''.$msgfor.'\');" target="_self">'.
@@ -2146,24 +2154,20 @@ KEYWORDS
 	    '<img src="'.$request->dir_config('lonIconsURL').
 	    '/mailbkgrd.gif" width="14" height="10" name="mailicon'.$counter.'" />'."\n".
 	    '<br />&nbsp;('.
-	    &mt('Message will be sent when you click on Save & Next below.').")\n";
+	    &mt('Message will be sent when you click on Save &amp; Next below.').")\n";
+	$result.='</div></div>';
 	$request->print($result);
     }
-    if ($perm{'vgr'}) {
-	$request->print('<br />'.
-	    &Apache::loncommon::track_student_link(&mt('View recent activity'),
-						   $uname,$udom,'check'));
-    }
-    if ($perm{'opa'}) {
-	$request->print('<br />'.
-	    &Apache::loncommon::pprmlink(&mt('Set/Change parameters'),
-					 $uname,$udom,$symb,'check'));
-    }
 
     my %seen = ();
     my @partlist;
     my @gradePartRespid;
     my @part_response_id = &flatten_responseType($responseType);
+    $request->print('<div class="LC_grade_assign">'.
+		    
+		    '<div class="LC_grade_assign_header">'.
+		    &mt('Assign Grades').'</div>'.
+		    '<div class="LC_grade_assign_body">');
     foreach my $part_response_id (@part_response_id) {
     	my ($partid,$respid) = @{ $part_response_id };
 	my $part_resp = join('_',@{ $part_response_id });
@@ -2175,6 +2179,21 @@ KEYWORDS
 	push @gradePartRespid,$partid.'.'.$respid;
 	$request->print(&gradeBox($request,$symb,$uname,$udom,$counter,$partid,\%record));
     }
+    $request->print('</div></div>');
+
+    $request->print('<div class="LC_grade_info_links">');
+    if ($perm{'vgr'}) {
+	$request->print(
+	    &Apache::loncommon::track_student_link(&mt('View recent activity'),
+						   $uname,$udom,'check'));
+    }
+    if ($perm{'opa'}) {
+	$request->print(
+	    &Apache::loncommon::pprmlink(&mt('Set/Change parameters'),
+					 $uname,$udom,$symb,'check'));
+    }
+    $request->print('</div>');
+
     $result='<input type="hidden" name="partlist'.$counter.
 	'" value="'.(join ":",@partlist).'" />'."\n";
     $result.='<input type="hidden" name="gradePartRespid'.
@@ -2185,11 +2204,12 @@ KEYWORDS
 	    $partlist[$ctr].'" />'."\n";
 	$ctr++;
     }
-    $request->print($result.'</td></tr></table></td></tr></table>'."\n");
+    $request->print($result.''."\n");
 
 # Done with printing info for one student
 
-    $request->print('</td></tr></table></p>');
+    $request->print('</div>');#LC_grade_show_user_body
+    $request->print('</div>');#LC_grade_show_user
 
 
     # print end of form
@@ -2248,25 +2268,25 @@ sub check_collaborators {
 	    }
 	}
 	if (scalar(@good_collaborators) != 0) {
-	    $result.='<b>Collaborators: </b>';
+	    $result.='<br />'.&mt('Collaborators: ');
 	    foreach my $name (@good_collaborators) {
 		my ($lastname,$givenn) = split(/,/,$$fullname{$name});
 		push(@col_fullnames, $givenn.' '.$lastname);
 		$result.=$fullname->{$name}.'&nbsp; &nbsp; &nbsp;';
 	    }
 	    $result.='<br />'."\n";
-	    my ($part)=split(/\./,$_);
+	    my ($part)=split(/\./,$part);
 	    $result.='<input type="hidden" name="collaborator'.$counter.
 		'" value="'.$part.':'.(join ':',@good_collaborators).'" />'.
 		"\n";
 	}
 	if (scalar(@bad_collaborators) > 0) {
-	    $result.='<div class="LC_error">';
+	    $result.='<div class="LC_warning">';
 	    $result.=&mt('This student has submitted [quant,_1,invalid collaborator]: [_2]',scalar(@bad_collaborators),join(', ',@bad_collaborators));
 	    $result .= '</div>';
 	}         
 	if (scalar(@bad_collaborators > $ncol)) {
-	    $result .= '<div class="LC_error">';
+	    $result .= '<div class="LC_warning">';
 	    $result .= &mt('This student has submitted too many '.
 		'collaborators.  Maximum is [_1].',$ncol);
 	    $result .= '</div>';
@@ -4273,30 +4293,33 @@ sub displaySubByDates {
     my $isCODE=0;
     my $isTask = ($symb =~/\.task$/);
     if (exists($record->{'resource.CODE'})) { $isCODE=1; }
-    my $studentTable='<table border="0" width="100%"><tr><td bgcolor="#777777">'.
-	'<table border="0" width="100%"><tr bgcolor="#e6ffff">'.
-	'<td><b>Date/Time</b></td>'.
-	($isCODE?'<td><b>CODE</b></td>':'').
-	'<td><b>Submission</b></td>'.
-	'<td><b>Status&nbsp;</b></td></tr>';
+    my $studentTable=&Apache::loncommon::start_data_table().
+	&Apache::loncommon::start_data_table_header_row().
+	'<th>'.&mt('Date/Time').'</th>'.
+	($isCODE?'<th>'.&mt('CODE').'</th>':'').
+	'<th>'.&mt('Submission').'</th>'.
+	'<th>'.&mt('Status').'</th>'.
+	&Apache::loncommon::end_data_table_header_row();
     my ($version);
     my %mark;
     my %orders;
     $mark{'correct_by_student'} = $checkIcon;
     if (!exists($$record{'1:timestamp'})) {
-	return '<br />&nbsp;<span class="LC_warning">Nothing submitted - no attempts</span><br />';
+	return '<br />&nbsp;<span class="LC_warning">'.&mt('Nothing submitted - no attempts').'</span><br />';
     }
 
     my $interaction;
     for ($version=1;$version<=$$record{'version'};$version++) {
-	my $timestamp = scalar(localtime($$record{$version.':timestamp'}));
+	my $timestamp = 
+	    &Apache::lonlocal::locallocaltime($$record{$version.':timestamp'});
 	if (exists($$record{$version.':resource.0.version'})) {
 	    $interaction = $$record{$version.':resource.0.version'};
 	}
 
 	my $where = ($isTask ? "$version:resource.$interaction"
 		             : "$version:resource");
-	$studentTable.='<tr bgcolor="#ffffff" valign="top"><td>'.$timestamp.'</td>';
+	$studentTable.=&Apache::loncommon::start_data_table_row().
+	    '<td>'.$timestamp.'</td>';
 	if ($isCODE) {
 	    $studentTable.='<td>'.$record->{$version.':resource.CODE'}.'</td>';
 	}
@@ -4315,14 +4338,14 @@ sub displaySubByDates {
 
 		    my ($responseId)= ($isTask ? ($matchKey=~ /^resource\.(.*?)\.\Q$partid\E\.award$/)
 				               : ($matchKey=~ /^resource\.\Q$partid\E\.(.*?)\.submission$/));
-		    $displaySub[0].='<b>Part:</b>&nbsp;'.$display_part.'&nbsp;';
-		    $displaySub[0].='<span class="LC_internal_info">(ID&nbsp;'.
+		    $displaySub[0].='<b>'.&mt('Part:').'</b>&nbsp;'.$display_part.'&nbsp;';
+		    $displaySub[0].='<span class="LC_internal_info">('.&mt('ID').'&nbsp;'.
 			$responseId.')</span>&nbsp;<b>';
 		    if ($$record{"$where.$partid.tries"} eq '') {
-			$displaySub[0].='Trial&nbsp;not&nbsp;counted';
+			$displaySub[0].=&mt('Trial&nbsp;not&nbsp;counted');
 		    } else {
-			$displaySub[0].='Trial&nbsp;'.
-			    $$record{"$where.$partid.tries"};
+			$displaySub[0].=&mt('Trial&nbsp;[_1]',
+					    $$record{"$where.$partid.tries"});
 		    }
 		    my $responseType=($isTask ? 'Task'
                                               : $responseType->{$partid}->{$responseId});
@@ -4362,12 +4385,12 @@ sub displaySubByDates {
 	}
 	$studentTable.='<td>'.$displaySub[0].'&nbsp;</td><td>'.$displaySub[1];
 	if ($displaySub[2]) {
-	    $studentTable.='Manually graded by '.$displaySub[2];
+	    $studentTable.=&mt('Manually graded by [_1]',$displaySub[2]);
 	}
-	$studentTable.='&nbsp;</td></tr>';
-    
+	$studentTable.='&nbsp;</td>'.
+	    &Apache::loncommon::end_data_table_row();
     }
-    $studentTable.='</table></td></tr></table>';
+    $studentTable.=&Apache::loncommon::end_data_table();
     return $studentTable;
 }
 
@@ -5216,6 +5239,7 @@ sub scan_data {
 
 sub scantron_parse_scanline {
     my ($line,$whichline,$scantron_config,$scan_data,$just_header)=@_;
+
     my %record;
     my $questions=substr($line,$$scantron_config{'Qstart'}-1);  # Answers
     my $data=substr($line,0,$$scantron_config{'Qstart'}-1);     # earlier stuff
@@ -5254,7 +5278,9 @@ sub scantron_parse_scanline {
     my $questnum=0;
     my $ansnum  =1;		# Multiple 'answer lines'/question.
 
-    while ($questions) {
+    chomp($questions);		# Get rid of any trailing \n.
+    $questions =~ s/\r$//;      # Get rid of trailing \r too (MAC or Win uploads).
+    while (length($questions)) {
 	my $answers_needed = $bubble_lines_per_response{$questnum};
 	my $answer_length  = $$scantron_config{'Qlength'} * $answers_needed;
 
@@ -5297,9 +5323,8 @@ sub scantron_parse_scanline {
 		}
 		if (!&scan_data($scan_data,"$whichline.no_bubble.$questnum")) {
 		    push(@{$record{"scantron.missingerror"}},$questnum);
-		    $ansnum += $answers_needed;
+		   #  $ansnum += $answers_needed;
 		}
-
 	    } else {
 		for (my $ans = 0; $ans < $answers_needed; $ans++) {
 		    $record{"scantron.$ansnum.answer"} = substr($currentquest, $ans, 1);
@@ -6457,7 +6482,8 @@ ENDSCRIPT
 		  join(',',@{$arg}).'" />');
 	foreach my $question (@{$arg}) {
 	    my $selected = &get_response_bubbles($scan_record, $question);
-	    &scantron_bubble_selector($r,$scan_config,$question);
+	    my @select_array = split(/:/,$selected); # ought to be an array of empties.
+	    &scantron_bubble_selector($r,$scan_config,$question, @select_array);
 	}
     } else {
 	$r->print("\n<ul>");
@@ -6477,7 +6503,7 @@ ENDSCRIPT
     $r           - Apache request object
     $scan_config - hash from &get_scantron_config()
     $quest       - number of the bubble line to make a corrector for
-    $lines       - array of answer lines.
+    @lines       - array of answer lines.
 
 =cut
 
@@ -6848,6 +6874,9 @@ sub scantron_validate_missingbubbles {
 						 $scan_data);
 	if (!defined($$scan_record{'scantron.missingerror'})) { next; }
 	my @to_correct;
+	
+	# Probably here's where the error is...
+
 	foreach my $missing (@{$$scan_record{'scantron.missingerror'}}) {
 	    if ($missing > $max_bubble) { next; }
 	    push(@to_correct,$missing);
@@ -7380,102 +7409,89 @@ GRADINGMENUJS
 	'<input type="hidden" name="gradingMenu" value="1" />'."\n".
 	'<input type="hidden" name="showgrading" value="yes" />'."\n";
 
-    $result.='<table border="0"><tr><td bgcolor=#777777>'."\n".
-	'<table width="100%" border="0"><tr bgcolor="#e6ffff"><td>'."\n".
-	'&nbsp;<b>Select a Grading/Viewing Option</b></td></tr>'."\n".
-	'<tr bgcolor="#ffffe6" valign="top"><td>'."\n";
-
-    $result.='<table width="100%" border="0">';
-    $result.='<tr bgcolor="#ffffe6" valign="top">'."\n";
-    $result.='<td><b>'.&mt('Sections').'</b></td>';
-    $result.='<td><b>'.&mt('Groups').'</b></td>';
-    $result.='<td><b>'.&mt('Access Status').'</td>'."\n";
-    $result.='<td><b>'.&mt('Submission Status').'</td>'."\n";
-    $result.='</tr>';
-    $result.='<tr bgcolor="#ffffe6" valign="top"><td>'."\n".
-	'&nbsp;<select name="section" multiple="multiple" size="3">'."\n";
+    $result.='
+    <div class="LC_grade_select_mode">
+      <div class="LC_grade_select_mode_header">
+        '.&mt('Select a Grading/Viewing Option').'
+      </div>
+      <div class="LC_grade_select_mode_body">
+        <div class="LC_grade_select_mode_selector">
+           <div class="LC_grade_select_mode_selector_header">
+              '.&mt('Sections').'
+           </div>
+           <div class="LC_grade_select_mode_selector_body">
+	    <select name="section" multiple="multiple" size="5">'."\n";
     if (ref($sections)) {
-	foreach (sort (@$sections)) {
-	    $result.='<option value="'.$_.'" '.
-		($saveSec eq $_ ? 'selected="selected"':'').'>'.$_.'</option>'."\n";
+	foreach my $section (sort (@$sections)) {
+	    $result.='<option value="'.$section.'" '.
+		($saveSec eq $section ? 'selected="selected"':'').'>'.$section.'</option>'."\n";
 	}
     }
     $result.= '<option value="all" '.($saveSec eq 'all' ? 'selected="selected"' : ''). '>all</option></select> &nbsp; ';
-    $result.= '</td><td>'."\n";
-    $result.= &Apache::lonstatistics::GroupSelect('group','multiple',3);
-    $result.='</td><td>'."\n";
-    $result.=&Apache::lonhtmlcommon::StatusOptions($saveStatus,undef,3,undef,'mult');
-
-    $result.='</td>';
-    $result.='<td><select name="submitonly" size="3">'.
-	'<option value="yes" '.
-	($saveSub eq 'yes' ? 'selected="selected"' : '').'>'.&mt('with submissions').'</option>'.
-	'<option value="queued" '.
-	($saveSub eq 'queued' ? 'selected="selected"' : '').'>'.&mt('in grading queue').'</option>'.
-	'<option value="graded" '.
-	($saveSub eq 'graded' ? 'selected="selected"' : '').'>'.&mt('with ungraded submissions').'</option>'.
-	'<option value="incorrect" '.
-	($saveSub eq 'incorrect' ? 'selected="selected"' : '').'>'.&mt('with incorrect submissions').'</option>'.
-	'<option value="all" '.
-	($saveSub eq 'all' ? 'selected="selected"' : '').'>'.&mt('with any status').'</option></select></td></tr>';
-
-    $result.='<tr bgcolor="#ffffe6"valign="top"><td colspan="3"><label>'.
-	'<input type="radio" name="radioChoice" value="submission" '.
-	($saveCmd eq 'submission' ? 'checked="checked"' : '').' /> '.'<b>'.&mt('Current Resource').':</b> '.&mt('For one or more students').
-	'</label> </td></tr>'."\n";
-
-    $result.='<tr bgcolor="#ffffe6"valign="top"><td colspan="3">'.
-	'<label><input type="radio" name="radioChoice" value="viewgrades" '.
+    $result.='
+           </div>
+        </div>
+        <div class="LC_grade_select_mode_selector">
+           <div class="LC_grade_select_mode_selector_header">
+              '.&mt('Groups').'
+           </div>
+           <div class="LC_grade_select_mode_selector_body">
+              '.&Apache::lonstatistics::GroupSelect('group','multiple',5).'
+           </div>
+        </div>
+        <div class="LC_grade_select_mode_selector">
+           <div class="LC_grade_select_mode_selector_header">
+              '.&mt('Access Status').'
+           </div>
+           <div class="LC_grade_select_mode_selector_body">
+              '.&Apache::lonhtmlcommon::StatusOptions($saveStatus,undef,5,undef,'mult').'
+           </div>
+        </div>
+        <div class="LC_grade_select_mode_selector">
+           <div class="LC_grade_select_mode_selector_header">
+              '.&mt('Submission Status').'
+           </div>
+           <div class="LC_grade_select_mode_selector_body">
+             <select name="submitonly" size="5">
+	       <option value="yes" '.      ($saveSub eq 'yes'       ? 'selected="selected"' : '').'>'.&mt('with submissions').'</option>
+	       <option value="queued" '.   ($saveSub eq 'queued'    ? 'selected="selected"' : '').'>'.&mt('in grading queue').'</option>
+	       <option value="graded" '.   ($saveSub eq 'graded'    ? 'selected="selected"' : '').'>'.&mt('with ungraded submissions').'</option>
+	       <option value="incorrect" '.($saveSub eq 'incorrect' ? 'selected="selected"' : '').'>'.&mt('with incorrect submissions').'</option>
+	       <option value="all" '.      ($saveSub eq 'all'       ? 'selected="selected"' : '').'>'.&mt('with any status').'</option>
+             </select>
+           </div>
+        </div>
+        <div class="LC_grade_select_mode_type_body">
+          <div class="LC_grade_select_mode_type">
+            <label>
+              <input type="radio" name="radioChoice" value="submission" '.
+	  ($saveCmd eq 'submission' ? 'checked="checked"' : '').' /> '.&mt('<b>Current Resource:</b> For one or more students').'
+	    </label> 
+          </div>
+          <div class="LC_grade_select_mode_type">
+	    <label>
+              <input type="radio" name="radioChoice" value="viewgrades" '.
 	($saveCmd eq 'viewgrades' ? 'checked="checked"' : '').' /> '.
-	'<b>Current Resource:</b> For all students in selected section or course</label></td></tr>'."\n";
-
-    $result.='<tr bgcolor="#ffffe6"><td colspan="3"><br />'.
-	'<input type="button" onClick="javascript:checkChoice(this.form,\'2\');" value="Next->" />'.
-	'</td></tr>'."\n";
-
-
-    $result.='<tr bgcolor="#ffffe6" valign="top"><td colspan="3">'.
-	'<br /><label><input type="radio" name="radioChoice" value="pickStudentPage" '.
+	&mt('<b>Current Resource:</b> For all students in selected section or course').'
+            </label>
+          </div>
+          <div class="LC_grade_select_mode_type">
+	    <input type="button" onClick="javascript:checkChoice(this.form,\'2\');" value="'.&mt('Next-&gt;').'" />
+          </div>
+          <div class="LC_grade_select_mode_type">
+            <label>
+              <input type="radio" name="radioChoice" value="pickStudentPage" '.
 	($saveCmd eq 'pickStudentPage' ? 'checked="checked"' : '').' /> '.
-	'The <b>complete</b> set/page/sequence/folder: For one student</label></td></tr>'."\n";
-
-    $result.='<tr bgcolor="#ffffe6"><td colspan="3"><br />'.
-	'<input type="button" onClick="javascript:checkChoice(this.form,\'2\');" value="Next->" />'.
-	'</td></tr></table>'."\n";
-
-    $result.='</td>'; #<td valign="top">';
-
-#    $result.='<table width="100%" border="0">';
-#    $result.='<tr bgcolor="#ffffe6"><td>'.
-#	'<input type="button" onClick="javascript:checkChoice(this.form,\'3\',\'csvform\');" value="'.&mt('Upload').'" />'.
-#	' '.&mt('scores from file').' </td></tr>'."\n";
-#
-#    $result.='<tr bgcolor="#ffffe6"><td>'.
-#        '<input type="button" onClick="javascript:checkChoice(this.form,\'6\',\'processclicker\');" value="'.&mt('Process').'" />'.
-#        ' '.&mt('clicker file').' </td></tr>'."\n";
-#
-#    $result.='<tr bgcolor="#ffffe6"valign="top"><td colspan="2">'.
-#	'<input type="button" onClick="javascript:checkChoice(this.form,\'4\',\'scantron_selectphase\');'.
-#	'" value="'.&mt('Grade').'" /> scantron forms</td></tr>'."\n";
-#
-#    if ((&Apache::lonnet::allowed('mgr',$env{'request.course.id'})) && ($symb)) {
-#	$result.='<tr bgcolor="#ffffe6"valign="top"><td>'.
-#	    '<input type="button" onClick="javascript:checkChoice(this.form,\'5\',\'verify\');" value="'.&mt('Verify').'" />'.
-#	    ' '.&mt('receipt').': '.
-#	    &Apache::lonnet::recprefix($env{'request.course.id'}).
-#	    '-<input type="text" name="receipt" size="4" onChange="javascript:checkReceiptNo(this.form,\'OK\')" />'.
-#	    '</td></tr>'."\n";
-#    } 
-#    $result.='<tr bgcolor="#ffffe6"valign="top"><td colspan="2">'.
-#	'<input type="button" onClick="javascript:this.form.action=\'/adm/helper/resettimes.helper\';this.form.submit();'.
-#	'" value="'.&mt('Manage').'" /> access times.</td></tr>'."\n";
-#    $result.='<tr bgcolor="#ffffe6"valign="top"><td colspan="2">'.
-#	'<input type="button" onClick="javascript:this.form.command.value=\'codelist\';this.form.action=\'/adm/pickcode\';this.form.submit();'.
-#	'" value="'.&mt('View').'" /> saved CODEs.</td></tr>'."\n";
-#
-#    $result.='</table>'."\n".'</td>';
-    $result.= '</tr></table>'."\n".
-	'</td></tr></table></form>'."\n";
+	&mt('The <b>complete</b> set/page/sequence/folder: For one student').'
+            </label>
+          </div>
+          <div class="LC_grade_select_mode_type">
+	    <input type="button" onClick="javascript:checkChoice(this.form,\'2\');" value="'.&mt('Next-&gt;').'" />
+          </div>
+        </div>
+      </div>
+    </div>
+  </form>';
     return $result;
 }