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

foxr lon-capa-cvs-allow@mail.lon-capa.org
Wed, 29 Aug 2007 10:12:20 -0000


foxr		Wed Aug 29 06:12:20 2007 EDT

  Modified files:              
    /loncom/homework	grades.pm 
  Log:
  BZ 4074 (incomplete) Modify scantron_get_maxbubble
  -  Analyze each resource to determine how many lines on the bubble
     sheet were actually required using the new bubble_lines
     analysis hash entry.
  -  Create a hash of resource->symb().part_id  for each part in the 
     set that describes the answer sheet lines required for each part on the
     exam.
  - Return the total number of answer sheet lines required as per the analysis
    output.
  
  
Index: loncom/homework/grades.pm
diff -u loncom/homework/grades.pm:1.434 loncom/homework/grades.pm:1.435
--- loncom/homework/grades.pm:1.434	Thu Aug 23 20:32:00 2007
+++ loncom/homework/grades.pm	Wed Aug 29 06:12:15 2007
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # The LON-CAPA Grading handler
 #
-# $Id: grades.pm,v 1.434 2007/08/24 00:32:00 albertel Exp $
+# $Id: grades.pm,v 1.435 2007/08/29 10:12:15 foxr Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -45,7 +45,11 @@
 
 use POSIX qw(floor);
 
-my %perm;
+
+my %perm=();
+my %bubble_lines_per_response;     # no. bubble lines for each response.
+                                   # index is "symb.part_id"
+
 
 # ----- These first few routines are general use routines.----
 #
@@ -4428,7 +4432,7 @@
 like.
 
 Next each scanline is checked for any errors of either 'missing
-bubbles' (it's an error because it may have been missed scanned
+bubbles' (it's an error because it may have been mis-scanned
 because too light bubbling), 'double bubble' (each bubble line should
 have no more that one letter picked), invalid or duplicated CODE,
 invalid student ID
@@ -4439,7 +4443,7 @@
 
 During the validation phase the instructor can choose to skip scanlines. 
 
-After the validation phase, there is now 3 bubble sheet files
+After the validation phase, there are now 3 bubble sheet files
 
   scantron_original_filename (unmodified original file)
   scantron_corrected_filename (file where the corrected information has replaced the original information)
@@ -6509,6 +6513,7 @@
 =cut
 
 sub scantron_get_maxbubble {    
+
     if (defined($env{'form.scantron_maxbubble'}) &&
 	$env{'form.scantron_maxbubble'}) {
 	return $env{'form.scantron_maxbubble'};
@@ -6523,14 +6528,40 @@
 
     &Apache::lonxml::clear_problem_counter();
 
+    my $uname       = $env{'form.student'};
+    my $udom        = $env{'form.userdom'};
+    my $cid         = $env{'request.course.id'};
+    my $total_lines = 0;
+    %bubble_lines_per_response = ();
+
     foreach my $resource (@resources) {
+	my $symb = $resource->symb();
 	my $result=&Apache::lonnet::ssi($resource->src(),
-					('symb' => $resource->symb()));
+					('symb' => $resource->symb()),
+					('grade_target' => 'analyze'),
+					('grade_courseid' => $cid),
+					('grade_domain' => $udom),
+					('grade_username' => $uname));
+	my ($garbage, $an) =
+	    split(/_HASH_REF__/,$result, 2);
+
+	my %analysis = &Apache::lonnet::str2hash($an);
+
+
+
+	foreach my $part_id (@{$analysis{'parts'}}) {
+	    my $bubble_lines = $analysis{"$part_id.bubble_lines"}[0];
+	    if (!$bubble_lines) {
+		$bubble_lines = 1;
+	    }
+	    $bubble_lines_per_response{"$symb.$part_id"} = $bubble_lines;
+	    $total_lines = $total_lines + $bubble_lines;
+	}
+
     }
     &Apache::lonnet::delenv('scantron\.');
     $env{'form.scantron_maxbubble'} =
-	&Apache::lonxml::get_problem_counter()-1;
-
+	$total_lines;
     return $env{'form.scantron_maxbubble'};
 }