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

sakharuk lon-capa-cvs@mail.lon-capa.org
Mon, 21 Apr 2003 17:51:46 -0000


sakharuk		Mon Apr 21 13:51:46 2003 EDT

  Modified files:              
    /loncom/homework/caparesponse	caparesponse.pm 
  Log:
  Allows to print numerical problems with answers.
  
  
Index: loncom/homework/caparesponse/caparesponse.pm
diff -u loncom/homework/caparesponse/caparesponse.pm:1.93 loncom/homework/caparesponse/caparesponse.pm:1.94
--- loncom/homework/caparesponse/caparesponse.pm:1.93	Fri Apr 18 03:12:13 2003
+++ loncom/homework/caparesponse/caparesponse.pm	Mon Apr 21 13:51:46 2003
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # caparesponse definition
 #
-# $Id: caparesponse.pm,v 1.93 2003/04/18 07:12:13 albertel Exp $
+# $Id: caparesponse.pm,v 1.94 2003/04/21 17:51:46 sakharuk Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -147,7 +147,7 @@
 						     $safeeval);
 	my $award = $Apache::lonhomework::history{"resource.$Apache::inputtags::part.solved"};
 	my $status = $Apache::inputtags::status['-1'];
-	if ($award =~ /^correct/ || $status eq "SHOW_ANSWER" ) {
+	if ($award =~ /^correct/ || $status eq "SHOW_ANSWER" || $ENV{'form.texaward'} eq 'SHOW_ANSWER') {
 	    my (@formats)=&Apache::lonxml::get_param_var('format',$parstack,
 							 $safeeval);
 	    my $unit=&Apache::lonxml::get_param_var('unit',$parstack,
@@ -155,7 +155,9 @@
 	    if ($target eq 'web') {
 		$result="<br />The correct answer is ";
 	    } elsif ($target eq 'tex') {
-		#$result='\vskip 0 mm The correct answer is \\texttt{';
+		if ($ENV{'form.texaward'} eq 'SHOW_ANSWER') {
+		    $result='\vskip 0 mm The correct answer is \\texttt{ ';
+		}
 	    }
 	    for (my $i=0; $i <= $#answers; $i++) {
 		my $answer=$answers[$i];
@@ -173,7 +175,9 @@
 		    &Apache::lonxml::debug("no format answer :$answer:");
 		    $formatted="$answer,";
 		}
-		
+		if ($ENV{'form.texaward'} eq 'SHOW_ANSWER') {
+		    $result.=$formatted;
+		}
 		if ($target eq 'tex') {
 		    $formatted='';
 		    #$formatted=&Apache::lonxml::latex_special_symbols($formatted);
@@ -183,9 +187,11 @@
 	    chop $result;
 	    if ($target eq 'web') {
 		$result.=" $unit.<br />";
-	    } elsif ($target eq 'tex') {
-		#$result.=&Apache::lonxml::latex_special_symbols($unit);
-		#$result.="}. \\vskip 0 mm ";
+	    } elsif ($target eq 'tex') {		
+		if ($ENV{'form.texaward'} eq 'SHOW_ANSWER') {
+		    $result.=&Apache::lonxml::latex_special_symbols($unit);
+		    $result.="}. \\vskip 0 mm ";
+		}
 	    }
 	}
 	if ($Apache::lonhomework::type eq 'exam') {