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

albertel lon-capa-cvs@mail.lon-capa.org
Mon, 26 Aug 2002 21:01:52 -0000


albertel		Mon Aug 26 17:01:52 2002 EDT

  Modified files:              
    /loncom/homework	structuretags.pm 
  Log:
  - I am ugly shoot me
  
  
Index: loncom/homework/structuretags.pm
diff -u loncom/homework/structuretags.pm:1.107 loncom/homework/structuretags.pm:1.108
--- loncom/homework/structuretags.pm:1.107	Mon Aug 26 16:42:36 2002
+++ loncom/homework/structuretags.pm	Mon Aug 26 17:01:52 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.107 2002/08/26 20:42:36 sakharuk Exp $
+# $Id: structuretags.pm,v 1.108 2002/08/26 21:01:52 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -387,20 +387,10 @@
 	      $status ne 'UNCHECKEDOUT') {
       # if part is zero, no <part>s existed, so we need show the current 
       # grading status
-      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;
+      my $gradestatus = &Apache::inputtags::gradestatus($Apache::inputtags::part);
+      #FIXME this is ugly we should just generate tex in inputtags
+      if ($target eq 'tex') { $gradestatus=&html_to_tex($gradestatus); }
+      $result.= $gradestatus;
     }
     if (
 	(($target eq 'web' || $target eq 'tex') && ($ENV{'request.state'} ne 'construct')) ||
@@ -442,6 +432,22 @@
   return $result;
 }
 
+#FIXME I am ugly shoot me
+sub html_to_tex {
+  my ($string)=@_;
+  $string =~ s/<table>//;
+  $string =~ s/<\/table>//;
+  $string =~ s/<tr([^>]*)>//g;
+  $string =~ s/<\/tr>//g;
+  $string =~ s/<td([^>]*)>//g;
+  $string =~ s/<\/td>//g;
+  $string =~ s/<b>/\\textbf{/g;
+  $string =~ s/<\/b>/}/g;
+  $string =~ s/<br \/>/\\vskip 0 mm /g;
+  $string =~ s/<input([^>]*)>//g;
+  return $string;
+}
+
 sub start_library {
   my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_;
   my ($result,$head_tag_start,$body_tag_start,$form_tag_start)=
@@ -645,8 +651,11 @@
   if ( $target eq 'grade' && $status eq 'CAN_ANSWER') {
     return &Apache::inputtags::grade;
   }
-  if ($target eq 'web') {
-    return &Apache::inputtags::gradestatus($Apache::inputtags::part);
+  if ($target eq 'web' || $target eq 'tex' ) {
+    my $gradestatus=&Apache::inputtags::gradestatus($Apache::inputtags::part);
+    #FIXME this is ugly we should just generate tex in inputtags
+    if ($target eq 'tex') { $gradestatus=&html_to_tex($gradestatus); }
+    return $gradestatus;
   }
   return '';
 }