Quiz: Show complete question list on admin view - refs BT#15996

pull/2981/head
Angel Fernando Quiroz Campos 6 years ago
parent d98760dd88
commit f5feaecc2e
  1. 19
      main/exercise/exercise.class.php

@ -1048,18 +1048,18 @@ class Exercise
switch ($questionSelectionType) { switch ($questionSelectionType) {
case EX_Q_SELECTION_ORDERED: case EX_Q_SELECTION_ORDERED:
$questionList = $this->getQuestionOrderedList(); $questionList = $this->getQuestionOrderedList($adminView);
break; break;
case EX_Q_SELECTION_RANDOM: case EX_Q_SELECTION_RANDOM:
// Not a random exercise, or if there are not at least 2 questions // Not a random exercise, or if there are not at least 2 questions
if ($this->random == 0 || $nbQuestions < 2) { if ($this->random == 0 || $nbQuestions < 2) {
$questionList = $this->getQuestionOrderedList(); $questionList = $this->getQuestionOrderedList($adminView);
} else { } else {
$questionList = $this->getRandomList($adminView); $questionList = $this->getRandomList($adminView);
} }
break; break;
default: default:
$questionList = $this->getQuestionOrderedList(); $questionList = $this->getQuestionOrderedList($adminView);
$result = $this->getQuestionListWithCategoryListFilteredByCategorySettings( $result = $this->getQuestionListWithCategoryListFilteredByCategorySettings(
$questionList, $questionList,
$questionSelectionType $questionSelectionType
@ -9652,9 +9652,11 @@ class Exercise
/** /**
* Gets the question list ordered by the question_order setting (drag and drop). * Gets the question list ordered by the question_order setting (drag and drop).
* *
* @param bool $adminView Optional.
*
* @return array * @return array
*/ */
private function getQuestionOrderedList() private function getQuestionOrderedList($adminView = false)
{ {
$TBL_EXERCICE_QUESTION = Database::get_course_table(TABLE_QUIZ_TEST_QUESTION); $TBL_EXERCICE_QUESTION = Database::get_course_table(TABLE_QUIZ_TEST_QUESTION);
$TBL_QUESTIONS = Database::get_course_table(TABLE_QUIZ_QUESTION); $TBL_QUESTIONS = Database::get_course_table(TABLE_QUIZ_QUESTION);
@ -9690,8 +9692,13 @@ class Exercise
$counter = 1; $counter = 1;
$questionList = []; $questionList = [];
while ($new_object = Database::fetch_object($result)) { while ($new_object = Database::fetch_object($result)) {
// Correct order. if (!$adminView) {
$questionList[$new_object->question_order] = $new_object->question_id; // Correct order.
$questionList[$new_object->question_order] = $new_object->question_id;
} else {
$questionList[$counter] = $new_object->question_id;
}
// Just in case we save the order in other array // Just in case we save the order in other array
$temp_question_list[$counter] = $new_object->question_id; $temp_question_list[$counter] = $new_object->question_id;
$counter++; $counter++;

Loading…
Cancel
Save