From 6388bd2f00858963a19bbc19b89bc8321b8d83d5 Mon Sep 17 00:00:00 2001 From: Ivan Tcholakov Date: Mon, 20 Sep 2010 03:46:35 +0300 Subject: [PATCH] Feature #747 - Replacement of the function api_parse_tex() with the function text_filter() which has generic purpose. The function text_filter is dummy yet, it may be developed in the future. --- main/exercice/exercice.php | 18 +++++----- main/exercice/exercice_submit.php | 4 +-- main/exercice/exercise.lib.php | 14 ++++---- main/exercice/exercise_result.php | 8 ++--- main/exercice/exercise_show.php | 2 +- main/exercice/export/scorm/scorm_classes.php | 14 ++++---- main/exercice/question.class.php | 38 ++++++++++---------- main/inc/lib/exercise_show_functions.lib.php | 6 ++-- main/newscorm/learnpath_functions.inc.php | 10 +++--- 9 files changed, 57 insertions(+), 57 deletions(-) mode change 100644 => 100755 main/exercice/export/scorm/scorm_classes.php diff --git a/main/exercice/exercice.php b/main/exercice/exercice.php index b4585707b1..23ee6c77df 100755 --- a/main/exercice/exercice.php +++ b/main/exercice/exercice.php @@ -869,7 +869,7 @@ if ($show == 'test') { echo ''.($i+($page*$limitExPage)).'.'.''; //Showing exercise title - $row['title']=api_parse_tex($row['title']); + $row['title']=text_filter($row['title']); echo ''; $class_invisible = ''; @@ -928,7 +928,7 @@ if ($show == 'test') { ?> - + ".COURSE_RELATION_TYPE_RRHH." $user_id_and $session_id_and AND ce.active <>-1 AND" . " orig_lp_id = 0 AND orig_lp_item_id = 0 AND cuser.course_code=te.exe_cours_id ORDER BY userpart2, te.exe_cours_id ASC, ce.title ASC," . @@ -1166,7 +1166,7 @@ if ($_configuration['tracking_enabled'] && ($show == 'result')) { $from_gradebook = true; } $sizeof = sizeof($results); - + $user_list_id = array (); $user_last_name = ''; $user_first_name = ''; @@ -1225,13 +1225,13 @@ if ($_configuration['tracking_enabled'] && ($show == 'result')) { //echo ceil((($results[$i][4] - $results[$i][7]) / 60)) . ' ' . get_lang('MinMinutes'); $exe_date_timestamp = api_strtotime($results[$i]['exdate'], date_default_timezone_get()); $start_date_timestamp = api_strtotime($results[$i]['exstart'], date_default_timezone_get()); - + $my_duration = ceil((($exe_date_timestamp - $start_date_timestamp) / 60)); - if ($my_duration == 1 ) { - $duration_list = $my_duration . ' ' . get_lang('MinMinute'); + if ($my_duration == 1 ) { + $duration_list = $my_duration . ' ' . get_lang('MinMinute'); } else { - $duration_list = $my_duration. ' ' . get_lang('MinMinutes'); - } + $duration_list = $my_duration. ' ' . get_lang('MinMinutes'); + } if ($results[$i]['exstep'] > 1) { //echo ' ( ' . $results[$i][8] . ' ' . get_lang('Steps') . ' )'; $duration_list = ' ( ' . $results[$i]['exstep'] . ' ' . get_lang('Steps') . ' )'; diff --git a/main/exercice/exercice_submit.php b/main/exercice/exercice_submit.php index 9939c932f9..4d02383c58 100755 --- a/main/exercice/exercice_submit.php +++ b/main/exercice/exercice_submit.php @@ -780,7 +780,7 @@ if ($formSent) { $current_time = time(); //The $exercise_row['expired_time'][$exerciseId] is never set. It means nothing. - //if (isset($_SESSION['expired_time'][$current_expired_time_key]) && $exercise_row['expired_time'][$exerciseId] != 0) { + //if (isset($_SESSION['expired_time'][$current_expired_time_key]) && $exercise_row['expired_time'][$exerciseId] != 0) { if (isset($_SESSION['expired_time'][$current_expired_time_key])) { $expired_date = $_SESSION['expired_time'][$current_expired_time_key]; $expired_time = strtotime($expired_date); @@ -1086,7 +1086,7 @@ if (api_is_course_admin() && $origin != 'learnpath') { echo ''; } -$exerciseTitle = api_parse_tex($exerciseTitle); +$exerciseTitle = text_filter($exerciseTitle); echo "

