/** * Creates a question GUI instance of a given question type * * @param integer $question_type The question type of the question * @param integer $question_id The question id of the question, if available * @return assQuestionGUI $questionGUI The question GUI instance * @access public */ function &createQuestionGUI($question_type, $question_id = -1) { if (!$question_type and $question_id > 0) { $question_type = $this->getQuestionType($question_id); } if (!strlen($question_type)) { return null; } include_once "./Modules/TestQuestionPool/classes/class.assQuestion.php"; assQuestion::_includeClass($question_type, 1); $question_type_gui = assQuestion::getGuiClassNameByQuestionType($question_type); $question = new $question_type_gui(); if ($question_id > 0) { $question->object->loadFromDb($question_id); global $ilCtrl, $ilDB, $ilUser, $lng; $feedbackObjectClassname = assQuestion::getFeedbackClassNameByQuestionType($question_type); $question->object->feedbackOBJ = new $feedbackObjectClassname($question->object, $ilCtrl, $ilDB, $lng); $assSettings = new ilSetting('assessment'); require_once 'Modules/TestQuestionPool/classes/class.ilAssQuestionProcessLockerFactory.php'; $processLockerFactory = new ilAssQuestionProcessLockerFactory($assSettings, $ilDB); $processLockerFactory->setQuestionId($question->object->getId()); $processLockerFactory->setUserId($ilUser->getId()); include_once "./Modules/Test/classes/class.ilObjAssessmentFolder.php"; $processLockerFactory->setAssessmentLogEnabled(ilObjAssessmentFolder::_enabledAssessmentLogging()); $question->object->setProcessLocker($processLockerFactory->getLocker()); } return $question; }
/** * Creates a question gui representation and returns the alias to the question gui * note: please do not use $this inside this method to allow static calls * * @param string $question_type The question type as it is used in the language database * @param integer $question_id The database ID of an existing question to load it into assQuestionGUI * * @return assQuestionGUI The alias to the question object */ public function &_getQuestionGUI($question_type, $question_id = -1) { global $ilCtrl, $ilDB, $lng; include_once "./Modules/TestQuestionPool/classes/class.assQuestion.php"; if (!$question_type and $question_id > 0) { $question_type = assQuestion::getQuestionTypeFromDb($question_id); } if (strlen($question_type) == 0) { return NULL; } assQuestion::_includeClass($question_type, 1); $question_type_gui = assQuestion::getGuiClassNameByQuestionType($question_type); $question =& new $question_type_gui(); $feedbackObjectClassname = assQuestion::getFeedbackClassNameByQuestionType($question_type); $question->object->feedbackOBJ = new $feedbackObjectClassname($question->object, $ilCtrl, $ilDB, $lng); if ($question_id > 0) { $question->object->loadFromDb($question_id); } return $question; }