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

albertel lon-capa-cvs@mail.lon-capa.org
Mon, 28 Feb 2005 21:18:09 -0000


albertel		Mon Feb 28 16:18:09 2005 EDT

  Modified files:              
    /loncom/homework	grades.pm 
  Log:
  - most of bug #2652, Written by Ray Batchelor
  
  
Index: loncom/homework/grades.pm
diff -u loncom/homework/grades.pm:1.248 loncom/homework/grades.pm:1.249
--- loncom/homework/grades.pm:1.248	Fri Feb 18 18:36:12 2005
+++ loncom/homework/grades.pm	Mon Feb 28 16:18:08 2005
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # The LON-CAPA Grading handler
 #
-# $Id: grades.pm,v 1.248 2005/02/18 23:36:12 albertel Exp $
+# $Id: grades.pm,v 1.249 2005/02/28 21:18:08 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -96,7 +96,7 @@
 sub nameUserString {
     my ($type,$fullname,$uname,$udom) = @_;
     if ($type eq 'header') {
-	return '<b>&nbsp;Fullname&nbsp;</b><font color="#999999">(Username)</font>&nbsp;';
+	return '<b>&nbsp;Fullname&nbsp;</b><font color="#999999">(Username)</font>&nbsp;Section/Group';
     } else {
 	return '&nbsp;'.$fullname.'<font color="#999999">&nbsp;('.$uname.
 	    ($ENV{'user.domain'} eq $udom ? '' : ' ('.$udom.')').')</font>';
@@ -664,11 +664,15 @@
     $gradeTable.='To '.lc($viewgrade).' a submission or a group of submissions, click on the check box(es) '.
 	'next to the student\'s name(s). Then click on the Next button.<br />'."\n".
 	'<input type="hidden" name="command" value="processGroup" />'."\n";
+
+# checkall buttons
+    $gradeTable.=&check_script('gradesub', 'stuinfo');
     $gradeTable.='<input type="button" '."\n".
 	'onClick="javascript:checkSelect(this.form.stuinfo);" '."\n".
-	'value="Next->" />'."\n";
+	'value="Next->" /> <br />'."\n";
+    $gradeTable.=&check_buttons();
     $gradeTable.='<input type="checkbox" name="checkPlag" checked="on">Check For Plagiarism</input>';
-    my (undef, undef, $fullname) = &getclasslist($getsec,'1');  
+    my ($classlist, undef, $fullname) = &getclasslist($getsec,'1');
     $gradeTable.='<table border="0"><tr><td bgcolor="#777777">'.
 	'<table border="0"><tr bgcolor="#e6ffff">';
     my $loop = 0;
@@ -719,12 +723,16 @@
 	}
 
 	$ctr++;
+	my $section = $classlist->{$student}->[&Apache::loncoursedata::CL_SECTION()];
+
 	if ( $perm{'vgr'} eq 'F' ) {
 	    $gradeTable.='<tr bgcolor="#ffffe6">' if ($ctr%2 ==1);
 	    $gradeTable.='<td align="right">'.$ctr.'&nbsp;</td>'.
-		'<td align="center"><input type=checkbox name="stuinfo" value="'.
-		$student.':'.$$fullname{$student}.'&nbsp;" /></td>'."\n".
-		'<td>'.&nameUserString(undef,$$fullname{$student},$uname,$udom).'</td>'."\n";
+               '<td align="center"><label><input type=checkbox name="stuinfo" value="'.
+               $student.':'.$$fullname{$student}.':::SECTION'.$section.
+	       ')&nbsp;" />&nbsp;&nbsp;</label></td>'."\n".'<td>'.
+	       &nameUserString(undef,$$fullname{$student},$uname,$udom).
+	       '&nbsp;'.$section.'</td>'."\n";
 
 	    if ($ENV{'form.showgrading'} eq 'yes' && $submitonly ne 'all') {
 		foreach (sort keys(%status)) {
@@ -746,7 +754,7 @@
 	$gradeTable.='</tr>';
     }
 
-    $gradeTable.='</table></td></tr></table>'.
+    $gradeTable.='</table></td></tr></table>'."\n".
 	'<input type="button" '.
 	'onClick="javascript:checkSelect(this.form.stuinfo);" '.
 	'value="Next->" /></form>'."\n";
@@ -771,6 +779,52 @@
 }
 
 #---- Called from the listStudents routine
+
+sub check_script {
+    my ($form, $type)=@_;
+    my $chkallscript='<script type="text/javascript">
+    function checkall() {
+        for (i=0; i<document.forms.'.$form.'.elements.length; i++) {
+            ele = document.forms.'.$form.'.elements[i];
+            if (ele.name == "'.$type.'") {
+            document.forms.'.$form.'.elements[i].checked=true;
+                                       }
+        }
+    }
+
+    function checksec() {
+        for (i=0; i<document.forms.'.$form.'.elements.length; i++) {
+            ele = document.forms.'.$form.'.elements[i];
+           string = document.forms.'.$form.'.chksec.value;
+           if
+          (ele.value.indexOf(":::SECTION"+string)>0) {
+              document.forms.'.$form.'.elements[i].checked=true;
+            }
+        }
+    }
+
+
+    function uncheckall() {
+        for (i=0; i<document.forms.'.$form.'.elements.length; i++) {
+            ele = document.forms.'.$form.'.elements[i];
+            if (ele.name == "'.$type.'") {
+            document.forms.'.$form.'.elements[i].checked=false;
+                                       }
+        }
+    }
+
+</script>'."\n";
+    return $chkallscript;
+}
+
+sub check_buttons {
+    my $buttons.='<input type="button" onclick="checkall()" value="Check All" />';
+    $buttons.='<input type="button" onclick="uncheckall()" value="Uncheck All" />&nbsp;';
+    $buttons.='<input type="button" onclick="checksec()" value="Check Section/Group" />';
+    $buttons.='<input type="text" size="5" name="chksec" />&nbsp;';
+    return $buttons;
+}
+
 #     Displays the submissions for one student or a group of students
 sub processGroup {
     my ($request)  = shift;