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

albertel lon-capa-cvs-allow@mail.lon-capa.org
Tue, 17 Jul 2007 20:44:08 -0000


albertel		Tue Jul 17 16:44:08 2007 EDT

  Modified files:              
    /loncom/homework	radiobuttonresponse.pm 
  Log:
  - BUG#4074,
    - correct line numbers in print 
    - correct the display of the correct answer to point to the correct line /bubble letter         
  
  
Index: loncom/homework/radiobuttonresponse.pm
diff -u loncom/homework/radiobuttonresponse.pm:1.123 loncom/homework/radiobuttonresponse.pm:1.124
--- loncom/homework/radiobuttonresponse.pm:1.123	Fri Jun 29 13:32:31 2007
+++ loncom/homework/radiobuttonresponse.pm	Tue Jul 17 16:44:07 2007
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # mutliple choice style responses
 #
-# $Id: radiobuttonresponse.pm,v 1.123 2007/06/29 17:32:31 albertel Exp $
+# $Id: radiobuttonresponse.pm,v 1.124 2007/07/17 20:44:07 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -240,7 +240,7 @@
 				      $direction,
 				      $bubbles_per_line);
 	    } elsif ($target eq 'answer' ) {
-		$result=&displayanswers($answer, \@shown);
+		$result=&displayanswers($answer, \@shown, $bubbles_per_line);
 	    } elsif ( $target eq 'grade') {
 		&grade_response($answer, \@shown, $bubbles_per_line);
 	    }  elsif ( $target eq 'analyze') {
@@ -585,6 +585,7 @@
 	my @alphabet = ('A'..'Z');
 	my $i = 0;
 	my $bubble_number = 0;
+	my $line = 0;
 	my $temp=0;  
 	my $id=$Apache::inputtags::response['-1'];
 	my $part=$Apache::inputtags::part;
@@ -612,14 +613,15 @@
 		$result .= ' />'.$Apache::response::foilgroup{$name.'.text'}."</label>";
 	    } else {
 		if ($Apache::lonhomework::type eq 'exam') {
-		    $result .= '{\small \textbf{'.$alphabet[$i].'}}$\bigcirc$'.$Apache::response::foilgroup{$name.'.text'}.'\\\\';  #' stupid emacs
-		    $i++;
-		    $bubble_number++;
 		    if($bubble_number >= $bubbles_per_line) {
+			$line++;
 			$i = 0;
 			$bubble_number = 0;
-			$result.='\item[\textbf{'.$Apache::lonxml::counter.'}.]';
+			$result.='\item[\textbf{'.($Apache::lonxml::counter+$line).'}.]';
 		    }
+		    $result .= '{\small \textbf{'.$alphabet[$i].'}}$\bigcirc$'.$Apache::response::foilgroup{$name.'.text'}.'\\\\';  #' stupid emacs
+		    $i++;
+		    $bubble_number++;
 		} else {
 		    $result .= '\vspace*{-2 mm}\item '.$Apache::response::foilgroup{$name.'.text'};
 		}
@@ -652,12 +654,18 @@
 }
 
 sub displayanswers {
-    my ($answer, $whichopt)=@_;
-    my $result=&Apache::response::answer_header('radiobuttonresponse');
+    my ($answer, $whichopt, $bubbles_per_line)=@_;
+    my $result;
+
     if ($Apache::lonhomework::type eq 'exam') {
-	my $correct = ('A'..'Z')[$answer];
-	$result.=&Apache::response::answer_part('radiobuttonresponse',
-						$correct);
+	my $line = int($answer/$bubbles_per_line);
+	my $correct = ('A'..'Z')[$answer%$bubbles_per_line];
+	$result .= &Apache::response::answer_header('radiobuttonresponse',
+						    $line);
+	$result .= &Apache::response::answer_part('radiobuttonresponse',
+						  $correct);
+    } else {
+	$result .= &Apache::response::answer_header('radiobuttonresponse');
     }
     foreach my $name (@{ $whichopt }) {
 	$result.=&Apache::response::answer_part('radiobuttonresponse',