Esempio n. 1
0
 function get_validated_question_list()
 {
     $tabres = array();
     $isRandomByCategory = $this->isRandomByCat();
     if ($isRandomByCategory == 0) {
         if ($this->isRandom()) {
             $tabres = $this->selectRandomList();
         } else {
             $tabres = $this->selectQuestionList();
         }
     } else {
         if ($this->isRandom()) {
             // USE question categories
             // get questions by category for this exercice
             // we have to choice $objExercise->random question in each array values of $tabCategoryQuestions
             // key of $tabCategoryQuestions are the categopy id (0 for not in a category)
             // value is the array of question id of this category
             $questionList = array();
             $tabCategoryQuestions = Testcategory::getQuestionsByCat($this->id);
             $isRandomByCategory = $this->selectRandomByCat();
             // on tri les categories en fonction du terme entre [] en tete de la description de la categorie
             /*
              * ex de catégories :
              * [biologie] Maitriser les mecanismes de base de la genetique
              * [biologie] Relier les moyens de depenses et les agents infectieux
              * [biologie] Savoir ou est produite l'enrgie dans les cellules et sous quelle forme
              * [chimie] Classer les molles suivant leur pouvoir oxydant ou reacteur
              * [chimie] Connaître la denition de la theoie acide/base selon Brönsted
              * [chimie] Connaître les charges des particules
              * On veut dans l'ordre des groupes definis par le terme entre crochet au debut du titre de la categorie
              */
             // If test option is Grouped By Categories
             if ($isRandomByCategory == 2) {
                 $tabCategoryQuestions = Testcategory::sortTabByBracketLabel($tabCategoryQuestions);
             }
             while (list($cat_id, $tabquestion) = each($tabCategoryQuestions)) {
                 $number_of_random_question = $this->random;
                 if ($this->random == -1) {
                     $number_of_random_question = count($this->questionList);
                 }
                 $questionList = array_merge($questionList, Testcategory::getNElementsFromArray($tabquestion, $number_of_random_question));
             }
             // shuffle the question list if test is not grouped by categories
             if ($isRandomByCategory == 1) {
                 shuffle($questionList);
                 // or not
             }
             $tabres = $questionList;
         } else {
             // Problem, random by category has been selected and we have no $this->isRandom nnumber of question selected
             // Should not happened
         }
     }
     return $tabres;
 }