Ver código fonte

Fix issue with questions list not showing all questions when a random number is selected

Yannick Warnier 8 anos atrás
pai
commit
7fca8d2d3d

+ 8 - 6
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

+ 1 - 1
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