/** * Constructor * * @param array $unOrderedTypes * @param string $orderMode * @throws ilTestQuestionPoolException */ public function __construct($unOrderedTypes, $orderMode = self::ORDER_MODE_ALPHA) { self::$flippedQuestionTypeOrder = array_flip(self::$fixQuestionTypeOrder); $this->types = $unOrderedTypes; switch ($orderMode) { case self::ORDER_MODE_FIX: uasort($this->types, array($this, 'fixQuestionTypeOrderSortCallback')); break; case self::ORDER_MODE_ALPHA: ksort($this->types); break; default: throw new ilTestQuestionPoolException('invalid order mode given: ' . $orderMode); } }
function &_getQuestionTypes($all_tags = FALSE, $fixOrder = false) { global $ilDB; global $lng; include_once "./Modules/Test/classes/class.ilObjAssessmentFolder.php"; $forbidden_types = ilObjAssessmentFolder::_getForbiddenQuestionTypes(); $lng->loadLanguageModule("assessment"); $result = $ilDB->query("SELECT * FROM qpl_qst_type"); $types = array(); while ($row = $ilDB->fetchAssoc($result)) { if ($all_tags || !in_array($row["question_type_id"], $forbidden_types)) { global $ilLog; if ($row["plugin"] == 0) { $types[$lng->txt($row["type_tag"])] = $row; } else { global $ilPluginAdmin; $pl_names = $ilPluginAdmin->getActivePluginsForSlot(IL_COMP_MODULE, "TestQuestionPool", "qst"); foreach ($pl_names as $pl_name) { $pl = ilPlugin::getPluginObject(IL_COMP_MODULE, "TestQuestionPool", "qst", $pl_name); if (strcmp($pl->getQuestionType(), $row["type_tag"]) == 0) { $types[$pl->getQuestionTypeTranslation()] = $row; } } } } } require_once 'Modules/TestQuestionPool/classes/class.ilAssQuestionTypeOrderer.php'; $orderMode = $fixOrder ? ilAssQuestionTypeOrderer::ORDER_MODE_FIX : ilAssQuestionTypeOrderer::ORDER_MODE_ALPHA; $orderer = new ilAssQuestionTypeOrderer($types, $orderMode); $types = $orderer->getOrderedTypes(); return $types; }