diff --git a/main/exercice/admin.php b/main/exercice/admin.php index 0d29b0c1f8..599062e498 100644 --- a/main/exercice/admin.php +++ b/main/exercice/admin.php @@ -574,6 +574,11 @@ if (isset($_GET['hotspotadmin'])) { } if (!$newQuestion && !$modifyQuestion && !$editQuestion && !isset($_GET['hotspotadmin'])) { + + if ($objExercise->randomByCat == EXERCISE_CATEGORY_RANDOM_SHUFFLED || EXERCISE_CATEGORY_RANDOM_ORDERED) { + Display::display_normal_message(get_lang('AllQuestionsMustHaveACategory')); + } + // Question list (drag n drop view) if ($fastEdition) { require 'question_list_pagination_admin.inc.php'; diff --git a/main/exercice/exercise.class.php b/main/exercice/exercise.class.php index 3ebe045cd7..dfb823f8b2 100644 --- a/main/exercice/exercise.class.php +++ b/main/exercice/exercise.class.php @@ -4658,7 +4658,7 @@ class Exercise //Getting questions by category $questions_in_category = Testcategory::getQuestionsByCat($this->id); - $isRandomByCategory = $this->selectRandomByCat(); + //$isRandomByCategory = $this->selectRandomByCat(); // on tri les catégories en fonction du terme entre [] en tête de la description de la catégorie /* @@ -4674,9 +4674,9 @@ class Exercise // If test option is Grouped By Categories - if ($isRandomByCategory == 2) { + /*if ($isRandomByCategory == 2) { $questions_in_category = Testcategory::sortTabByBracketLabel($questions_in_category); - } + }*/ $number_of_random_question = $this->random; if ($this->random == -1) { @@ -4722,21 +4722,21 @@ class Exercise */ function get_validated_question_list() { - //Getting current question list + // Getting current question list $question_list = $this->selectQuestionList(); - //Getting random by category setting + // Getting random by category setting $random_by_category = $this->isRandomByCat(); switch ($random_by_category) { case EXERCISE_CATEGORY_RANDOM_SHUFFLED: - //Randomized array + // Randomized array if ($this->isRandom()) { $question_list = $this->selectRandomList($question_list); } break; case EXERCISE_CATEGORY_RANDOM_DISABLED: - //Randomized array + // Randomized array if ($this->isRandom()) { $question_list = $this->selectRandomList($question_list); } @@ -4746,16 +4746,16 @@ class Exercise //break; } + /** - * Get questions by category for this exercice + * Get questions by category for this exercise * we have to choice $objExercise->random question in each array values of $questions_by_category - * key of $tabCategoryQuestions are the categopy id (0 for not in a category) + * key of $tabCategoryQuestions are the category id (0 for not in a category) * value is the array of question id of this category */ //Getting questions by category - //$questions_by_category = Testcategory::getQuestionsByCat($this->id, $question_list); - + $questions_by_category = Testcategory::getQuestionsByCat($this->id, $question_list); /** * The order is based in the category in this case [biology] is first that [maths] @@ -4773,13 +4773,13 @@ class Exercise //$questions_by_category = Testcategory::sortCategoriesQuestionByName($questions_by_category); //} -/* $number_of_random_question = $this->random; - if ($this->random == -1) { + if ($this->random == -1 || empty($this->random)) { $number_of_random_question = count($question_list); } //Only 1 question per category + /* if (!empty($questions_by_category)) { $one_question_per_category = array(); $questions_added = array(); @@ -4792,7 +4792,7 @@ class Exercise } } $questions_by_category = $one_question_per_category; - } + }*/ $temp_question_list = array(); while (list($category_id, $question_list) = each($questions_by_category)) { @@ -4802,9 +4802,9 @@ class Exercise // shuffle the question list if test is not grouped by categories //if ($random_by_category == EXERCISE_CATEGORY_RANDOM_SHUFFLED) { - shuffle($temp_question_list); + //shuffle($temp_question_list); //} - $question_list = $temp_question_list;*/ + $question_list = $temp_question_list; break; } return $question_list; @@ -4819,7 +4819,6 @@ class Exercise { $question_list = $this->get_validated_question_list(); $question_list = $this->transform_question_list_with_medias($question_list, $expand_media_questions); - return $question_list; } @@ -4829,7 +4828,7 @@ class Exercise * @params bool expand or not question list (true show all questions, false show media question id instead of the question ids) * **/ - function transform_question_list_with_medias($question_list, $expand_media_questions = false) + public function transform_question_list_with_medias($question_list, $expand_media_questions = false) { $new_question_list = array(); if (!empty($question_list)) { diff --git a/main/exercice/exercise_reminder.php b/main/exercice/exercise_reminder.php index 71076b1daf..0b45fb4fb7 100644 --- a/main/exercice/exercise_reminder.php +++ b/main/exercice/exercise_reminder.php @@ -154,7 +154,6 @@ $exercise_result = get_answered_questions_from_attempt($exe_id, $objExercise); $remind_list = $exercise_stat_info['questions_to_check']; $remind_list = explode(',', $remind_list); - echo Display::label(get_lang('QuestionWithNoAnswer'), 'warning'); echo '