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

albertel lon-capa-cvs@mail.lon-capa.org
Mon, 11 Nov 2002 20:26:59 -0000


albertel		Mon Nov 11 15:26:59 2002 EDT

  Modified files:              
    /loncom/homework	optionresponse.pm 
  Log:
  - doesn't generate <br /> when the question consits of foils with only whitespace
  
  
Index: loncom/homework/optionresponse.pm
diff -u loncom/homework/optionresponse.pm:1.61 loncom/homework/optionresponse.pm:1.62
--- loncom/homework/optionresponse.pm:1.61	Mon Nov 11 15:13:47 2002
+++ loncom/homework/optionresponse.pm	Mon Nov 11 15:26:59 2002
@@ -1,7 +1,7 @@
 # LearningOnline Network with CAPA
 # option list style responses
 #
-# $Id: optionresponse.pm,v 1.61 2002/11/11 20:13:47 sakharuk Exp $
+# $Id: optionresponse.pm,v 1.62 2002/11/11 20:26:59 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -318,22 +318,30 @@
   my @whichopt = &whichfoils($max,$randomize);
   my $part=$Apache::inputtags::part;
   my $id=$Apache::inputtags::response[-1];
+  my $break;
   if (($Apache::lonhomework::history{"resource.$part.solved"} =~ /^correct/)  || ($Apache::inputtags::status[-1] eq  'SHOW_ANSWER')) {    
     my $temp=1; ####
     foreach $name (@whichopt) {
-      if ($target eq 'web') {
-	  $result.="<br />";
+	my $text=$Apache::response::foilgroup{$name.'.text'};
+	if ($text!~/^\s*$/) {
+	    if ($target eq 'tex') {
+		$break='\vskip 0 mm ';
+	    } elsif ($target eq 'web') {
+		$break='<br />';
+	    }
+	}
+	$result.=$break;
+	if ($target eq 'web') {
+	    my $value=$Apache::response::foilgroup{$name.'.value'};
+	    if (!($text=~s|<drawoptionlist\s*/>|$value|)) {
+		if ($text=~/^\s*$/) {
+		    $text=$value.$text;
+		} else {
+		    $text=$value.': '.$text;
+		}
+	    }
+	    $result.=$text."\n";
       } elsif ($target eq 'tex') {
-	  $result.='\vskip 0 mm ';
-      }
-      if ($target ne 'tex') {
-	  my $text=$Apache::response::foilgroup{$name.'.text'};
-	  my $value=$Apache::response::foilgroup{$name.'.value'};
-	  if (!($text=~s|<drawoptionlist\s*/>|$value|)) {
-	      $text=$value.': '.$text;
-	  }
-	  $result.=$text."\n";
-      } else {
 	  $Apache::response::foilgroup{$name.'.text'}=~s/\\item//;
  	  $result .='\item \textit{'.$Apache::response::foilgroup{$name.'.value'}.'}'.
 	      ":".$Apache::response::foilgroup{$name.'.text'}."\n";
@@ -351,6 +359,14 @@
     my $temp=1;
     my %lastresponse=&Apache::lonnet::str2hash($Apache::lonhomework::history{"resource.$part.$id.submission"});
     foreach $name (@whichopt) {
+      my $text=$Apache::response::foilgroup{$name.'.text'};
+      if ($text!~/^\s*$/) {
+	  if ($target eq 'tex') {
+	      $break='\vskip 0 mm ';
+	  } elsif ($target eq 'web') {
+	      $break='<br />';
+	  }
+      }
       my $lastopt=$lastresponse{$name};
       my $optionlist="<option></option>\n";
       my $option;
@@ -369,7 +385,7 @@
 	  if (!($text=~s|<drawoptionlist\s*/>|$optionlist|)) {
 	      $text=$optionlist.$text;
 	  }
-	  $result.="<br />".$text."\n";
+	  $result.=$break.$text."\n";
 	  if ($Apache::lonhomework::type eq 'exam') {
 	    $result.=&webbubbles(\@opt,\@alphabet);
 	  }
@@ -417,13 +433,12 @@
 		  $result.=&bubbles(\@alphabet,\@opt);
 	      }
 	  }
-      } 
+      }
     }
-  } 
-  if ($target ne 'tex') {
-      return $result."<br />";
   }
-  else {
+  if ($target ne 'tex') {
+      return $result.$break;
+  } else {
       return $result;
   }
 }