Quiz: Use iid instead of id in c_quiz_answer queries - refs BT#18452

pull/3824/head
Angel Fernando Quiroz Campos 5 years ago
parent 8d08d2979b
commit 4d8acb3de2
  1. 2
      main/cron/fix_fill_blank.php
  2. 3
      main/exercise/MultipleAnswerTrueFalseDegreeCertainty.php
  3. 17
      main/exercise/answer.class.php
  4. 3
      main/exercise/calculated_answer.class.php
  5. 10
      main/exercise/exercise.class.php
  6. 2
      main/exercise/hotspot_actionscript.as.php
  7. 4
      main/exercise/hotspot_save.inc.php
  8. 8
      main/exercise/question.class.php
  9. 1
      main/exercise/unique_answer.class.php
  10. 2
      main/inc/lib/exercise.lib.php
  11. 2
      plugin/test2pdf/src/test2pdf.lib.php
  12. 8
      src/Chamilo/CourseBundle/Component/CourseCopy/CourseBuilder.php
  13. 2
      src/Chamilo/CourseBundle/Component/CourseCopy/CourseRecycler.php

@ -27,7 +27,7 @@ var_dump($sql2);
$res2 = Database::query($sql2);
while ($row = Database::fetch_array($res2)) {
$id = $row['id'];
$id = $row['iid'];
$courseId = $row['c_id'];
$idAuto = $row['id_auto'];
$answerOriginal = $row['answer'];

@ -1169,10 +1169,9 @@ class MultipleAnswerTrueFalseDegreeCertainty extends Question
public static function getCorrectAnswerOptionId($idAuto)
{
$tblAnswer = Database::get_course_table(TABLE_QUIZ_ANSWER);
$courseId = api_get_course_int_id();
$idAuto = (int) $idAuto;
$sql = "SELECT correct FROM $tblAnswer
WHERE c_id = $courseId AND id_auto = $idAuto";
WHERE id_auto = $idAuto";
$res = Database::query($sql);
$data = Database::fetch_assoc($res);

@ -125,7 +125,6 @@ class Answer
$sql = "SELECT * FROM $table
WHERE
c_id = {$this->course_id} AND
question_id ='".$questionId."'
ORDER BY position";
@ -134,7 +133,7 @@ class Answer
// while a record is found
while ($object = Database::fetch_object($result)) {
$this->id[$i] = $object->id;
$this->id[$i] = $object->iid;
$this->answer[$i] = $object->answer;
$this->correct[$i] = $object->correct;
$this->comment[$i] = $object->comment;
@ -161,8 +160,8 @@ class Answer
$questionId = $this->questionId;
$sql = "SELECT * FROM $table
WHERE c_id = {$this->course_id}
AND question_id = $questionId
WHERE
question_id = $questionId
ORDER BY position";
$result = Database::query($sql);
@ -211,7 +210,7 @@ class Answer
$sql = "SELECT id FROM
$table
WHERE c_id = {$this->course_id} AND question_id ='".$questionId."'";
WHERE question_id ='".$questionId."'";
$result = Database::query($sql);
$id = [];
@ -394,8 +393,8 @@ class Answer
{
$table = Database::get_course_table(TABLE_QUIZ_ANSWER);
$auto_id = (int) $auto_id;
$sql = "SELECT id, answer, id_auto FROM $table
WHERE c_id = {$this->course_id} AND id_auto='$auto_id'";
$sql = "SELECT iid, answer, id_auto FROM $table
WHERE id_auto='$auto_id'";
$rs = Database::query($sql);
if (Database::num_rows($rs) > 0) {
@ -1029,10 +1028,8 @@ class Answer
$tableAnswer,
$params,
[
'id = ? AND c_id = ? AND question_id = ? ' => [
'iid = ? ' => [
$answer_id,
$courseId,
$newQuestionId,
],
]
);

@ -189,8 +189,7 @@ class CalculatedAnswer extends Question
Database::delete(
$table,
[
'c_id = ? AND question_id = ?' => [
$this->course['real_id'],
'question_id = ?' => [
$this->id,
],
]

@ -3839,9 +3839,9 @@ class Exercise
$user_answer = '';
// Get answer list for matching.
$sql = "SELECT id_auto, id, answer
$sql = "SELECT id_auto, iid, answer
FROM $table_ans
WHERE c_id = $course_id AND question_id = $questionId";
WHERE question_id = $questionId";
$res_answer = Database::query($sql);
$answerMatching = [];
@ -4629,7 +4629,7 @@ class Exercise
case MATCHING_DRAGGABLE:
case MATCHING:
if ($from_database) {
$sql = "SELECT id, answer, id_auto
$sql = "SELECT iid, answer, id_auto
FROM $table_ans
WHERE
c_id = $course_id AND
@ -4648,7 +4648,7 @@ class Exercise
$orderBy = ' ORDER BY correct ';
}
$sql = "SELECT id, answer, correct, id_auto, ponderation
$sql = "SELECT iId, answer, correct, id_auto, ponderation
FROM $table_ans
WHERE
c_id = $course_id AND
@ -4666,7 +4666,7 @@ class Exercise
$questionScore = 0;
$counterAnswer = 1;
foreach ($options as $a_answers) {
$i_answer_id = $a_answers['id']; //3
$i_answer_id = $a_answers['iid']; //3
$s_answer_label = $a_answers['answer']; // your daddy - your mother
$i_answer_correct_answer = $a_answers['correct']; //1 - 2
$i_answer_id_auto = $a_answers['id_auto']; // 3 - 4

@ -84,7 +84,7 @@ $nmbrTries = 0;
while ($hotspot = Database::fetch_assoc($result)) {
$hotSpot = [];
$hotSpot['id'] = $hotspot['id'];
$hotSpot['id'] = $hotspot['iid'];
$hotSpot['iid'] = $hotspot['iid'];
$hotSpot['answer'] = $hotspot['answer'];

@ -41,9 +41,7 @@ $sql = "UPDATE $TBL_ANSWER SET
hotspot_coordinates = '".Database::escape_string($hotspot_coordinates)."',
hotspot_type = '".Database::escape_string($hotspot_type)."'
WHERE
c_id = $course_id AND
id = ".intval($answerId)." AND
question_id = ".intval($questionId)."
iid = ".intval($answerId)."
LIMIT 1 ";
$result = Database::query($sql);
echo "done=done";

@ -715,11 +715,7 @@ abstract class Question
public function updateType($type)
{
$table = Database::get_course_table(TABLE_QUIZ_ANSWER);
$course_id = $this->course['real_id'];
if (empty($course_id)) {
$course_id = api_get_course_int_id();
}
// if we really change the type
if ($type != $this->type) {
// if we don't change from "unique answer" to "multiple answers" (or conversely)
@ -728,7 +724,7 @@ abstract class Question
) {
// removes old answers
$sql = "DELETE FROM $table
WHERE c_id = $course_id AND question_id = ".intval($this->id);
WHERE question_id = ".intval($this->id);
Database::query($sql);
}
@ -1471,7 +1467,7 @@ abstract class Question
Database::query($sql);
$sql = "DELETE FROM $TBL_REPONSES
WHERE c_id = $courseId AND question_id = ".$id;
WHERE question_id = ".$id;
Database::query($sql);
// remove the category of this question in the question_rel_category table

@ -494,7 +494,6 @@ class UniqueAnswer extends Question
$sql = "SELECT max(position) as max_position
FROM $tbl_quiz_answer
WHERE
c_id = $course_id AND
question_id = $question_id";
$rs_max = Database::query($sql);
$row_max = Database::fetch_object($rs_max);

@ -1467,7 +1467,7 @@ HTML;
$answers = $objAnswerTmp->selectAnswerByAutoId(
$objAnswerTmp->selectAutoId($answerId)
);
$answers_hotspot[$answers['id']] = $objAnswerTmp->selectAnswer(
$answers_hotspot[$answers['iid']] = $objAnswerTmp->selectAnswer(
$answerId
);
}

@ -156,7 +156,7 @@ function getAnswers($courseId, $id)
$id = (int) $id;
$tableQuizAnswer = Database::get_course_table(TABLE_QUIZ_ANSWER);
$sql = "SELECT * FROM $tableQuizAnswer
WHERE c_id = $courseId AND question_id = $id
WHERE question_id = $id
ORDER BY position ASC;";
$res = Database::query($sql);
$aux = [];

@ -861,11 +861,11 @@ class CourseBuilder
$question->addPicture($this);
$sql = 'SELECT * FROM '.$table_ans.'
WHERE c_id = '.$courseId.' AND question_id = '.$obj->iid;
WHERE question_id = '.$obj->iid;
$db_result2 = Database::query($sql);
while ($obj2 = Database::fetch_object($db_result2)) {
$question->add_answer(
$obj2->id,
$obj2->iid,
$obj2->answer,
$obj2->correct,
$obj2->comment,
@ -951,7 +951,7 @@ class CourseBuilder
);
$question->addPicture($this);
$sql = "SELECT * FROM $table_ans
WHERE c_id = $courseId AND question_id = ".$obj->id;
WHERE question_id = ".$obj->id;
$db_result2 = Database::query($sql);
if (Database::num_rows($db_result2)) {
while ($obj2 = Database::fetch_object($db_result2)) {
@ -1046,7 +1046,7 @@ class CourseBuilder
$db_result2 = Database::query($sql);
while ($obj2 = Database::fetch_object($db_result2)) {
$question->add_answer(
$obj2->id,
$obj2->iid,
$obj2->answer,
$obj2->correct,
$obj2->comment,

@ -473,7 +473,7 @@ class CourseRecycler
WHERE c_id = ".$this->course_id." AND question_id IN(".$orphan_ids.")";
Database::query($sql);
$sql = "DELETE FROM ".$table_qui_ans."
WHERE c_id = ".$this->course_id." AND question_id IN(".$orphan_ids.")";
WHERE question_id IN(".$orphan_ids.")";
Database::query($sql);
$sql = "DELETE FROM ".$table_qui_que."
WHERE iid IN(".$orphan_ids.")";

Loading…
Cancel
Save