/** * */ protected function redirectLocToTestObject($a_force_new_run = NULL) { $objective_id = (int) $_REQUEST['objective_id']; $test_id = (int) $_REQUEST['tid']; include_once './Modules/Course/classes/Objectives/class.ilLOUserResults.php'; include_once './Modules/Course/classes/Objectives/class.ilLOSettings.php'; $res = new ilLOUserResults($this->object->getId(), $GLOBALS['ilUser']->getId()); $passed = $res->getCompletedObjectiveIdsByType(ilLOSettings::getInstanceByObjId($this->object->getId())->getQualifiedTest() == $test_id ? ilLOUserResults::TYPE_QUALIFIED : ilLOUserResults::TYPE_INITIAL); if ($objective_id) { $objective_ids = array($objective_id); if (in_array($objective_id, $passed)) { $passed = array(); } } else { include_once './Modules/Course/classes/class.ilCourseObjective.php'; $objective_ids = ilCourseObjective::_getObjectiveIds($this->object->getId(), true); // do not disable objective question if all are passed if (count($objective_ids) == count($passed)) { $passed = array(); } } if (is_null($a_force_new_run)) { $resume_type = $this->handleActivePass($test_id, $objective_id); switch ($resume_type) { case 1: return TRUE; case 2: $a_force_new_run = TRUE; break; case 3: $a_force_new_run = FALSE; break; } } else { include_once './Modules/Test/classes/class.ilObjTest.php'; ilObjTest::ensureParticipantsLastActivePassFinished($test_id, $GLOBALS['ilUser']->getId(), $a_force_new_run); } if ($a_force_new_run === TRUE) { include_once './Modules/Course/classes/Objectives/class.ilLOTestRun.php'; ilLOTestRun::deleteRun($this->object->getId(), $GLOBALS['ilUser']->getId(), ilObject::_lookupObjId($test_id)); foreach ((array) $objective_ids as $oid) { if (!in_array($oid, $passed)) { $run = new ilLOTestRun($this->object->getId(), $GLOBALS['ilUser']->getId(), ilObject::_lookupObjId($test_id), $oid); $run->create(); } } } // Redirect to test player include_once './Services/Object/classes/class.ilObjectFactory.php'; $test_obj = ilObjectFactory::getInstanceByObjId(ilObject::_lookupObjId($test_id)); include_once 'Modules/Test/classes/class.ilTestPlayerFactory.php'; $testPlayerFactory = new ilTestPlayerFactory($test_obj); $playerGuiClass = get_class($testPlayerFactory->getPlayerGUI()); $sessionLock = md5($_COOKIE[session_name()] . time()); // do NOT set this into $_SESSION // resume or start new run if (ilObjTest::isParticipantsLastPassActive($test_id, $GLOBALS['ilUser']->getId())) { $test_cmd = 'resumePlayer'; } else { $test_cmd = 'startPlayer'; } $GLOBALS['ilCtrl']->setParameterByClass($playerGuiClass, 'ref_id', $test_id); $GLOBALS['ilCtrl']->setParameterByClass($playerGuiClass, 'crs_show_result', $this->object->getRefId()); $GLOBALS['ilCtrl']->setParameterByClass($playerGuiClass, 'lock', $sessionLock); $GLOBALS['ilCtrl']->redirectByClass(array('ilObjTestGUI', $playerGuiClass), $test_cmd); }
/** * Called from learning objective test on actual test start * @param ilTestSession $a_test_session * @param integer $a_test_obj_id */ public function notifyTestStart(ilTestSession $a_test_session, $a_test_obj_id) { $relevant_objectives = $this->lookupRelevantObjectiveIdsForTest($a_test_session->getObjectiveOrientedContainerId(), $a_test_session->getRefId(), $a_test_session->getUserId()); $GLOBALS['ilLog']->write(__METHOD__ . ': Notify test start ' . print_r($relevant_objectives, TRUE)); // delete test runs include_once './Modules/Course/classes/Objectives/class.ilLOTestRun.php'; ilLOTestRun::deleteRun($a_test_session->getObjectiveOrientedContainerId(), $a_test_session->getUserId(), $a_test_obj_id); foreach ((array) $relevant_objectives as $oid) { $GLOBALS['ilLog']->write(__METHOD__ . ': Adding new run for objective with id ' . $oid); $run = new ilLOTestRun($a_test_session->getObjectiveOrientedContainerId(), $a_test_session->getUserId(), $a_test_obj_id, $oid); $run->create(); } // finally reinitialize test runs $this->initTestRun($a_test_session); }