/** * creates and returns an instance of a test sequence * that corresponds to the current test mode * * @param integer $activeId * @return ilTestSession|ilTestSessionDynamicQuestionSet */ public function getSession($activeId = null) { global $ilUser; if (self::$testSession === null) { switch ($this->testOBJ->getQuestionSetType()) { case ilObjTest::QUESTION_SET_TYPE_FIXED: case ilObjTest::QUESTION_SET_TYPE_RANDOM: global $ilUser; require_once 'Modules/Test/classes/class.ilTestSession.php'; self::$testSession = new ilTestSession(); break; case ilObjTest::QUESTION_SET_TYPE_DYNAMIC: require_once 'Modules/Test/classes/class.ilTestSessionDynamicQuestionSet.php'; self::$testSession = new ilTestSessionDynamicQuestionSet(); break; } self::$testSession->setRefId($this->testOBJ->getRefId()); self::$testSession->setTestId($this->testOBJ->getTestId()); if ($activeId) { self::$testSession->loadFromDb($activeId); } else { self::$testSession->loadTestSession($this->testOBJ->getTestId(), $ilUser->getId(), $_SESSION["tst_access_code"][$this->testOBJ->getTestId()]); } } return self::$testSession; }
/** * Sets the test session data for the active user * * @param integer $active_id The active id of the active user * @return object The ilTestSession object or FALSE if the creation of the object fails * @access public */ function &setTestSession($active_id = "") { if (is_object($this->testSession) && $this->testSession->getActiveId() > 0) { return $this->testSession; } global $ilUser; include_once "./Modules/Test/classes/class.ilTestSession.php"; $testSession = FALSE; if ($active_id > 0) { $testSession = new ilTestSession($active_id); $testSession->setRefId($this->getRefId()); } else { $testSession = new ilTestSession(); $testSession->setRefId($this->getRefId()); $testSession->loadTestSession($this->getTestId(), $ilUser->getId(), $_SESSION["tst_access_code"][$this->getTestId()]); } $this->testSession =& $testSession; return $this->testSession; }