]> git.mjollnir.org Git - moodle.git/commitdiff
Bug fix for incorrect handling of negatives in equations and inequalities
authorfiedorow <fiedorow>
Tue, 30 Mar 2004 17:11:56 +0000 (17:11 +0000)
committerfiedorow <fiedorow>
Tue, 30 Mar 2004 17:11:56 +0000 (17:11 +0000)
filter/algebra/AlgParser.pm
filter/algebra/algebradebug.php
filter/algebra/filter.php

index 43982930520ecd8f296a21b25e6c1d0bfccf7833..6ab1e7967a9b2d72a120e0f0ba3ddcf24a746eef 100755 (executable)
@@ -42,7 +42,7 @@ $binoper1 = '[-+=><%!#]';
 $openparen = '[{(\\[]';
 $closeparen = '[})\\]]';
 $varname = '[A-Za-z](?:_[0-9]+)?';
-$specialvalue = '(?:e|pi|da|db|dc|de|df|dg|dh|di|dj|dk|dl|dm|dn|do|dp|dq|dr|ds|dt|du|dv|dw|dx|dy|dz|infty|alpha|bita|gamma|zita|thita|iota|kappa|lambda|mu|nu|xi|rho|sigma|tau|phi|chi|psi|omega|zepslon|zdelta|xeta|zupslon)';
+$specialvalue = '(?:e|pi|da|db|dc|de|df|dg|dh|di|dj|dk|dl|dm|dn|do|dp|dq|dr|ds|dt|du|dv|dw|dx|dy|dz|infty|alpha|bita|gamma|zita|thita|iota|kappa|lambda|mu|nu|xi|rho|sigma|tau|phi|chi|psi|omega|zepslon|zdelta|xeta|zupslon|zeroplace)';
 $numberplain = '(?:\d+(?:\.\d*)?|\.\d+)';
 $numberE = '(?:' . $numberplain . 'E[-+]?\d+)';
 $number = '(?:' . $numberE . '|' . $numberplain . ')';
index caff0f6311596194dd902ddaf043a55930756683..c5af44fe180e8242479043e89282f09136b8c59a 100644 (file)
@@ -74,6 +74,7 @@ function algebra2tex($algebra) {
   $algebra = str_replace('<>','#',$algebra);
   $algebra = str_replace('<=','%',$algebra);
   $algebra = str_replace('>=','!',$algebra);
+  $algebra = preg_replace('/([=><%!#] *)-/',"\$1 zeroplace -",$algebra);
   $algebra = str_replace('delta','zdelta',$algebra);
   $algebra = str_replace('beta','bita',$algebra);
   $algebra = str_replace('theta','thita',$algebra);
@@ -95,6 +96,7 @@ function algebra2tex($algebra) {
 }
 
 function refineTeX($texexp) {
+  $texexp = str_replace('zeroplace','',$texexp);
   $texexp = str_replace('#','\not= ',$texexp);
   $texexp = str_replace('%','\leq ',$texexp);
   $texexp = str_replace('!','\geq ',$texexp);
index c38cda28a08df887f37b4c2ba176d9a2dd3dd902..81947657f272fb036c6285bfaaf3fae80b610153 100644 (file)
@@ -150,6 +150,7 @@ function algebra_filter ($courseid, $text) {
            $algebra = str_replace('<>','#',$algebra);
            $algebra = str_replace('<=','%',$algebra);
            $algebra = str_replace('>=','!',$algebra);
+           $algebra = preg_replace('/([=><%!#] *)-/',"\$1 zeroplace -",$algebra);
            $algebra = str_replace('delta','zdelta',$algebra);
            $algebra = str_replace('beta','bita',$algebra);
            $algebra = str_replace('theta','thita',$algebra);
@@ -169,6 +170,7 @@ function algebra_filter ($courseid, $text) {
            if (preg_match('/parsehilight/',$texexp)) {
              $text = str_replace( $matches[0][$i],"<b>Syntax error:</b> " . $texexp,$text);
            } else if ($texexp) {
+              $texexp = str_replace('zeroplace','',$texexp);
               $texexp = str_replace('#','\not= ',$texexp);
               $texexp = str_replace('%','\leq ',$texexp);
               $texexp = str_replace('!','\geq ',$texexp);