" . $exerciseTitle . "

"; $show_clock = true; diff --git a/main/exercice/exercise.lib.php b/main/exercice/exercise.lib.php index 37fa1bd161..1de7ef11f1 100755 --- a/main/exercice/exercise.lib.php +++ b/main/exercice/exercise.lib.php @@ -47,7 +47,7 @@ function showQuestion($questionId, $onlyAnswers = false, $origin = false, $curre $questionName=$objQuestionTmp->selectTitle(); $questionDescription=$objQuestionTmp->selectDescription(); - $questionName=api_parse_tex($questionName); + $questionName=text_filter($questionName); $s="
".get_lang('Question').' '; @@ -63,7 +63,7 @@ function showQuestion($questionId, $onlyAnswers = false, $origin = false, $curre $s=''; $s.="
"; - $questionDescription=api_parse_tex($questionDescription); + $questionDescription=text_filter($questionDescription); $s.=$questionDescription; $s.="
"; @@ -224,7 +224,7 @@ function showQuestion($questionId, $onlyAnswers = false, $origin = false, $curre $selected = 'checked="checked"'; } } - $answer = api_parse_tex($answer); + $answer = text_filter($answer); $answer = Security::remove_XSS($answer, STUDENT); $s .= ''. '

'. @@ -244,7 +244,7 @@ function showQuestion($questionId, $onlyAnswers = false, $origin = false, $curre $selected = 'checked="checked"'; } } - $answer = api_parse_tex($answer); + $answer = text_filter($answer); $answer = Security::remove_XSS($answer, STUDENT); $s .= ''. '

'. @@ -264,7 +264,7 @@ function showQuestion($questionId, $onlyAnswers = false, $origin = false, $curre $selected = 'checked="checked"'; } } - $answer = api_parse_tex($answer); + $answer = text_filter($answer); $answer = Security::remove_XSS($answer, STUDENT); $s .= ''. '

