Browse Source

Fix pagination see BT#15535

Julio Montoya 6 years ago
parent
commit
0f695892f1
1 changed files with 11 additions and 11 deletions
  1. 11 11
      main/exercise/exercise.class.php

+ 11 - 11
main/exercise/exercise.class.php

@@ -7915,35 +7915,35 @@ class Exercise
 
 
     /**
     /**
      * @param int $start
      * @param int $start
-     * @param int $lenght
+     * @param int $length
      *
      *
      * @return array
      * @return array
      */
      */
-    public function getQuestionForTeacher($start = 0, $lenght = 10)
+    public function getQuestionForTeacher($start = 0, $length = 10)
     {
     {
         $start = (int) $start;
         $start = (int) $start;
         if ($start < 0) {
         if ($start < 0) {
             $start = 0;
             $start = 0;
         }
         }
 
 
-        $lenght = (int) $lenght;
+        $length = (int) $length;
 
 
-        $TBL_EXERCICE_QUESTION = Database::get_course_table(TABLE_QUIZ_TEST_QUESTION);
-        $TBL_QUESTIONS = Database::get_course_table(TABLE_QUIZ_QUESTION);
-        $sql = "SELECT DISTINCT e.question_id, e.question_order
-                FROM $TBL_EXERCICE_QUESTION e
-                INNER JOIN $TBL_QUESTIONS q
-                ON (e.question_id = q.id AND e.c_id = q.c_id)
+        $quizRelQuestion = Database::get_course_table(TABLE_QUIZ_TEST_QUESTION);
+        $question = Database::get_course_table(TABLE_QUIZ_QUESTION);
+        $sql = "SELECT DISTINCT e.question_id
+                FROM $quizRelQuestion e
+                INNER JOIN $question q
+                ON (e.question_id = q.iid AND e.c_id = q.c_id)
                 WHERE
                 WHERE
                     e.c_id = {$this->course_id} AND
                     e.c_id = {$this->course_id} AND
                     e.exercice_id = '".$this->id."'
                     e.exercice_id = '".$this->id."'
                 ORDER BY question_order
                 ORDER BY question_order
-                LIMIT $start, $lenght
+                LIMIT $start, $length
             ";
             ";
         $result = Database::query($sql);
         $result = Database::query($sql);
         $questionList = [];
         $questionList = [];
         while ($object = Database::fetch_object($result)) {
         while ($object = Database::fetch_object($result)) {
-            $questionList[$object->question_order] = $object->question_id;
+            $questionList[] = $object->question_id;
         }
         }
 
 
         return $questionList;
         return $questionList;