protected function resetCustomLPDataForUserIds(array $a_user_ids, $a_recursive = true) { /* @var ilObjTest $testOBJ */ require_once 'Services/Object/classes/class.ilObjectFactory.php'; $testOBJ = ilObjectFactory::getInstanceByObjId($this->obj_id); $testOBJ->removeTestResults($a_user_ids); // :TODO: there has to be a better way $test_ref_id = (int) $_REQUEST["ref_id"]; if ($test_ref_id) { require_once "Modules/Course/classes/Objectives/class.ilLOSettings.php"; $course_obj_id = ilLOSettings::isObjectiveTest($test_ref_id); if ($course_obj_id) { // is test initial and/or qualified? $lo_settings = ilLOSettings::getInstanceByObjId($course_obj_id); $is_i = $lo_settings->getInitialTest() == $test_ref_id; $is_q = $lo_settings->getQualifiedTest() == $test_ref_id; // remove objective results data require_once "Modules/Course/classes/Objectives/class.ilLOUserResults.php"; ilLOUserResults::deleteResultsFromLP($course_obj_id, $a_user_ids, $is_i, $is_q); // refresh LP - see ilLPStatusWrapper::_updateStatus() require_once "Services/Tracking/classes/class.ilLPStatusFactory.php"; $lp_status = ilLPStatusFactory::_getInstance($course_obj_id); if (strtolower(get_class($lp_status)) != "illpstatus") { foreach ($a_user_ids as $user_id) { $lp_status->_updateStatus($course_obj_id, $user_id); } } } } }
static function getObjectivesStatusForUser($a_user_id, $a_obj_id, array $a_objective_ids) { global $ilDB; include_once "Modules/Course/classes/Objectives/class.ilLOUserResults.php"; $lo_lp_status = ilLOUserResults::getObjectiveStatusForLP($a_user_id, $a_obj_id, $a_objective_ids); $query = "SELECT crs_id, crs_objectives.objective_id AS obj_id, title," . $ilDB->quote("lobj", "text") . " AS type" . " FROM crs_objectives" . " WHERE " . $ilDB->in("crs_objectives.objective_id", $a_objective_ids, false, "integer") . " AND active = " . $ilDB->quote(1, "integer") . " ORDER BY position"; $set = $ilDB->query($query); $result = array(); while ($rec = $ilDB->fetchAssoc($set)) { if (array_key_exists($rec["obj_id"], $lo_lp_status)) { $rec["status"] = $lo_lp_status[$rec["obj_id"]]; } else { $rec["status"] = ilLPStatus::LP_STATUS_NOT_ATTEMPTED_NUM; } $result[] = $rec; } return $result; }
function _deleteUser($a_usr_id) { // Delete all user related data // delete lm_history include_once './Modules/Course/classes/class.ilCourseLMHistory.php'; ilCourseLMHistory::_deleteUser($a_usr_id); include_once './Modules/Course/classes/class.ilCourseParticipants.php'; ilCourseParticipants::_deleteUser($a_usr_id); // Course objectives include_once "Modules/Course/classes/Objectives/class.ilLOUserResults.php"; ilLOUserResults::deleteResultsForUser($a_usr_id); }
protected function parseLOUserResults() { global $ilUser; $res = array(); include_once "Modules/Course/classes/Objectives/class.ilLOTestAssignments.php"; $lo_ass = ilLOTestAssignments::getInstance($this->getContainerObject()->getId()); include_once "Modules/Course/classes/Objectives/class.ilLOUserResults.php"; $lur = new ilLOUserResults($this->getContainerObject()->getId(), $ilUser->getId()); foreach ($lur->getCourseResultsForUserPresentation() as $objective_id => $types) { // show either initial or qualified for objective if (isset($types[ilLOUserResults::TYPE_INITIAL])) { $initial_status = $types[ilLOUserResults::TYPE_INITIAL]["status"]; } // qualified test has priority if (isset($types[ilLOUserResults::TYPE_QUALIFIED])) { $result = $types[ilLOUserResults::TYPE_QUALIFIED]; $result["type"] = ilLOUserResults::TYPE_QUALIFIED; $result["initial"] = $types[ilLOUserResults::TYPE_INITIAL]; } else { $result = $types[ilLOUserResults::TYPE_INITIAL]; $result["type"] = ilLOUserResults::TYPE_INITIAL; } $result["initial_status"] = $initial_status; $result["itest"] = $lo_ass->getTestByObjective($objective_id, ilLOSettings::TYPE_TEST_INITIAL); $result["qtest"] = $lo_ass->getTestByObjective($objective_id, ilLOSettings::TYPE_TEST_QUALIFIED); $res[$objective_id] = $result; } return $res; }
/** * Parse user results for table * @return type */ public function parse() { include_once './Modules/Course/classes/Objectives/class.ilLOUserResults.php'; include_once './Modules/Course/classes/class.ilCourseObjective.php'; $objective_ids = ilCourseObjective::_getObjectiveIds($this->getParentContainer()->getId(), TRUE); foreach ((array) $objective_ids as $objective_id) { $objective = array(); $objective['id'] = $objective_id; $objective['title'] = ilCourseObjective::lookupObjectiveTitle($objective_id); if ($this->getSettings()->worksWithInitialTest()) { $results_it = ilLOUserResults::lookupResult($this->getParentContainer()->getId(), $this->getUserId(), $objective_id, ilLOSettings::TYPE_TEST_INITIAL); $objective['tries_it'] = $results_it['tries']; $objective['res_it'] = $results_it['result_perc']; $objective['link_it'] = $this->createTestResultLink(ilLOSettings::TYPE_TEST_INITIAL, $objective_id); } $results_qt = ilLOUserResults::lookupResult($this->getParentContainer()->getId(), $this->getUserId(), $objective_id, ilLOSettings::TYPE_TEST_QUALIFIED); $objective['tries_qt'] = $results_qt['tries']; $objective['res_qt'] = $results_qt['result_perc']; $objective['link_qt'] = $this->createTestResultLink(ilLOSettings::TYPE_TEST_QUALIFIED, $objective_id); $tbl_data[] = $objective; } return $this->setData($tbl_data); }
/** * Determine status * * @param integer object id * @param integer user id * @param object object (optional depends on object type) * @return integer status */ function determineStatus($a_obj_id, $a_user_id, $a_obj = null) { global $ilObjDataCache, $ilDB; // the status completed depends on: // $status_info['num_objectives'] (ilLPStatusWrapper::_getStatusInfo($a_obj_id);) // - ilCourseObjective::_getObjectiveIds($a_obj_id); // - table crs_objectives manipulated in // - ilCourseObjective // $status_info['objective_result'] (ilLPStatusWrapper::_getStatusInfo($a_obj_id);) // table crs_objective_status (must not contain a dataset) // ilCourseObjectiveResult -> added ilLPStatusWrapper::_updateStatus() $status = self::LP_STATUS_NOT_ATTEMPTED_NUM; switch ($ilObjDataCache->lookupType($a_obj_id)) { case "crs": include_once "./Services/Tracking/classes/class.ilChangeEvent.php"; if (ilChangeEvent::hasAccessed($a_obj_id, $a_user_id)) { // change_event is of no use when no objective has been tried // $status = self::LP_STATUS_IN_PROGRESS_NUM; include_once 'Modules/Course/classes/class.ilCourseObjective.php'; $objectives = ilCourseObjective::_getObjectiveIds($a_obj_id, true); if ($objectives) { // #14051 - getSummarizedObjectiveStatusForLP() might return null include_once "Modules/Course/classes/Objectives/class.ilLOUserResults.php"; $status = (int) ilLOUserResults::getSummarizedObjectiveStatusForLP($objectives, $a_user_id); } } break; } return $status; }
/** * 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; }
protected function parseLOUserResults($a_course_obj_id, $a_user_id) { $res = array(); include_once "Modules/Course/classes/Objectives/class.ilLOUserResults.php"; $lur = new ilLOUserResults($a_course_obj_id, $a_user_id); foreach ($lur->getCourseResultsForUserPresentation() as $objective_id => $types) { // show either initial or qualified for objective if (isset($types[ilLOUserResults::TYPE_INITIAL])) { $initial_status = $types[ilLOUserResults::TYPE_INITIAL]["status"]; } // qualified test has priority if (isset($types[ilLOUserResults::TYPE_QUALIFIED])) { $result = $types[ilLOUserResults::TYPE_QUALIFIED]; $result["type"] = ilLOUserResults::TYPE_QUALIFIED; } else { $result = $types[ilLOUserResults::TYPE_INITIAL]; $result["type"] = ilLOUserResults::TYPE_INITIAL; } $result["initial_status"] = $initial_status; $res[$objective_id] = $result; } return $res; }
/** * update question result of run * @param ilTestSession $session * @param assQuestion $qst */ protected function updateQuestionResult(ilTestSession $session, assQuestion $qst) { foreach ($this->run as $run) { if ($run->questionExists($qst->getId())) { $GLOBALS['ilLog']->write(__METHOD__ . ': reached points are ' . $qst->getReachedPoints($session->getActiveId(), $session->getPass())); $run->setQuestionResult($qst->getId(), $qst->getReachedPoints($session->getActiveId(), $session->getPass())); $run->update(); $res = $run->getResult(); include_once './Modules/Course/classes/Objectives/class.ilLOUserResults.php'; include_once './Modules/Course/classes/Objectives/class.ilLOUtils.php'; $old_result = ilLOUserResults::lookupResult($this->container_id, $this->user_id, $run->getObjectiveId(), $this->getSettings()->getQualifiedTest() == $session->getRefId() ? ilLOUserResults::TYPE_QUALIFIED : ilLOUserResults::TYPE_INITIAL); $ur = new ilLOUserResults($this->container_id, $this->user_id); $ur->saveObjectiveResult($run->getObjectiveId(), $this->getSettings()->getQualifiedTest() == $session->getRefId() ? ilLOUserResults::TYPE_QUALIFIED : ilLOUserResults::TYPE_INITIAL, ilLOUtils::isCompleted($this->container_id, $session->getRefId(), $run->getObjectiveId(), $res['max'], $res['reached'], $old_result['limit_perc']) ? ilLOUserResults::STATUS_COMPLETED : ilLOUserResults::STATUS_FAILED, (int) $res['percentage'], $old_result['limit_perc'], $old_result['tries'], $old_result['is_final']); $GLOBALS['ilLog']->write(__METHOD__ . ': ' . print_r($run->getResult(), true)); include_once "./Services/Tracking/classes/class.ilLPStatusWrapper.php"; ilLPStatusWrapper::_updateStatus($this->container_id, $this->user_id); } } return false; }
/** * */ 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); }