'. @@ -284,7 +284,7 @@ function showQuestion($questionId, $onlyAnswers = false, $origin = false, $curre // only show elements to be answered (not the contents of // the select boxes, who are corrrect = 0) $s .= ''; - $parsed_answer = api_parse_tex($answer); + $parsed_answer = text_filter($answer); //left part questions $s .= ' '.$lines_count.' '.$parsed_answer.''; @@ -390,7 +390,7 @@ function showQuestion($questionId, $onlyAnswers = false, $origin = false, $curre echo ''; } diff --git a/main/exercice/exercise_result.php b/main/exercice/exercise_result.php index 2f8d5a3d04..caa84eaa0b 100755 --- a/main/exercice/exercise_result.php +++ b/main/exercice/exercise_result.php @@ -314,14 +314,14 @@ function display_unique_or_multiple_answer($answerType, $studentChoice, $answer, '; - echo ''; + echo ''; echo ''; } } diff --git a/main/exercice/exercise_show.php b/main/exercice/exercise_show.php index 1ac46877a6..ecf2984b18 100755 --- a/main/exercice/exercise_show.php +++ b/main/exercice/exercise_show.php @@ -269,7 +269,7 @@ $show_results = true; // Avoiding the "Score 0/0" message when the exe_id is not set if (Database::num_rows($result)>0 && isset($id)) { $test=Database::result($result,0,0); - $exerciseTitle=api_parse_tex($test); + $exerciseTitle=text_filter($test); $exerciseDescription=Database::result($result,0,1); // if the results_disabled of the Quiz is 1 when block the script diff --git a/main/exercice/export/scorm/scorm_classes.php b/main/exercice/export/scorm/scorm_classes.php old mode 100644 new mode 100755 index 358fb5b035..748cf26664 --- a/main/exercice/export/scorm/scorm_classes.php +++ b/main/exercice/export/scorm/scorm_classes.php @@ -129,12 +129,12 @@ class ScormQuestion extends Question $cols = 2; $s='' . '' . "\n" . '' . "\n" . '' . "\n" . '' . "\n" . '' . "\n"; return $s; @@ -174,7 +174,7 @@ class ScormAnswerMultipleChoice extends Answer $type = $this->getQuestionType(); $jstmpw = 'questions_answers_ponderation['.$this->questionJSId.'] = new Array();'."\n"; $jstmpw .= 'questions_answers_ponderation['.$this->questionJSId.'][0] = 0;'."\n"; - + //not sure if we are going to export also the MULTIPLE_ANSWER_COMBINATION to SCORM //if ($type == MCMA || $type == MULTIPLE_ANSWER_COMBINATION ) { if ($type == MCMA ) { @@ -208,7 +208,7 @@ class ScormAnswerMultipleChoice extends Answer $js .= 'questions_types['.$this->questionJSId.'] = \'mcma\';'."\n"; } else { $js .= 'questions_types['.$this->questionJSId.'] = \'exact\';'."\n"; - } + } $js .= $jstmpw; } elseif ($type == MULTIPLE_ANSWER_COMBINATION) { //To this items we show the ThisItemIsNotExportable @@ -443,7 +443,7 @@ class ScormAnswerMatching extends Answer // options (A, B, C, ...) that will be put into the list-box $Select[$answerId]['Lettre']=$cpt1; // answers that will be shown at the right side - $answer = api_parse_tex($answer); + $answer = text_filter($answer); $Select[$answerId]['Reponse']=$answer; $cpt1++; } @@ -722,14 +722,14 @@ class ScormAnswerHotspot extends Answer { $s=" diff --git a/main/exercice/question.class.php b/main/exercice/question.class.php index c50fb82482..241db19e13 100755 --- a/main/exercice/question.class.php +++ b/main/exercice/question.class.php @@ -42,7 +42,7 @@ abstract class Question public $picture; public $exerciseList; // array with the list of exercises which this question is in private $isContent; - + static $typePicture = 'new_question.png'; static $explanationLangVar = ''; static $questionTypes = array( @@ -70,7 +70,7 @@ abstract class Question $this->level = 1; $this->exerciseList=array(); } - + public function getIsContent() { $isContent = intval($_REQUEST['isContent']); return $this->isContent = $isContent; @@ -142,7 +142,7 @@ abstract class Question */ function selectTitle() { - $this->question=api_parse_tex($this->question); + $this->question=text_filter($this->question); return $this->question; } @@ -154,7 +154,7 @@ abstract class Question */ function selectDescription() { - $this->description=api_parse_tex($this->description); + $this->description=text_filter($this->description); return $this->description; } @@ -516,15 +516,15 @@ abstract class Question // saves the picture into a temporary file @move_uploaded_file($Picture,$picturePath.'/tmp.'.$Extension); } - + /** - Sets the title + Sets the title */ public function setTitle($title) { - $this->question = $title; + $this->question = $title; } - + /** * Moves the temporary question "tmp" to "quiz-$questionId" @@ -1002,10 +1002,10 @@ abstract class Question $renderer->setElementTemplate('
{label}
{element}
','questionName'); $renderer->setElementTemplate('
{label}
{element}
','questionLevel'); $form->addRule('questionName', get_lang('GiveQuestion'), 'required'); - + // default content $isContent = intval($_REQUEST['isContent']); - + // question type $answerType= intval($_REQUEST['answerType']); $form->addElement('hidden','answerType',$_REQUEST['answerType']); @@ -1101,26 +1101,26 @@ abstract class Question //2. but if it is a feedback DIRECT we only show the UNIQUE_ANSWER type that is currently available $question_type_custom_list = array ( UNIQUE_ANSWER => self::$questionTypes[UNIQUE_ANSWER]); } - + //blocking edition - + $show_quiz_edition = true; if (isset($exerciseId) && !empty($exerciseId)) { $TBL_LP_ITEM = Database::get_course_table(TABLE_LP_ITEM); $sql="SELECT max_score FROM $TBL_LP_ITEM WHERE item_type = '".TOOL_QUIZ."' AND path ='".Database::escape_string($exerciseId)."'"; $result = Database::query($sql); - if (Database::num_rows($result) > 0) { + if (Database::num_rows($result) > 0) { $show_quiz_edition = false; } } - + echo '
    '; foreach ($question_type_custom_list as $i=>$a_type) { // include the class of the type - require_once($a_type[0]); - // get the picture of the type and the langvar which describes it + require_once($a_type[0]); + // get the picture of the type and the langvar which describes it eval('$img = '.$a_type[1].'::$typePicture;'); eval('$explanation = get_lang('.$a_type[1].'::$explanationLangVar);'); echo '
  • '; @@ -1139,7 +1139,7 @@ abstract class Question echo ''; echo '
  • '; } - + echo '
  • '; echo '
    '; if ($show_quiz_edition) { @@ -1164,11 +1164,11 @@ abstract class Question { return self::$questionTypes; } - + static function updateId() { return self::$questionTypes; - } + } } endif; ?> \ No newline at end of file diff --git a/main/inc/lib/exercise_show_functions.lib.php b/main/inc/lib/exercise_show_functions.lib.php index 8145e23e64..8d9215c421 100755 --- a/main/inc/lib/exercise_show_functions.lib.php +++ b/main/inc/lib/exercise_show_functions.lib.php @@ -124,7 +124,7 @@ class ExerciseShowFunctions {
