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

sakharuk lon-capa-cvs@mail.lon-capa.org
Mon, 11 Nov 2002 15:58:51 -0000


sakharuk		Mon Nov 11 10:58:51 2002 EDT

  Modified files:              
    /loncom/homework	optionresponse.pm 
  Log:
  TeX version of Guy's <drawoptionlist /> tag is implemented. This is very 
  preliminary implementation and I have to return to it after finishing work
  with two types of exam - bubble and online.
  
  
Index: loncom/homework/optionresponse.pm
diff -u loncom/homework/optionresponse.pm:1.59 loncom/homework/optionresponse.pm:1.60
--- loncom/homework/optionresponse.pm:1.59	Sun Nov 10 10:51:31 2002
+++ loncom/homework/optionresponse.pm	Mon Nov 11 10:58:51 2002
@@ -1,7 +1,7 @@
 # LearningOnline Network with CAPA
 # option list style responses
 #
-# $Id: optionresponse.pm,v 1.59 2002/11/10 15:51:31 albertel Exp $
+# $Id: optionresponse.pm,v 1.60 2002/11/11 15:58:51 sakharuk Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -375,14 +375,20 @@
 	  }
 	  $temp++;
       } else {
+          my $texoptionlist = &optionlist_correction($optionlist);
 	  if ($displayoptionintex == 0) {
-              my $texoptionlist = &optionlist_correction($optionlist);
-	      if ($Apache::lonhomework::type eq 'exam') {$texoptionlist='';}
+	      if ($Apache::lonhomework::type eq 'exam') {$texoptionlist='';} #if exam we do not need to show optionlist
 	      if ($Apache::response::foilgroup{$name.'.text'}=~m/\\item /) {
-		  if ($Apache::lonhomework::type eq 'exam') {
-		      $Apache::response::foilgroup{$name.'.text'}=~s/\\item/\\item[\\textbf{$Apache::lonxml::counter}\.]/;
-		  }
-		  $result.= $texoptionlist.$Apache::response::foilgroup{$name.'.text'};
+		if ($Apache::lonhomework::type eq 'exam') {
+	          $Apache::response::foilgroup{$name.'.text'}=~s/\\item/\\item[\\textbf{$Apache::lonxml::counter}\.]/;
+	        }
+	        if ($Apache::response::foilgroup{$name.'.text'}=~/<drawoptionlist\s*\/>/) {
+		  $texoptionlist = &texoptionlist_correction($texoptionlist);
+	          $Apache::response::foilgroup{$name.'.text'}=~s|<drawoptionlist\s*/>|$texoptionlist|;
+	          $result.= $Apache::response::foilgroup{$name.'.text'};
+	        } else {
+	          $result.= $texoptionlist.$Apache::response::foilgroup{$name.'.text'};
+	        }
 	      } else {
 		  if ($Apache::lonhomework::type eq 'exam') {
 		      $result.= $texoptionlist.'\vspace*{-2 mm}\item[\textbf{'.$Apache::lonxml::counter.'}.]'.$Apache::response::foilgroup{$name.'.text'};
@@ -399,7 +405,11 @@
 		  if ($Apache::lonhomework::type eq 'exam') {
 		      $Apache::response::foilgroup{$name.'.text'}=~s/\\item/\\item[\\textbf{$Apache::lonxml::counter}\.]/;
 		  }
-		  $result.= $Apache::response::foilgroup{$name.'.text'};
+	        if ($Apache::response::foilgroup{$name.'.text'}=~/<drawoptionlist\s*\/>/) {
+		  $texoptionlist = &texoptionlist_correction($texoptionlist);
+	          $Apache::response::foilgroup{$name.'.text'}=~s|<drawoptionlist\s*/>|$texoptionlist|;
+	        }
+		$result.= $Apache::response::foilgroup{$name.'.text'};
 	      } else {
 		  if ($Apache::lonhomework::type eq 'exam') {
 		      $result.= '\item[\textbf{'.$Apache::lonxml::counter.'}.]'.$Apache::response::foilgroup{$name.'.text'};
@@ -434,6 +444,14 @@
     $texoptionlist =~ s/>/\$>\$/g;
     $texoptionlist =~ s/</\$<\$/g;
     $texoptionlist =~ s/=/\$=\$/g;
+    return $texoptionlist;
+}
+
+
+sub texoptionlist_correction {
+    my $texoptionlist = shift;
+    $texoptionlist =~ s/\\item \[\] Possible answers are:\s*/\\fbox\{/;
+    $texoptionlist =~ s/\.$/}/;
     return $texoptionlist;
 }