diff --git a/main/exercise/exercise.class.php b/main/exercise/exercise.class.php index 94956002a1..b4458d1701 100755 --- a/main/exercise/exercise.class.php +++ b/main/exercise/exercise.class.php @@ -1082,11 +1082,12 @@ class Exercise /** * returns the array with the question ID list - * + * @param bool $from_db Whether the results should be fetched in the database or just from memory + * @param bool $adminView Whether we should return all questions (admin view) or just a list limited by the max number of random questions * @author Olivier Brouckaert * @return array - question ID list */ - public function selectQuestionList($from_db = false) + public function selectQuestionList($from_db = false, $adminView = false) { if ($from_db && !empty($this->id)) { $nbQuestions = $this->getQuestionCount(); @@ -1101,7 +1102,7 @@ class Exercise if ($this->random == 0 || $nbQuestions < 2) { $questionList = $this->getQuestionOrderedList(); } else { - $questionList = $this->selectRandomList(); + $questionList = $this->selectRandomList($adminView); } break; default: @@ -1153,10 +1154,11 @@ class Exercise * * @author Olivier Brouckaert * @author Hubert Borderiou 15 nov 2011 + * @param bool $adminView Whether we should return all questions (admin view) or just a list limited by the max number of random questions * @return array - if the exercise is not set to take questions randomly, returns the question list * without randomizing, otherwise, returns the list with questions selected randomly */ - public function selectRandomList() + public function selectRandomList($adminView = false) { /*$nbQuestions = $this->selectNbrQuestions(); $temp_list = $this->questionList; @@ -1193,8 +1195,8 @@ class Exercise $randomLimit = "LIMIT $random"; // Random all questions so no limit - if ($random == -1) { - $randomLimit = null; + if ($random == -1 or $adminView === true) { + $randomLimit = ''; } $sql = "SELECT e.question_id diff --git a/main/exercise/question_list_admin.inc.php b/main/exercise/question_list_admin.inc.php index 77faffca76..3f056680b9 100755 --- a/main/exercise/question_list_admin.inc.php +++ b/main/exercise/question_list_admin.inc.php @@ -194,7 +194,7 @@ if (!$inATest) { // Show all questions no matter the category settings. $tempCategoryOrder = isset($objExercise->specialCategoryOrders) ? $objExercise->specialCategoryOrders : false; $objExercise->specialCategoryOrders = false; - $questionList = $objExercise->selectQuestionList(true); + $questionList = $objExercise->selectQuestionList(true, true); $objExercise->specialCategoryOrders = $tempCategoryOrder; // Style for columns