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

albertel lon-capa-cvs@mail.lon-capa.org
Tue, 28 Oct 2003 23:20:04 -0000


albertel		Tue Oct 28 18:20:04 2003 EDT

  Modified files:              
    /loncom/homework	grades.pm 
  Log:
  - implements 'graded ungraded students option' BUG#2102
  
  
Index: loncom/homework/grades.pm
diff -u loncom/homework/grades.pm:1.144 loncom/homework/grades.pm:1.145
--- loncom/homework/grades.pm:1.144	Tue Oct 21 17:46:15 2003
+++ loncom/homework/grades.pm	Tue Oct 28 18:20:03 2003
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # The LON-CAPA Grading handler
 #
-# $Id: grades.pm,v 1.144 2003/10/21 21:46:15 albertel Exp $
+# $Id: grades.pm,v 1.145 2003/10/28 23:20:03 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -572,18 +572,21 @@
 	my %status = ();
 	if ($ENV{'form.showgrading'} eq 'yes' && $submitonly ne 'all') {
 	    (%status) =&student_gradeStatus($url,$symb,$udom,$uname,$partlist);
-	    my $statusflg = '';
+	    my $submitted = 0;
+	    my $graded = 1;
 	    foreach (keys(%status)) {
-		$statusflg = 1 if ($status{$_} ne 'nothing');
+		$submitted = 1 if ($status{$_} ne 'nothing');
+		$graded = 0 if ($status{$_} =~ /^correct/);
 		my ($foo,$partid,$foo1) = split(/\./,$_);
 		if ($status{'resource.'.$partid.'.submitted_by'} ne '') {
-		    $statusflg = '';
+		    $submitted = 0;
 		    $gradeTable.='<input type="hidden" name="'.
 			$student.':submitted_by" value="'.
 			$status{'resource.'.$partid.'.submitted_by'}.'" />';
 		}
 	    }
-	    next if ($statusflg eq '' && $submitonly eq 'yes');
+	    next if (!$submitted && ($submitonly eq 'yes' || $submitonly eq 'graded'));
+	    next if (!$graded && $submitonly eq 'graded');
 	}
 
 	$ctr++;
@@ -625,7 +628,7 @@
 	} else {
 	    $gradeTable='<br />&nbsp;<font color="red">'.
 		'No submissions found for this resource for any students. ('.$num_students.
-		' checked for submissions</font><br />';
+		' checked for submissions)</font><br />';
 	}
     } elsif ($ctr == 1) {
 	$gradeTable =~ s/type=checkbox/type=checkbox checked/;
@@ -1830,15 +1833,25 @@
     }
     $ctr = 0;
     @parsedlist = reverse @parsedlist if ($button eq 'Previous');
+    my ($partlist) = &response_type($url);
     foreach my $student (@parsedlist) {
+	my $submitonly=$ENV{'form.submitonly'};
 	my ($uname,$udom) = split(/:/,$student);
-	if ($ENV{'form.submitonly'} eq 'yes') {
-	    my %record = &Apache::lonnet::restore($symb,$ENV{'request.course.id'},$udom,$uname);
-	    my $statusflg = '';
-	    foreach (split(/:/,$ENV{'form.gradePartRespid'})){
-		$statusflg = 1 if (exists ($record{'resource.'.$_.'.submission'}));
+	if ($submitonly =~ /^(yes|graded)$/) {
+#	    my %record = &Apache::lonnet::restore($symb,$ENV{'request.course.id'},$udom,$uname);
+	    my %status=&student_gradeStatus($url,$symb,$udom,$uname,$partlist);
+	    my $submitted = 0;
+	    my $graded = 1;
+	    foreach (keys(%status)) {
+		$submitted = 1 if ($status{$_} ne 'nothing');
+		$graded = 0 if ($status{$_} =~ /^correct/);
+		my ($foo,$partid,$foo1) = split(/\./,$_);
+		if ($status{'resource.'.$partid.'.submitted_by'} ne '') {
+		    $submitted = 0;
+		}
 	    }
-	    next if ($statusflg eq '');
+	    next if (!$submitted && ($submitonly eq 'yes' || $submitonly eq 'graded'));
+	    next if (!$graded && $submitonly eq 'graded');
 	}
 	push @nextlist,$student if ($ctr < $ntstu);
 	last if ($ctr == $ntstu);
@@ -3551,7 +3564,7 @@
 	}
 	formname.command.value = cmd;
 	formname.saveState.value = "saveCmd="+cmdsave+":saveSec="+pullDownSelection(formname.section)+
-	    ":saveSub="+radioSelection(formname.submitonly)+":saveStatus="+pullDownSelection(formname.Status);
+	    ":saveSub="+pullDownSelection(formname.submitonly)+":saveStatus="+pullDownSelection(formname.Status);
 	if (val < 5) formname.submit();
 	if (val == 5) {
 	    if (!checkReceiptNo(formname,'notOK')) { return false;}
@@ -3619,12 +3632,14 @@
 
     $result.='<tr bgcolor="#ffffe6"valign="top"><td>'.
 	'<input type="radio" name="radioChoice" value="submission" '.
-	($saveCmd eq 'submission' ? 'checked' : '').'> '.'<b>Current Resource:</b> For one or more students'.
-	'<br />&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;-->For students with '.
-	'<input type="radio" name="submitonly" value="yes" '.
-	($saveSub eq 'yes' ? 'checked' : '').' /> submissions or '.
-	'<input type="radio" name="submitonly" value="all" '.
-	($saveSub eq 'all' ? 'checked' : '').' /> for all</td></tr>'."\n";
+	($saveCmd eq 'submission' ? 'checked' : '').'> '.'<b>Current Resource:</b> For one or more students '.
+	'<select name="submitonly">'.
+	'<option value="yes" '.
+	($saveSub eq 'yes' ? 'selected="on"' : '').'>with submissions</option>'.
+	'<option value="graded" '.
+	($saveSub eq 'graded' ? 'selected="on"' : '').'>with ungraded submissions</option>'.
+	'<option value="all" '.
+	($saveSub eq 'all' ? 'selected="on"' : '').'>with any status</option></select></td></tr>'."\n";
 
     $result.='<tr bgcolor="#ffffe6"valign="top"><td>'.
 	'<input type="radio" name="radioChoice" value="viewgrades" '.