From 31c04395b8caf8fbd9d76fbe765056cfbf765bed Mon Sep 17 00:00:00 2001 From: Ivan Tcholakov Date: Mon, 20 Sep 2010 04:26:35 +0300 Subject: [PATCH] Feature #747 - Elimination of obsolete code for Tex parsing. --- main/exercice/answer_admin.inc.php | 5 ++++- main/exercice/exercice_submit.php | 7 ++++++- main/exercice/exercise.lib.php | 5 +++++ main/exercice/exercise_result.php | 7 ++++++- main/exercice/exercise_show.php | 10 +++++++++- 5 files changed, 30 insertions(+), 4 deletions(-) diff --git a/main/exercice/answer_admin.inc.php b/main/exercice/answer_admin.inc.php index cb55891c9d..d1a908e38d 100755 --- a/main/exercice/answer_admin.inc.php +++ b/main/exercice/answer_admin.inc.php @@ -281,8 +281,10 @@ if($submitAnswers || $buttonBack) $reponse=str_replace('::','',$reponse); // we save the answer because it will be modified - $temp=$reponse; + //$temp=$reponse; + $temp = text_filter($reponse); + /* // Deprecated code. // 1. find everything between the [tex] and [/tex] tags $startlocations=api_strpos($temp,'[tex]'); $endlocations=api_strpos($temp,'[/tex]'); @@ -294,6 +296,7 @@ if($submitAnswers || $buttonBack) // 2. replace this by {texcode} $temp=str_replace($texstring,"{texcode}",$temp); } + */ // blanks will be put into an array $blanks=Array(); diff --git a/main/exercice/exercice_submit.php b/main/exercice/exercice_submit.php index 4d02383c58..847d700ec9 100755 --- a/main/exercice/exercice_submit.php +++ b/main/exercice/exercice_submit.php @@ -519,8 +519,10 @@ if ($formSent) { $answerWeighting = explode(',', $is_set_switchable[0]); // we save the answer because it will be modified - $temp = $answer; + //$temp = $answer; + $temp = text_filter($answer); + /* // Deprecated code // TeX parsing // 1. find everything between the [tex] and [/tex] tags $startlocations = api_strpos($temp, '[tex]'); @@ -531,6 +533,7 @@ if ($formSent) { // 2. replace this by {texcode} $temp = str_replace($texstring, '{texcode}', $temp); } + */ $answer = ''; $j = 0; @@ -545,9 +548,11 @@ if ($formSent) { if (($pos = api_strpos($temp, '[')) === false) { // adds the end of the text $answer = $temp; + /* // Deprecated code // TeX parsing - replacement of texcode tags $texstring = api_parse_tex($texstring); $answer = str_replace("{texcode}", $texstring, $answer); + */ $real_text[] = $answer; break; //no more "blanks", quit the loop } diff --git a/main/exercice/exercise.lib.php b/main/exercice/exercise.lib.php index 1de7ef11f1..8148b59c98 100755 --- a/main/exercice/exercise.lib.php +++ b/main/exercice/exercise.lib.php @@ -150,6 +150,8 @@ function showQuestion($questionId, $onlyAnswers = false, $origin = false, $curre list($answer) = explode('::',$answer); // because [] is parsed here we follow this procedure: + $answer = text_filter($answer); + /* // Deprecated code // 1. find everything between the [tex] and [/tex] tags $startlocations = api_strpos($answer,'[tex]'); $endlocations = api_strpos($answer,'[/tex]'); @@ -159,6 +161,7 @@ function showQuestion($questionId, $onlyAnswers = false, $origin = false, $curre // 2. replace this by {texcode} $answer = str_replace($texstring,'{texcode}',$answer); } + */ // 3. do the normal matching parsing // replaces [blank] by an input field @@ -207,9 +210,11 @@ function showQuestion($questionId, $onlyAnswers = false, $origin = false, $curre */ + /* // Deprecated code // 5. replace the {texcode by the api_pare_tex parsed code} $texstring = api_parse_tex($texstring); $answer=str_replace("{texcode}",$texstring,$answer); + */ } diff --git a/main/exercice/exercise_result.php b/main/exercice/exercise_result.php index caa84eaa0b..418fa85d41 100755 --- a/main/exercice/exercise_result.php +++ b/main/exercice/exercise_result.php @@ -685,8 +685,10 @@ foreach ($questionList as $questionId) { $answerWeighting = explode(',',$is_set_switchable[0]); // we save the answer because it will be modified - $temp=$answer; + //$temp=$answer; + $temp = text_filter($answer); + /* // Deprecated code. // TeX parsing // 1. find everything between the [tex] and [/tex] tags $startlocations=api_strpos($temp,'[tex]'); @@ -698,6 +700,7 @@ foreach ($questionList as $questionId) { // 2. replace this by {texcode} $temp=str_replace($texstring,'{texcode}',$temp); } + */ $answer=''; $j=0; @@ -714,9 +717,11 @@ foreach ($questionList as $questionId) { { // adds the end of the textsolution $answer=$temp; + /* // Deprecated code. // TeX parsing - replacement of texcode tags $texstring = api_parse_tex($texstring); $answer=str_replace("{texcode}",$texstring,$answer); + */ $real_text[] = $answer; break; //no more "blanks", quit the loop } diff --git a/main/exercice/exercise_show.php b/main/exercice/exercise_show.php index ecf2984b18..2a5551dc86 100755 --- a/main/exercice/exercise_show.php +++ b/main/exercice/exercise_show.php @@ -634,8 +634,10 @@ if ($show_results) { //$answerWeighting=explode(',',$answerWeighting); // we save the answer because it will be modified - $temp=$answer; + //$temp=$answer; + $temp = text_filter($answer); + /* // Deprecated code // TeX parsing // 1. find everything between the [tex] and [/tex] tags $startlocations=api_strpos($temp,'[tex]'); @@ -645,6 +647,8 @@ if ($show_results) { // 2. replace this by {texcode} $temp=str_replace($texstring,'{texcode}',$temp); } + */ + $j=0; // the loop will stop at the end of the text $i=0; @@ -655,8 +659,10 @@ if ($show_results) { if (($pos = api_strpos($temp,'[')) === false) { // adds the end of the text $answer.=$temp; + /* // Deprecated code // TeX parsing $texstring = api_parse_tex($texstring); + */ break; } $temp=api_substr($temp,$pos+1); @@ -703,9 +709,11 @@ if ($show_results) { if (($pos = api_strpos($temp,'[')) === false) { // adds the end of the text $answer.=$temp; + /* // Deprecated code // TeX parsing $texstring = api_parse_tex($texstring); //$answer=str_replace("{texcode}",$texstring,$answer); + */ break; } // adds the piece of text that is before the blank and ended by [