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

albertel lon-capa-cvs@mail.lon-capa.org
Mon, 13 Mar 2006 21:10:36 -0000


albertel		Mon Mar 13 16:10:36 2006 EDT

  Modified files:              
    /loncom/homework	grades.pm 
  Log:
  - BUG#4655 throw an error if scantron grading a resource that isn't set to exam mode
  
  
Index: loncom/homework/grades.pm
diff -u loncom/homework/grades.pm:1.333 loncom/homework/grades.pm:1.334
--- loncom/homework/grades.pm:1.333	Mon Mar 13 15:26:51 2006
+++ loncom/homework/grades.pm	Mon Mar 13 16:10:34 2006
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # The LON-CAPA Grading handler
 #
-# $Id: grades.pm,v 1.333 2006/03/13 20:26:51 albertel Exp $
+# $Id: grades.pm,v 1.334 2006/03/13 21:10:34 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -4764,7 +4764,8 @@
     my $result=&scantron_form_start($max_bubble).$default_form_data;
     $r->print($result);
     
-    my @validate_phases=( 'ID',
+    my @validate_phases=( 'sequence',
+			  'ID',
 			  'CODE',
 			  'doublebubble',
 			  'missingbubbles');
@@ -4797,10 +4798,17 @@
 	$r->print("<input type='hidden' name='validatepass' value='".$currentphase."' />");
     }
     if ($stop) {
-	$r->print('<input type="submit" name="submit" value="Continue ->" />');
-	$r->print(' using corrected info <br />');
-	$r->print("<input type='submit' value='Skip' name='scantron_skip_record' />");
-	$r->print(" this scanline saving it for later.");
+	if ($validate_phases[$currentphase] eq 'sequence') {
+	    $r->print('<input type="submit" name="submit" value="Ignore -> " />');
+	    $r->print(' this error <br />');
+
+	    $r->print(" <p>Or click the 'Grading Menu' button to start over.</p>");
+	} else {
+	    $r->print('<input type="submit" name="submit" value="Continue ->" />');
+	    $r->print(' using corrected info <br />');
+	    $r->print("<input type='submit' value='Skip' name='scantron_skip_record' />");
+	    $r->print(" this scanline saving it for later.");
+	}
     }
     $r->print(" </form><br />".&show_grading_menu_form($symb).
 	      "</body></html>");
@@ -4933,6 +4941,45 @@
     $scanlines->{'corrected'}[$i]=$newline;
 }
 
+sub scantron_filter_not_exam {
+    my ($curres)=@_;
+    
+    if (ref($curres) && $curres->is_problem() && !$curres->is_exam()) {
+	# if the user has asked to not have either hidden
+	# or 'randomout' controlled resources to be graded
+	# don't include them
+	if ($env{'form.scantron_options_hidden'} eq 'ignore_hidden'
+	    && $curres->randomout) {
+	    return 0;
+	}
+	return 1;
+    }
+    return 0;
+}
+
+sub scantron_validate_sequence {
+    my ($r,$currentphase) = @_;
+
+    my $navmap=Apache::lonnavmaps::navmap->new();
+    my (undef,undef,$sequence)=
+	&Apache::lonnet::decode_symb($env{'form.selectpage'});
+
+    my $map=$navmap->getResourceByUrl($sequence);
+
+    $r->print('<input type="hidden" name="validate_sequence_exam"
+                                    value="ignore" />');
+    if ($env{'form.validate_sequence_exam'} ne 'ignore') {
+	my @resources=
+	    $navmap->retrieveResources($map,\&scantron_filter_not_exam,1,0);
+	if (@resources) {
+	    $r->print("<p>".&mt('Some resource in the sequece currently are not set to exam mode. Grading these resources currently may not work correctly.')."</p>");
+	    return (1,$currentphase);
+	}
+    }
+
+    return (0,$currentphase+1);
+}
+
 sub scantron_validate_ID {
     my ($r,$currentphase) = @_;