/** * Lookup all relevant objective ids for a specific test * @return array */ protected function lookupRelevantObjectiveIdsForTest($a_container_id, $a_tst_ref_id, $a_user_id) { include_once './Modules/Course/classes/Objectives/class.ilLOTestAssignments.php'; $assignments = ilLOTestAssignments::getInstance($a_container_id); include_once './Modules/Course/classes/class.ilCourseObjective.php'; $objective_ids = ilCourseObjective::_getObjectiveIds($a_container_id); $relevant_objective_ids = array(); if (!$this->getSettings()->hasSeparateInitialTests()) { if ($a_tst_ref_id == $this->getSettings()->getInitialTest()) { $relevant_objective_ids = $objective_ids; } } elseif (!$this->getSettings()->hasSeparateQualifiedTests()) { if ($a_tst_ref_id == $this->getSettings()->getQualifiedTest()) { $relevant_objective_ids = $objective_ids; } } foreach ((array) $objective_ids as $objective_id) { $assigned_itest = $assignments->getTestByObjective($objective_id, ilLOSettings::TYPE_TEST_INITIAL); if ($assigned_itest == $a_tst_ref_id) { $relevant_objective_ids[] = $objective_id; } $assigned_qtest = $assignments->getTestByObjective($objective_id, ilLOSettings::TYPE_TEST_QUALIFIED); if ($assigned_qtest == $a_tst_ref_id) { $relevant_objective_ids[] = $objective_id; } } $relevant_objective_ids = array_unique($relevant_objective_ids); if (count($relevant_objective_ids) <= 1) { return $relevant_objective_ids; } // filter passed objectives $test_type = $assignments->getTypeByTest($a_tst_ref_id); $passed_objectives = array(); include_once './Modules/Course/classes/Objectives/class.ilLOUserResults.php'; $results = new ilLOUserResults($a_container_id, $a_user_id); $passed = $results->getCompletedObjectiveIds(); $GLOBALS['ilLog']->write(__METHOD__ . ': Passed objectives are ' . print_r($passed, TRUE) . ' test_type = ' . $test_type); // all completed => show all objectives if (count($passed) >= count($relevant_objective_ids)) { return $relevant_objective_ids; } $unpassed = array(); foreach ($relevant_objective_ids as $objective_id) { if (!in_array($objective_id, $passed)) { $unpassed[] = $objective_id; } } return $unpassed; }
/** * Test redirection will be moved lo adapter */ 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'; include_once './Modules/Course/classes/Objectives/class.ilLOTestAssignments.php'; $res = new ilLOUserResults($this->object->getId(), $GLOBALS['ilUser']->getId()); $passed = $res->getCompletedObjectiveIds(); $has_completed = FALSE; if ($objective_id) { $objective_ids = array($objective_id); if (in_array($objective_id, $passed)) { $has_completed = TRUE; $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)) { $has_completed = TRUE; $passed = array(); } } if ($has_completed) { // show confirmation $this->redirectLocToTestConfirmation($objective_id, $test_id); return TRUE; } include_once './Services/Link/classes/class.ilLink.php'; ilUtil::redirect(ilLink::_getLink($test_id)); return TRUE; }