Fix pagination see BT#15535

pull/3173/head
Julio Montoya 7 years ago
parent 7dc665e2b7
commit 0f695892f1
  1. 22
      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); $quizRelQuestion = Database::get_course_table(TABLE_QUIZ_TEST_QUESTION);
$TBL_QUESTIONS = Database::get_course_table(TABLE_QUIZ_QUESTION); $question = Database::get_course_table(TABLE_QUIZ_QUESTION);
$sql = "SELECT DISTINCT e.question_id, e.question_order $sql = "SELECT DISTINCT e.question_id
FROM $TBL_EXERCICE_QUESTION e FROM $quizRelQuestion e
INNER JOIN $TBL_QUESTIONS q INNER JOIN $question q
ON (e.question_id = q.id AND e.c_id = q.c_id) 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;

Loading…
Cancel
Save