Skip to content

Commit

Permalink
Improve queries see BT#12052
Browse files Browse the repository at this point in the history
  • Loading branch information
jmontoyaa committed Dec 7, 2016
1 parent 9cf4852 commit 8cfbb5d
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions main/exercise/exercise.class.php
Expand Up @@ -690,9 +690,12 @@ public function getQuestionOrderedListByName()

// Getting question list from the order (question list drag n drop interface ).
$sql = "SELECT e.question_id
FROM $TBL_EXERCICE_QUESTION e INNER JOIN $TBL_QUESTIONS q
ON (e.question_id= q.id)
WHERE e.c_id = {$this->course_id} AND e.exercice_id = '".Database::escape_string($this->id)."'
FROM $TBL_EXERCICE_QUESTION e
INNER JOIN $TBL_QUESTIONS q
ON (e.question_id= q.id AND e.c_id = q.c_id)
WHERE
e.c_id = {$this->course_id} AND
e.exercice_id = '".Database::escape_string($this->id)."'
ORDER BY q.question";
$result = Database::query($sql);
$list = array();
Expand Down Expand Up @@ -1194,10 +1197,10 @@ public function selectRandomList()
$randomLimit = null;
}

// @todo improve this query
$sql = "SELECT e.question_id
FROM $TBL_EXERCISE_QUESTION e INNER JOIN $TBL_QUESTIONS q
ON (e.question_id= q.iid)
FROM $TBL_EXERCISE_QUESTION e
INNER JOIN $TBL_QUESTIONS q
ON (e.question_id= q.iid AND e.c_id = q.c_id)
WHERE e.c_id = {$this->course_id} AND e.exercice_id = '".Database::escape_string($this->id)."'
ORDER BY RAND()
$randomLimit ";
Expand Down

0 comments on commit 8cfbb5d

Please sign in to comment.