Diff for /loncom/xml/lonxml.pm between versions 1.298 and 1.303

version 1.298, 2004/01/28 16:10:26 version 1.303, 2004/02/26 23:39:03
Line 405  sub latex_special_symbols { Line 405  sub latex_special_symbols {
  $string =~ s/_/ /g;   $string =~ s/_/ /g;
     } else {      } else {
  $string=~s/\\ /\\char92 /g;   $string=~s/\\ /\\char92 /g;
  $string=~s/\^/\\\^ /g;   $string=~s/\^/\\\^\\strut /g;
  $string=~s/\~/\\char126 /g;   $string=~s/\~/\\char126 /g;
  #fixup & if it doesn't look like   #fixup & if it doesn't look like
         # { or α          # { or α
  $string=~s/(&(?!((\#[0-9]+)|([a-z]+));))/\\$1/gi;   $string=~s/(&(?!((\#[0-9]+)|([a-z]+));))/\\$1/gi;
  $string=~s/([^&])\#/$1\\#/g;          $string=~s/([^&\\])\#/$1\\#/g;
    $string=~s/\#\#/\#\\#/g;
  $string=~s/(\$|_|{|})/\\$1/g;   $string=~s/(\$|_|{|})/\\$1/g;
  $string=~s/\\char92 /\\texttt{\\char92}/g;   $string=~s/\\char92 /\\texttt{\\char92}/g;
  $string=~s/(>|<)/\$$1\$/g; #more or less   $string=~s/(>|<)/\$$1\$/g; #more or less
Line 759  sub init_safespace { Line 760  sub init_safespace {
   $safeinit .= ';$external::randomseed='.$rndseed.';';    $safeinit .= ';$external::randomseed='.$rndseed.';';
   &Apache::lonxml::debug("Setting rndseed to $rndseed");    &Apache::lonxml::debug("Setting rndseed to $rndseed");
   &Apache::run::run($safeinit,$safeeval);    &Apache::run::run($safeinit,$safeeval);
   
     my $subroutine=<<'EVALUATESUB';
   sub __LC_INTERNAL_EVALUATE__ {
       my ($__LC__a,$__LC__b,$__LC__c)=@_;
       my $__LC__prefix;
       my $__LC__msg;
       while(1){
    { 
       use strict;
       if (eval(defined(eval($__LC__a.$__LC__b)))) {
    return $__LC__msg.$__LC__prefix.eval($__LC__a.$__LC__b.$__LC__c);
       }
    }
    $__LC__prefix.=substr($__LC__a,0,1,"");
    if ($__LC__a!~/^(\$|&|\#)/) { last; }
       }
       return $__LC__prefix.$__LC__a.$__LC__b.$__LC__c.$__LC__msg;
   }
   EVALUATESUB
       $safeeval->permit("require");
       $safeeval->reval($subroutine);
       $safeeval->deny("require");
 }  }
   
 sub default_homework_load {  sub default_homework_load {
Line 1296  sub display_title { Line 1319  sub display_title {
 sub debug {  sub debug {
     if ($Apache::lonxml::debug eq "1") {      if ($Apache::lonxml::debug eq "1") {
  $|=1;   $|=1;
  Apache->request->print('<font size="-2"<pre>DEBUG:'.&HTML::Entities::encode($_[0])."</pre></font>\n");   my $request=$Apache::lonxml::request;
    if (!$request) { $request=Apache->request; }
    $request->print('<font size="-2"><pre>DEBUG:'.&HTML::Entities::encode($_[0])."</pre></font>\n");
     }      }
 }  }
   
 sub error {  sub error {
   $errorcount++;    $errorcount++;
     my $request=$Apache::lonxml::request;
     if (!$request) { $request=Apache->request; }
   if (($Apache::lonxml::debug eq 1) || ($ENV{'request.state'} eq 'construct') ) {    if (($Apache::lonxml::debug eq 1) || ($ENV{'request.state'} eq 'construct') ) {
     # If printing in construction space, put the error inside <pre></pre>      # If printing in construction space, put the error inside <pre></pre>
       print $Apache::lonxml::warnings_error_header.        $request->print($Apache::lonxml::warnings_error_header.
   "<b>ERROR:</b>".join("\n",@_)."\n";        "<b>ERROR:</b>".join("\n",@_)."\n");
       $Apache::lonxml::warnings_error_header='';        $Apache::lonxml::warnings_error_header='';
   } else {    } else {
     print "<b>An Error occured while processing this resource. The instructor has been notified.</b> <br />";      $request->print("<b>An Error occured while processing this resource. The instructor has been notified.</b> <br />");
     #notify author      #notify author
     &Apache::lonmsg::author_res_msg($ENV{'request.filename'},join('<br />',@_));      &Apache::lonmsg::author_res_msg($ENV{'request.filename'},join('<br />',@_));
     #notify course      #notify course
Line 1321  sub error { Line 1348  sub error {
         "Error [$declutter]",join('<br />',@_));          "Error [$declutter]",join('<br />',@_));
       }        }
     }      }
   
     #FIXME probably shouldn't have me get everything forever.  
     &Apache::lonmsg::user_normal_msg('albertel','msu',"Error in $ENV{'request.filename'}",join('<br />',@_));  
     #&Apache::lonmsg::user_normal_msg('albertel','103',"Error in $ENV{'request.filename'}",$_[0]);  
   }    }
 }  }
   
Line 1333  sub warning { Line 1356  sub warning {
       
     if ($ENV{'form.grade_target'} ne 'tex') {      if ($ENV{'form.grade_target'} ne 'tex') {
  if ($ENV{'request.state'} eq 'construct' || $Apache::lonxml::debug) {   if ($ENV{'request.state'} eq 'construct' || $Apache::lonxml::debug) {
     print $Apache::lonxml::warnings_error_header.      my $request=$Apache::lonxml::request;
  "<b>W</b>ARNING<b>:</b>".join('<br />',@_)."<br />\n";      if (!$request) { $request=Apache->request; }
       $request->print($Apache::lonxml::warnings_error_header.
         "<b>W</b>ARNING<b>:</b>".join('<br />',@_)."<br />\n");
     $Apache::lonxml::warnings_error_header='';      $Apache::lonxml::warnings_error_header='';
  }   }
     }      }

Removed from v.1.298  
changed lines
  Added in v.1.303


FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>