You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
79 lines
2.4 KiB
79 lines
2.4 KiB
<?php
|
|
/* For licensing terms, see /license.txt */
|
|
|
|
require_once '../inc/global.inc.php';
|
|
|
|
api_protect_admin_script();
|
|
|
|
$table = Database::get_course_table(TABLE_QUIZ_ANSWER);
|
|
|
|
$execute = isset($_GET['execute']) ? $_GET['execute'] : null;
|
|
$courseId = isset($_GET['c_id']) ? $_GET['c_id'] : null;
|
|
$questionId = isset($_GET['question_id']) ? $_GET['question_id'] : null;
|
|
|
|
$sql2 = "SELECT * FROM $table WHERE answer LIKE '%[%]%'";
|
|
|
|
if (!empty($courseId)) {
|
|
$courseId = intval($courseId);
|
|
$sql2 .= " AND c_id = $courseId";
|
|
if (!empty($questionId)) {
|
|
$questionId = intval($questionId);
|
|
$sql2 .= " AND question_id = $questionId";
|
|
}
|
|
}
|
|
|
|
var_dump($sql2);
|
|
|
|
$res2 = Database::query($sql2);
|
|
|
|
while ($row = Database::fetch_array($res2)) {
|
|
$id = $row['id'];
|
|
$courseId = $row['c_id'];
|
|
$idAuto = $row['id_auto'];
|
|
$answerOriginal = $row['answer'];
|
|
|
|
$answer = $row['answer'];
|
|
|
|
$answer = str_replace('â', 'â', $answer);
|
|
$answer = str_replace('à', 'à', $answer);
|
|
$answer = str_replace('é', 'é', $answer);
|
|
$answer = str_replace('ê', 'ê', $answer);
|
|
$answer = str_replace('è', 'è', $answer);
|
|
$answer = str_replace('í', 'í', $answer);
|
|
$answer = str_replace('ì', 'ì', $answer);
|
|
$answer = str_replace('ó', 'ó', $answer);
|
|
$answer = str_replace('ò', 'ò', $answer);
|
|
$answer = str_replace('ù', 'ù', $answer);
|
|
$answer = str_replace('ú', 'ú', $answer);
|
|
$answer = str_replace('ç', 'ç', $answer);
|
|
$answer = str_replace('À', 'À', $answer);
|
|
$answer = str_replace('Ç', 'Ç', $answer);
|
|
|
|
$answerFixedNotEscape = $answer;
|
|
|
|
$answer = Database::escape_string($answer);
|
|
|
|
$sql4 = "UPDATE c_quiz_answer SET
|
|
answer = '$answer'
|
|
WHERE id = $id AND c_id = $courseId AND id_auto = $idAuto ";
|
|
|
|
if ($answerOriginal != $answerFixedNotEscape) {
|
|
if (!empty($execute) && $execute == 1) {
|
|
Database::query($sql4);
|
|
echo '<pre>';
|
|
var_dump($sql4);
|
|
echo '</pre>';
|
|
var_dump('executed');
|
|
} else {
|
|
echo "to be executed";
|
|
echo '<pre>';
|
|
var_dump($sql4);
|
|
echo 'Original:<br />';
|
|
echo($answerOriginal);
|
|
echo 'Fixed:<br />';
|
|
echo($answerFixedNotEscape);
|
|
echo '</pre>';
|
|
echo '----------<br />';
|
|
}
|
|
}
|
|
}
|
|
|