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

foxr lon-capa-cvs-allow@mail.lon-capa.org
Wed, 17 Oct 2007 09:40:51 -0000


foxr		Wed Oct 17 05:40:51 2007 EDT

  Modified files:              
    /loncom/homework	grades.pm 
  Log:
  BZ4074
   - Remove a ton of debugging log-spew.
   - For at least simple test cases, if a bubble response requires
     more than a single line of answer bubbles, double bubble cases
     where the double bubbling consists of a single bubble but more than
     a single line with bubbles will be shown accurately in the bubble
     selector.
  
  
Index: loncom/homework/grades.pm
diff -u loncom/homework/grades.pm:1.459 loncom/homework/grades.pm:1.460
--- loncom/homework/grades.pm:1.459	Mon Oct 15 05:47:47 2007
+++ loncom/homework/grades.pm	Wed Oct 17 05:40:49 2007
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # The LON-CAPA Grading handler
 #
-# $Id: grades.pm,v 1.459 2007/10/15 09:47:47 foxr Exp $
+# $Id: grades.pm,v 1.460 2007/10/17 09:40:49 foxr Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -57,9 +57,7 @@
 
 
 sub save_bubble_lines {
-    &Apache::lonnet::logthis("Saving bubble_lines...");
     foreach my $line (keys(%bubble_lines_per_response)) {
-	&Apache::lonnet::logthis("Saving form.scantron.bubblelines.$line value: $bubble_lines_per_response{$line}");
 	$env{"form.scantron.bubblelines.$line"}  = $bubble_lines_per_response{$line};
 	$env{"form.scantron.first_bubble_line.$line"} =
 	    $first_bubble_line{$line};
@@ -72,7 +70,6 @@
     %bubble_lines_per_response = ();
     while ($env{"form.scantron.bubblelines.$line"}) {
 	my $value = $env{"form.scantron.bubblelines.$line"};
-	&Apache::lonnet::logthis("Restoring form.scantron.bubblelines.$line value: $value");
 	$bubble_lines_per_response{$line} = $value;
 	$first_bubble_line{$line}  =
 	    $env{"form.scantron.first_bubble_line.$line"};
@@ -87,8 +84,10 @@
 sub get_response_bubbles {
     my ($parsed_line, $response)  = @_;
 
-    my $bubble_line = $first_bubble_line{$response};
-    my $bubble_lines= $bubble_lines_per_response{$response};
+
+    my $bubble_line = $first_bubble_line{$response-1} +1;
+    my $bubble_lines= $bubble_lines_per_response{$response-1};
+    
     my $selected = "";
 
     for (my $bline = 0; $bline < $bubble_lines; $bline++) {
@@ -5269,7 +5268,12 @@
 		|| (&occurence_count($currentquest, "[A-Z]") > 1)) {
 		push(@{$record{'scantron.doubleerror'}},$questnum);
 		for (my $ans = 0; $ans < $answers_needed; $ans++) { 
-		    $record{"scantron.$ansnum.answer"}='';
+		    my $bubble = substr($currentquest, $ans, 1);
+		    if ($bubble =~ /[A-Z]/ ) {
+			$record{"scantron.$ansnum.answer"} = $bubble;
+		    } else {
+			$record{"scantron.$ansnum.answer"}='';
+		    }
 		    $ansnum++;
 		}
 
@@ -5304,7 +5308,12 @@
 		|| (&occurence_count($currentquest, '\d') > 1)) {
 		push(@{$record{'scantron.doubleerror'}},$questnum);
 		for (my $ans = 0; $ans < $answers_needed; $ans++) {
-		    $record{"scantron.$ansnum.answer"}='';
+		    my $bubble = substr($currentquest, $ans, 1);
+		    if ($bubble =~ /\d/) {
+			$record{"scantron.$ansnum.answer"} = $alphabet[$bubble];
+		    } else {
+			$record{"scantron.$ansnum.answer"}='';
+		    }
 		    $ansnum++;
 		}
 
@@ -5747,7 +5756,6 @@
 
   my $line = 0;
     while (defined($env{"form.scantron.bubblelines.$line"})) {
-	&Apache::lonnet::logthis("Saving chunk for $line");
        my $chunk =
 	   '<input type="hidden" name="scantron.bubblelines.'.$line.'" value="'.$env{"form.scantron.bubblelines.$line"}.'" />'."\n";
        $chunk .=
@@ -5813,7 +5821,6 @@
     }
     my $currentphase=$env{'form.validatepass'};
 
-    &Apache::lonnet::logthis("Phase: $currentphase");
 
     my $stop=0;
     while (!$stop && $currentphase < scalar(@validate_phases)) {
@@ -6424,10 +6431,10 @@
 	$r->print($message);
 	$r->print("<p>Please indicate which bubble should be used for grading</p>");
 	foreach my $question (@{$arg}) {
-
 	    my $selected  = &get_response_bubbles($scan_record, $question);
+	    my @select_array = split('',$selected);
 	    &scantron_bubble_selector($r,$scan_config,$question,
-				      split('',$selected));
+				      @select_array);
 	}
     } elsif ($error eq 'missingbubble') {
 	$r->print("<p>There have been <b>no</b> bubbles scanned for some question(s)</p>\n");
@@ -6468,12 +6475,13 @@
 
     my $scmode=$$scan_config{'Qon'};
 
+    my $bubble_length = scalar(@selected);
+
 
     if ($scmode eq 'number' || $scmode eq 'letter') { $max=10; }	     
 
     my $response = $quest-1;
     my $lines = $bubble_lines_per_response{$response};
-    &Apache::lonnet::logthis("Question $quest, lines: $lines");
 
     my $total_lines = $lines*2;
     my @alphabet=('A'..'Z');
@@ -6484,10 +6492,6 @@
 	    $r->print('<tr>');
 	}
 
-	# FIXME:  This loop probably has to be considerably more clever for
-	#  multiline bubbles: User can multibubble by having bubbles in
-	#  several lines.  User can skip lines legitimately etc. etc.
-
 	for (my $i=0;$i<$max;$i++) {
 	    $r->print("\n".'<td align="center">');
 	    if ($selected[0] eq $alphabet[$i]) { 
@@ -6737,14 +6741,11 @@
 =cut
 
 sub scantron_get_maxbubble {    
-    &Apache::lonnet::logthis("get_max_bubble");
     if (defined($env{'form.scantron_maxbubble'}) &&
 	$env{'form.scantron_maxbubble'}) {
-	&Apache::lonnet::logthis("cached");
 	&restore_bubble_lines();
 	return $env{'form.scantron_maxbubble'};
     }
-    &Apache::lonnet::logthis("computing");
 
     my (undef, undef, $sequence) =
 	&Apache::lonnet::decode_symb($env{'form.selectpage'});
@@ -6782,9 +6783,9 @@
 
 
 	foreach my $part_id (@{$analysis{'parts'}}) {
-	    my ($trash, $part) = split(/\./, $part_id);
 
-	    my $lines = $analysis{"$part_id.bubble_lines"}[0];
+
+	    my $lines = $analysis{"$part_id.bubble_lines"};;
 
 	    # TODO - make this a persistent hash not an array.
 
@@ -8071,7 +8072,6 @@
 	} elsif ($command eq 'csvuploadassign' && $perm{'mgr'} ) {
 	    $request->print(&csvuploadassign($request));
 	} elsif ($command eq 'scantron_selectphase' && $perm{'mgr'}) {
-	    &Apache::lonnet::logthis("Selecting pyhase");
 	    $request->print(&scantron_selectphase($request));
  	} elsif ($command eq 'scantron_warning' && $perm{'mgr'}) {
  	    $request->print(&scantron_do_warning($request));