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

sakharuk lon-capa-cvs@mail.lon-capa.org
Mon, 30 Sep 2002 18:08:09 -0000


sakharuk		Mon Sep 30 14:08:09 2002 EDT

  Modified files:              
    /loncom/homework/caparesponse	caparesponse.pm 
  Log:
  1. Prints integers in the bubbles;
  2. Size of bubbles is defined more correctly.
  
  
Index: loncom/homework/caparesponse/caparesponse.pm
diff -u loncom/homework/caparesponse/caparesponse.pm:1.59 loncom/homework/caparesponse/caparesponse.pm:1.60
--- loncom/homework/caparesponse/caparesponse.pm:1.59	Mon Sep 30 12:01:36 2002
+++ loncom/homework/caparesponse/caparesponse.pm	Mon Sep 30 14:08:09 2002
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # caparesponse definition
 #
-# $Id: caparesponse.pm,v 1.59 2002/09/30 16:01:36 albertel Exp $
+# $Id: caparesponse.pm,v 1.60 2002/09/30 18:08:09 sakharuk Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -220,19 +220,26 @@
 	for ($ind=0;$ind<$number_of_bubbles;$ind++) {
 	    $bubbles_values[$ind] = $answers[0]*$factor**($power-$powers[$powers_number-$ind-1]);
 	}	    
+	my @alphabet = ('A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P',
+			'Q','R','S','T','U','V','W','X','Y','Z');
         if ($target eq 'web') {
 	    $result.= '<table border="1"><tr>';
 	    for ($ind=0;$ind<$number_of_bubbles;$ind++) {
-		my $ans = sprintf('%.'.$formats[0],$bubbles_values[$ind]);
-		$result.='<td>'.$ans.'</td>';
+		if (undef @formats) {
+		    my $ans = sprintf('%.'.$formats[0],$bubbles_values[$ind]);
+		    $result.='<td>'.$alphabet[$ind].': '.$ans.'</td>';
+		} else {
+		    my $ans = sprintf('%.'.'d',$bubbles_values[$ind]);
+		    $result.='<td>'.$alphabet[$ind].': '.$ans.'</td>';
 		}
+	    }
 	    $result.='</tr></table>';
 	} elsif ($target eq 'tex') {
-	    my @alphabet = ('A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P',
-                            'Q','R','S','T','U','V','W','X','Y','Z');
 	    my $max_val = 0;
 	    if ($formats[0]=~m/^(\d+)E([^\d]*)(\d*)$/) {
 		$max_val=$1+$2+4;
+	    } else {
+		$max_val=5;
 	    }
 	    $max_val = int(90/(($max_val+6)*2));
             my $celllength = 90/$max_val-12;
@@ -253,8 +260,13 @@
 		}
 		$result.='}\hline';
 		for ($ind=$cou;$ind<$cou+$table_range[$j];$ind++) {
-		    my $ans = sprintf('%.'.$formats[0],$bubbles_values[$ind]);
-		    $result.=' '.$alphabet[$ind].': & '.$ans.' ';
+		    if (undef @formats) {
+			my $ans = sprintf('%.'.$formats[0],$bubbles_values[$ind]);
+			$result.=' '.$alphabet[$ind].': & '.$ans.' ';
+		    } else {
+			my $ans = sprintf('%.'.'d',$bubbles_values[$ind]);
+			$result.=' '.$alphabet[$ind].': & '.$ans.' ';
+		    }
 		    if ($ind != $cou+$table_range[$j]-1) {$result.=' & ';}
 		}
 		$j++;