12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879 |
- <?php
- /* For licensing terms, see /license.txt */
- require_once __DIR__.'/../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 />';
- }
- }
- }
|