@@ -177,7 +177,7 @@ class ExerciseShowFunctions {
'; - echo $questionDescription=api_parse_tex($questionDescription); + echo $questionDescription=text_filter($questionDescription); echo '
'; } -$exerciseTitle=api_parse_tex($exerciseTitle); +$exerciseTitle=text_filter($exerciseTitle); //show exercise title ?> @@ -890,7 +890,7 @@ foreach ($questionList as $questionId) { { if ($origin != 'learnpath') { echo '
'.api_parse_tex($answer_matching[$answerId]).''.api_parse_tex($user_answer).' / '.api_parse_tex($answer_matching[$answerCorrect]).''.text_filter($answer_matching[$answerId]).''.text_filter($user_answer).' / '.text_filter($answer_matching[$answerCorrect]).'
' . "\n" . - api_parse_tex($title). + text_filter($title). '
' . "\n" . - ''.api_parse_tex($description).'' . "\n" . + ''.text_filter($description).'' . "\n" . '
 "; - $questionName=api_parse_tex($questionName); + $questionName=text_filter($questionName); $s.=$questionName; $s.="
"; - $questionDescription=api_parse_tex($questionDescription); + $questionDescription=text_filter($questionDescription); $s.=$questionDescription; $s.=" '.nl2br(make_clickable($answerComment)).''; } else { @@ -169,7 +169,7 @@ class ExerciseShowFunctions { ".$exerciseTitle.""; @@ -1482,7 +1482,7 @@ function export_exercise($item_id) $test .= ".get_lang("; } - $exerciseDescription = api_parse_tex($exerciseDescription); + $exerciseDescription = text_filter($exerciseDescription); // --------- writing the .js file with to check the correct answers begin ----------------------- $scriptfilename = "Exercice".$item_id.".js"; @@ -1716,7 +1716,7 @@ function exportitem($id, $item_id, $item_type, $add_scorm_communications = false $content = $myrow["content"]; //3.2.7 Make clickable??? $content = make_clickable($content); - $content = api_parse_tex($content); + $content = text_filter($content); //3.2.8 Write the prepared content to the export string $expcontent .= "
"; $expcontent .= $content; @@ -1755,7 +1755,7 @@ function exportitem($id, $item_id, $item_type, $add_scorm_communications = false //$content = nl2br($content); //3.2 Prepare the data for export $content = make_clickable($content); - $content = api_parse_tex($content); + $content = text_filter($content); //3.3 Get a UNIX(?<-mktime) Timestamp of the end_date for this announcement $last_post_datetime = $myrow['end_date']; // post time format datetime de mysql @@ -1801,7 +1801,7 @@ function exportitem($id, $item_id, $item_type, $add_scorm_communications = false $expcontent .= "

".$row['title']."

"; //2.a.1.2 Prepare content $content = make_clickable(nl2br($row['content'])); - $content = api_parse_tex($content); + $content = text_filter($content); //2.a.1.3 Write content to the export string $expcontent .= $content; }