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.

skala
Ivan Tcholakov 15 years ago
parent 5553a4799d
commit 6388bd2f00
  1. 18
      main/exercice/exercice.php
  2. 4
      main/exercice/exercice_submit.php
  3. 14
      main/exercice/exercise.lib.php
  4. 8
      main/exercice/exercise_result.php
  5. 2
      main/exercice/exercise_show.php
  6. 14
      main/exercice/export/scorm/scorm_classes.php
  7. 38
      main/exercice/question.class.php
  8. 6
      main/inc/lib/exercise_show_functions.lib.php
  9. 10
      main/newscorm/learnpath_functions.inc.php

@ -869,7 +869,7 @@ if ($show == 'test') {
echo '<td width="15" valign="left">'.($i+($page*$limitExPage)).'.'.'</td>';
//Showing exercise title
$row['title']=api_parse_tex($row['title']);
$row['title']=text_filter($row['title']);
echo '<td>';
$class_invisible = '';
@ -928,7 +928,7 @@ if ($show == 'test') {
?>
<tr>
<td><?php echo ($i+($page*$limitExPage)).'.'; ?></td>
<?php $row['title']=api_parse_tex($row['title']);?>
<?php $row['title']=text_filter($row['title']);?>
<td>
<?php
@ -1131,7 +1131,7 @@ if ($_configuration['tracking_enabled'] && ($show == 'result')) {
"te.exe_weighting as exweight, te.exe_date as exdate, te.exe_id as exid, email as exemail, " .
"te.start_date as exstart, steps_counter as exstep, cuser.user_id as excruid, te.exe_duration as exduration, ce.results_disabled as exdisabled
FROM $TBL_EXERCICES AS ce , $TBL_TRACK_EXERCICES AS te, $TBL_USER AS user,$tbl_course_rel_user AS cuser
WHERE user.user_id=cuser.user_id AND te.exe_exo_id = ce.id AND te.status != 'incomplete' AND cuser.user_id=te.exe_user_id
WHERE user.user_id=cuser.user_id AND te.exe_exo_id = ce.id AND te.status != 'incomplete' AND cuser.user_id=te.exe_user_id
AND te.exe_cours_id='" . Database :: escape_string($_cid) . "'
AND cuser.relation_type<>".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') . ' )';

@ -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 '</div>';
}
$exerciseTitle = api_parse_tex($exerciseTitle);
$exerciseTitle = text_filter($exerciseTitle);
echo "<h3>" . $exerciseTitle . "</h3>";
$show_clock = true;

@ -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="<div id=\"question_title\" class=\"sectiontitle\">
".get_lang('Question').' ';
@ -63,7 +63,7 @@ function showQuestion($questionId, $onlyAnswers = false, $origin = false, $curre
$s='';
$s.="<table class='exercise_questions' style='margin:4px;padding:2px;'>
<tr><td valign='top' colspan='2'>";
$questionDescription=api_parse_tex($questionDescription);
$questionDescription=text_filter($questionDescription);
$s.=$questionDescription;
$s.="</td></tr></table>";
@ -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 .= '<input type="hidden" name="choice2['.$questionId.']" value="0" />'.
'<tr><td colspan="3"><div class="u-m-answer"><p style="float: '.($is_ltr_text_direction ? 'left' : 'right').'; padding-'.($is_ltr_text_direction ? 'right' : 'left').': 4px;">'.
@ -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 .= '<input type="hidden" name="choice2['.$questionId.']" value="0" />'.
'<tr><td colspan="3"><div class="u-m-answer"><p style="float: '.($is_ltr_text_direction ? 'left' : 'right').'; padding-'.($is_ltr_text_direction ? 'right' : 'left').': 4px;">'.
@ -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 .= '<input type="hidden" name="choice2['.$questionId.']" value="0" />'.
'<tr><td colspan="3"><div class="u-m-answer"><p style="float: '.($is_ltr_text_direction ? 'left' : 'right').'; padding-'.($is_ltr_text_direction ? 'right' : 'left').': 4px;">'.
@ -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 .= '<tr><td width="45%" valign="top" >';
$parsed_answer = api_parse_tex($answer);
$parsed_answer = text_filter($answer);
//left part questions
$s .= ' <span style="float:left; width:8%;"><b>'.$lines_count.'</b>.&nbsp;</span>
<span style="float:left; width:92%;">'.$parsed_answer.'</span></td>';
@ -390,7 +390,7 @@ function showQuestion($questionId, $onlyAnswers = false, $origin = false, $curre
echo '<table class="exercise_questions" >
<tr>
<td valign="top" colspan="2">';
echo $questionDescription=api_parse_tex($questionDescription);
echo $questionDescription=text_filter($questionDescription);
echo '</td></tr>';
}

@ -314,14 +314,14 @@ function display_unique_or_multiple_answer($answerType, $studentChoice, $answer,
</td>
<td width="45%" style="border-bottom: 1px solid #4171B5;">
<?php
$answer=api_parse_tex($answer);
$answer=text_filter($answer);
echo $answer;
?>
</td>
<?php if ($feedback_type != EXERCISE_FEEDBACK_TYPE_EXAM) { ?>
<td width="45%" style="border-bottom: 1px solid #4171B5;">
<?php
$answerComment=api_parse_tex($answerComment);
$answerComment=text_filter($answerComment);
if($studentChoice)
{
if(!$answerCorrect)
@ -440,7 +440,7 @@ if (api_is_course_admin() && $origin != 'learnpath') {
echo '</div>';
}
$exerciseTitle=api_parse_tex($exerciseTitle);
$exerciseTitle=text_filter($exerciseTitle);
//show exercise title
?>
@ -890,7 +890,7 @@ foreach ($questionList as $questionId) {
{
if ($origin != 'learnpath') {
echo '<tr>';
echo '<td>'.api_parse_tex($answer_matching[$answerId]).'</td><td>'.api_parse_tex($user_answer).' / <b><span style="color: #008000;">'.api_parse_tex($answer_matching[$answerCorrect]).'</span></b></td>';
echo '<td>'.text_filter($answer_matching[$answerId]).'</td><td>'.text_filter($user_answer).' / <b><span style="color: #008000;">'.text_filter($answer_matching[$answerCorrect]).'</span></b></td>';
echo '</tr>';
}
}

@ -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

@ -129,12 +129,12 @@ class ScormQuestion extends Question
$cols = 2;
$s='<tr>' .
'<td colspan="'.$cols.'" id="question_'.$this->id.'_title" valign="middle" style="background-color:#d6d6d6;">' . "\n" .
api_parse_tex($title).
text_filter($title).
'</td>' . "\n" .
'</tr>' . "\n" .
'<tr>' . "\n" .
'<td valign="top" colspan="'.$cols.'">' . "\n" .
'<i>'.api_parse_tex($description).'</i>' . "\n" .
'<i>'.text_filter($description).'</i>' . "\n" .
'</td>' . "\n" .
'</tr>' . "\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="<tr>
<td valign='top' colspan='2'>&nbsp;";
$questionName=api_parse_tex($questionName);
$questionName=text_filter($questionName);
$s.=$questionName;
$s.="</td>
</tr>
<tr>
<td valign='top' colspan='2'>
<i>";
$questionDescription=api_parse_tex($questionDescription);
$questionDescription=text_filter($questionDescription);
$s.=$questionDescription;
$s.="</i>
</td>

@ -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('<div class="row"><div class="label">{label}</div><div class="formw" >{element}</div></div>','questionName');
$renderer->setElementTemplate('<div class="row"><div class="label">{label}</div><div class="formw">{element}</div></div>','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 '<ul class="question_menu">';
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 '<li>';
@ -1139,7 +1139,7 @@ abstract class Question
echo '</div>';
echo '</li>';
}
echo '<li>';
echo '<div class="icon_image_content">';
if ($show_quiz_edition) {
@ -1164,11 +1164,11 @@ abstract class Question
{
return self::$questionTypes;
}
static function updateId()
{
return self::$questionTypes;
}
}
}
endif;
?>

@ -124,7 +124,7 @@ class ExerciseShowFunctions {
<?php if ($feedback_type != EXERCISE_FEEDBACK_TYPE_EXAM) { ?>
<td valign="top" align="left" >
<?php
$answerComment=api_parse_tex($answerComment);
$answerComment=text_filter($answerComment);
if($studentChoice) {
echo '<span style="font-weight: bold; color: #008000;">'.nl2br(make_clickable($answerComment)).'</span>';
} else {
@ -169,7 +169,7 @@ class ExerciseShowFunctions {
</td>
<td width="40%" style="border-bottom: 1px solid #4171B5;">
<?php
$answer=api_parse_tex($answer);
$answer=text_filter($answer);
echo $answer;
?>
</td>
@ -177,7 +177,7 @@ class ExerciseShowFunctions {
<?php if ($feedback_type != EXERCISE_FEEDBACK_TYPE_EXAM) { ?>
<td width="20%" style="border-bottom: 1px solid #4171B5;">
<?php
$answerComment=api_parse_tex($answerComment);
$answerComment=text_filter($answerComment);
if($studentChoice)
{
if(!$answerCorrect)

@ -1473,7 +1473,7 @@ function export_exercise($item_id)
}
}
$exerciseTitle = api_parse_tex($exerciseTitle);
$exerciseTitle = text_filter($exerciseTitle);
$test .= "<h3>".$exerciseTitle."</h3>";
@ -1482,7 +1482,7 @@ function export_exercise($item_id)
$test .= "<a href=\"../document/download.php?doc_url=%2Faudio%2F".$exerciseSound."\"&SQMSESSID=36812c2dea7d8d6e708d5e6a2f09b0b9 target=\"_blank\"><img src=\"../img/sound.gif\" border=\"0\" align=\"absmiddle\" alt=".get_lang("Sound")."\" /></a>";
}
$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 .= "<tr><td class=\"text\" colspan='2'>";
$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 .= "<h4>".$row['title']."</h4>";
//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;
}

Loading…
Cancel
Save