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

www lon-capa-cvs@mail.lon-capa.org
Fri, 13 Feb 2004 15:09:52 -0000


www		Fri Feb 13 10:09:52 2004 EDT

  Modified files:              
    /loncom/homework/caparesponse	caparesponse.pm 
  Log:
  Bug #873: Correct answer of string response can appear inline with the
  text (for fill-in-the-blank) without "The correct answer is ..." linebreak
  and text.
  
  
Index: loncom/homework/caparesponse/caparesponse.pm
diff -u loncom/homework/caparesponse/caparesponse.pm:1.128 loncom/homework/caparesponse/caparesponse.pm:1.129
--- loncom/homework/caparesponse/caparesponse.pm:1.128	Wed Feb 11 16:10:45 2004
+++ loncom/homework/caparesponse/caparesponse.pm	Fri Feb 13 10:09:52 2004
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # caparesponse definition
 #
-# $Id: caparesponse.pm,v 1.128 2004/02/11 21:10:45 sakharuk Exp $
+# $Id: caparesponse.pm,v 1.129 2004/02/13 15:09:52 www Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -29,6 +29,7 @@
 package Apache::caparesponse;
 use strict;
 use capa;
+use Apache::lonlocal;
 
 BEGIN {
     &Apache::lonxml::register('Apache::caparesponse',('caparesponse','numericalresponse','stringresponse','formularesponse'));
@@ -179,7 +180,7 @@
 	    my $unit=&Apache::lonxml::get_param_var('unit',$parstack,
 						    $safeeval);
 	    if ($target eq 'web') {
-		$result="<br />The correct answer is ";
+		$result="<br />".&mt('The correct answer is')." ";
 	    }
 	    for (my $i=0; $i <= $#answers; $i++) {
 		my $answer=$answers[$i];
@@ -524,16 +525,20 @@
 			 [['cs','Case Sensitive'],['ci','Case Insensitive'],
 			  ['mc','Case Insensitive, Any Order'],
 			  ['re','Regular Expression']],$token);
+	$result.=&Apache::edit::checked_arg('Answer Display:','answerdisplay',
+					    [['inline','Inline']],$token);
 	$result.=&Apache::edit::end_row().&Apache::edit::start_spanning_row();
     } elsif ($target eq 'modified') {
-	my $constructtag;
-	$constructtag=&Apache::edit::get_new_args($token,$parstack,
-						  $safeeval,'answer',
-						  'type');
-	if ($constructtag) {
-	    $result = &Apache::edit::rebuild_tag($token);
-	    $result.=&Apache::edit::handle_insert();
+	&Apache::edit::get_new_args($token,$parstack,
+				    $safeeval,'answer','type');
+	my $answerdisplay=$ENV{'form.'.&Apache::edit::html_element_name('answerdisplay')};
+	if ($answerdisplay) {
+	    $token->[2]->{'answerdisplay'}=$answerdisplay;
+	} else {
+	    delete $token->[2]->{'answerdisplay'};
 	}
+	$result = &Apache::edit::rebuild_tag($token);
+	$result.=&Apache::edit::handle_insert();
     } elsif ($target eq 'answer' || $target eq 'grade') {
 	&Apache::response::reset_params();
     }
@@ -548,6 +553,7 @@
     my $id=$Apache::inputtags::response[-1];
     my $answer=&Apache::lonxml::get_param('answer',$parstack,$safeeval);
     my $type=&Apache::lonxml::get_param('type',$parstack,$safeeval);
+    my $answerdisplay=&Apache::lonxml::get_param('answerdisplay',$parstack,$safeeval);
     &Apache::lonxml::debug("current $answer ".$token->[2]);
     if (!$Apache::lonxml::default_homework_loaded) {
 	&Apache::lonxml::default_homework_load($safeeval);
@@ -610,7 +616,8 @@
 	my $status = $Apache::inputtags::status['-1'];
 	if (  &Apache::response::show_answer() ) {
 	    if ($target eq 'web') {
-		$result="<br />The correct answer is ".$answer;
+		$result=($answerdisplay eq 'inline'?'':"<br />".&mt('The correct answer is')." ")
+		    .$answer;
 #		    join(', ',@answers).".<br />";
 	    }
 	}