From efc126a21f2a032f28456b18b92d0edaf8bd4562 Mon Sep 17 00:00:00 2001 From: Angel Fernando Quiroz Campos Date: Tue, 16 Mar 2021 18:44:15 -0500 Subject: [PATCH] Quiz: Use iid instead of id in c_quiz_question_option queries - refs BT#18452 --- main/exercise/MultipleAnswerTrueFalseDegreeCertainty.php | 2 +- main/exercise/question.class.php | 8 +++----- .../CourseBundle/Component/CourseCopy/CourseBuilder.php | 2 +- .../Component/CourseCopy/Resources/QuizQuestionOption.php | 2 +- 4 files changed, 6 insertions(+), 8 deletions(-) diff --git a/main/exercise/MultipleAnswerTrueFalseDegreeCertainty.php b/main/exercise/MultipleAnswerTrueFalseDegreeCertainty.php index ace3fe9930..bdff39aa70 100644 --- a/main/exercise/MultipleAnswerTrueFalseDegreeCertainty.php +++ b/main/exercise/MultipleAnswerTrueFalseDegreeCertainty.php @@ -1147,7 +1147,7 @@ class MultipleAnswerTrueFalseDegreeCertainty extends Question $optionId = (int) $optionId; $sql = "SELECT position FROM $tblAnswerOption - WHERE c_id = $courseId AND id = $optionId"; + WHERE iid = $optionId"; $res = Database::query($sql); if (Database::num_rows($res) == 0) { diff --git a/main/exercise/question.class.php b/main/exercise/question.class.php index 2a35b7b0b0..0669703cd8 100755 --- a/main/exercise/question.class.php +++ b/main/exercise/question.class.php @@ -2123,8 +2123,7 @@ abstract class Question Database::delete( $table, [ - 'c_id = ? AND question_id = ?' => [ - $course_id, + 'question_id = ?' => [ $question_id, ], ] @@ -2145,7 +2144,7 @@ abstract class Question return Database::update( $table, $params, - ['c_id = ? AND id = ?' => [$course_id, $id]] + ['iid = ?' => [$id]] ); } @@ -2164,8 +2163,7 @@ abstract class Question $table, [ 'where' => [ - 'c_id = ? AND question_id = ?' => [ - $course_id, + 'question_id = ?' => [ $question_id, ], ], diff --git a/src/Chamilo/CourseBundle/Component/CourseCopy/CourseBuilder.php b/src/Chamilo/CourseBundle/Component/CourseCopy/CourseBuilder.php index 055d41e9f9..9c9be40fcc 100644 --- a/src/Chamilo/CourseBundle/Component/CourseCopy/CourseBuilder.php +++ b/src/Chamilo/CourseBundle/Component/CourseCopy/CourseBuilder.php @@ -881,7 +881,7 @@ class CourseBuilder if ($obj->type == MULTIPLE_ANSWER_TRUE_FALSE) { $table_options = Database::get_course_table(TABLE_QUIZ_QUESTION_OPTION); $sql = 'SELECT * FROM '.$table_options.' - WHERE c_id = '.$courseId.' AND question_id = '.$obj->iid; + WHERE question_id = '.$obj->iid; $db_result3 = Database::query($sql); while ($obj3 = Database::fetch_object($db_result3)) { $question_option = new QuizQuestionOption($obj3); diff --git a/src/Chamilo/CourseBundle/Component/CourseCopy/Resources/QuizQuestionOption.php b/src/Chamilo/CourseBundle/Component/CourseCopy/Resources/QuizQuestionOption.php index d2557389fc..dacb32a65d 100644 --- a/src/Chamilo/CourseBundle/Component/CourseCopy/Resources/QuizQuestionOption.php +++ b/src/Chamilo/CourseBundle/Component/CourseCopy/Resources/QuizQuestionOption.php @@ -21,7 +21,7 @@ class QuizQuestionOption extends Resource */ public function __construct($obj) { - parent::__construct($obj->id, RESOURCE_QUIZQUESTION); + parent::__construct($obj->iid, RESOURCE_QUIZQUESTION); $this->obj = $obj; } }