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

sakharuk lon-capa-cvs@mail.lon-capa.org
Mon, 26 Aug 2002 20:29:30 -0000


sakharuk		Mon Aug 26 16:29:30 2002 EDT

  Modified files:              
    /loncom/homework	structuretags.pm 
  Log:
  Statements now can be printed correctly, for example: You are correct. Your receipt is 596-2276.
  
  
Index: loncom/homework/structuretags.pm
diff -u loncom/homework/structuretags.pm:1.105 loncom/homework/structuretags.pm:1.106
--- loncom/homework/structuretags.pm:1.105	Fri Aug 23 17:17:16 2002
+++ loncom/homework/structuretags.pm	Mon Aug 26 16:29:30 2002
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA 
 # definition of tags that give a structure to a document
 #
-# $Id: structuretags.pm,v 1.105 2002/08/23 21:17:16 albertel Exp $
+# $Id: structuretags.pm,v 1.106 2002/08/26 20:29:30 sakharuk Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -379,27 +379,61 @@
   my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_;
   my $result='';
   my $status=$Apache::inputtags::status['-1'];
-  if ($target eq 'grade' || $target eq 'web' || $target eq 'answer' ) {
+  if ($target eq 'grade' || $target eq 'web' || $target eq 'answer' || $target eq 'tex') {
     if ( $target eq 'grade' && $Apache::inputtags::part eq '0') {
       # if part is zero, no <part>s existed, so we need to the grading
       &Apache::inputtags::grade;
-    } elsif ( $target eq 'web' && $Apache::inputtags::part eq '0' && 
+    } elsif ( ($target eq 'web' || $target eq 'tex') && $Apache::inputtags::part eq '0' && 
 	      $status ne 'UNCHECKEDOUT') {
       # if part is zero, no <part>s existed, so we need show the current 
       # grading status
-      $result.= &Apache::inputtags::gradestatus($Apache::inputtags::part);
+      my $gradesatement = &Apache::inputtags::gradestatus($Apache::inputtags::part);
+      if ($target eq 'tex') {
+	  $gradesatement =~ s/<table>//;
+	  $gradesatement =~ s/<\/table>//;
+	  $gradesatement =~ s/<tr([^>]*)>//g;
+	  $gradesatement =~ s/<\/tr>//g;
+	  $gradesatement =~ s/<td([^>]*)>//g;
+	  $gradesatement =~ s/<\/td>//g;
+	  $gradesatement =~ s/<b>/\\textbf{/g;
+	  $gradesatement =~ s/<\/b>/}/g;
+	  $gradesatement =~ s/<br \/>/\\vskip 0 mm /g;
+	  $gradesatement =~ s/<input([^>]*)>//g;
+      }
+      $result.= $gradesatement;
+      if ($target eq 'tex') {
+	  $result .= '\vskip 0.5mm\noindent\makebox[\textwidth/$number_of_columns][b]{\hrulefill}';
+	  if (not $ENV{'request.symb'} =~ m/\.page_/) {
+	      $result .= '\end{document} ';
+	  } else {
+	      $result .= '} ';
+	  }
+      }
     }
     if (
-	($target eq 'web' && ($ENV{'request.state'} ne 'construct')) ||
+	(($target eq 'web' || $target eq 'tex') && ($ENV{'request.state'} ne 'construct')) ||
 	($target eq 'answer')
        ) {
       if ($status eq 'CAN_ANSWER') {
-	$result.="</form></body>\n"; 
+	  if ($target ne 'tex') {
+	      $result.="</form></body>\n";
+	  } 
       } elsif ($status eq 'SHOW_ANSWER' || $status eq 'CANNOT_ANSWER' ||
 	       $status eq 'UNCHECKEDOUT' ) {
-	$result.="</body>\n";
+	  if ($target ne 'tex') {
+	      $result.="</body>\n";
+	  }
+      }
+      if ($target ne 'tex') {
+	  $result.=&Apache::lonxml::xmlend();
+      } else {
+	      $result .= '\vskip 0.5mm\noindent\makebox[\textwidth/$number_of_columns][b]{\hrulefill}';
+	      if (not $ENV{'request.symb'} =~ m/\.page_/) {
+		  $result .= '\end{document} ';
+	      } else {
+		  $result .= '} ';
+	      }
       }
-      $result.=&Apache::lonxml::xmlend();
     }
     if ($target eq 'grade') { 
       &Apache::lonhomework::showhash(%Apache::lonhomework::results);
@@ -412,14 +446,7 @@
   } elsif ($target eq 'edit') {
     &Apache::lonxml::debug("in end_problem with $target, edit");
     $result = &problem_edit_footer();
-  } elsif ($target eq 'tex') {
-      $result .= '\vskip 0.5mm\noindent\makebox[\textwidth/$number_of_columns][b]{\hrulefill}';
-      if (not $ENV{'request.symb'} =~ m/\.page_/) {
-	  $result .= '\end{document} ';
-      } else {
-	  $result .= '} ';
-      }
-  }
+  } 
   return $result;
 }