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

sakharuk lon-capa-cvs@mail.lon-capa.org
Thu, 07 Nov 2002 16:45:55 -0000


sakharuk		Thu Nov  7 11:45:55 2002 EDT

  Modified files:              
    /loncom/homework	optionresponse.pm 
  Log:
  Result of on-line exam can be printed and seen on the screen correctly
  now both before and after openning answer date.
  
  
Index: loncom/homework/optionresponse.pm
diff -u loncom/homework/optionresponse.pm:1.57 loncom/homework/optionresponse.pm:1.58
--- loncom/homework/optionresponse.pm:1.57	Mon Oct 28 18:31:48 2002
+++ loncom/homework/optionresponse.pm	Thu Nov  7 11:45:55 2002
@@ -1,7 +1,7 @@
 # LearningOnline Network with CAPA
 # option list style responses
 #
-# $Id: optionresponse.pm,v 1.57 2002/10/28 23:31:48 albertel Exp $
+# $Id: optionresponse.pm,v 1.58 2002/11/07 16:45:55 sakharuk Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -318,7 +318,8 @@
   my @whichopt = &whichfoils($max,$randomize);
   my $part=$Apache::inputtags::part;
   my $id=$Apache::inputtags::response[-1];
-  if (($Apache::lonhomework::history{"resource.$part.solved"} =~ /^correct/)  || ($Apache::inputtags::status[-1] eq  'SHOW_ANSWER')) {
+  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 />";
@@ -333,6 +334,14 @@
  	  $result .='\item \textit{'.$Apache::response::foilgroup{$name.'.value'}.'}'.
 	      ":".$Apache::response::foilgroup{$name.'.text'}."\n";
       }
+      if ($Apache::lonhomework::type eq 'exam') {
+	if ($target ne 'tex') {
+	  $result.=&webbubbles(\@opt,\@alphabet);
+        } else {
+	  $result.=&bubbles(\@alphabet,\@opt);
+        }
+      }
+    $temp++;
     }
   } else {
     my $temp=1;
@@ -353,12 +362,7 @@
 	      .$optionlist
 		  ."</select>\n".$Apache::response::foilgroup{$name.'.text'}."\n";
 	  if ($Apache::lonhomework::type eq 'exam') {
-		  my $number_of_bubbles = $#opt + 1;
-		  $result.= '<table border="1"><tr>';
-		  for (my $ind=0;$ind<$number_of_bubbles;$ind++) {
-		      $result.='<td>'.$alphabet[$ind].': '.$opt[$ind].'</td>';
-		  }
-		  $result.='</tr></table>';
+	    $result.=&webbubbles(\@opt,\@alphabet);
 	  }
 	  $temp++;
       } else {
@@ -422,6 +426,22 @@
     $texoptionlist =~ s/</\$<\$/g;
     $texoptionlist =~ s/=/\$=\$/g;
     return $texoptionlist;
+}
+
+
+sub webbubbles {
+
+    my ($ropt,$ralphabet)=@_;
+    my @opt=@$ropt; 
+    my @alphabet=@$ralphabet;
+    my $result='';
+	my $number_of_bubbles = $#opt + 1;
+	$result.= '<table border="1"><tr>';
+	for (my $ind=0;$ind<$number_of_bubbles;$ind++) {
+	   $result.='<td>'.$alphabet[$ind].': '.$opt[$ind].'</td>';
+	}
+	$result.='</tr></table>';
+	return $result;
 }