/** * Get in progress users for object * * @param int $a_obj_id * @param array $a_user_ids * @return array */ public static function _lookupInProgressForObject($a_obj_id, $a_user_ids = null) { $class = ilLPStatusFactory::_getClassById($a_obj_id); return $class::_lookupInProgressForObject($a_obj_id, $a_user_ids); }
protected function checkLPIcon($a_id) { global $ilUser; // do it once for all chapters if ($this->lp_cache[$this->lm_obj->getId()] === null) { $this->lp_cache[$this->lm_obj->getId()] = false; include_once './Services/Tracking/classes/class.ilLearningProgressAccess.php'; if (ilLearningProgressAccess::checkAccess($this->lm_obj->getRefId())) { $info = null; include_once './Services/Object/classes/class.ilObjectLP.php'; $olp = ilObjectLP::getInstance($this->lm_obj->getId()); if ($olp->getCurrentMode() == ilLPObjSettings::LP_MODE_COLLECTION_MANUAL || $olp->getCurrentMode() == ilLPObjSettings::LP_MODE_COLLECTION_TLT) { include_once "Services/Tracking/classes/class.ilLPStatusFactory.php"; $class = ilLPStatusFactory::_getClassById($this->lm_obj->getId(), $olp->getCurrentMode()); $info = $class::_getStatusInfo($this->lm_obj->getId()); } // parse collection items if (is_array($info["items"])) { foreach ($info["items"] as $item_id) { $status = ilLPStatus::LP_STATUS_NOT_ATTEMPTED_NUM; if (is_array($info["in_progress"][$item_id]) && in_array($ilUser->getId(), $info["in_progress"][$item_id])) { $status = ilLPStatus::LP_STATUS_IN_PROGRESS_NUM; } else { if (is_array($info["completed"][$item_id]) && in_array($ilUser->getId(), $info["completed"][$item_id])) { $status = ilLPStatus::LP_STATUS_COMPLETED_NUM; } } $this->lp_cache[$this->lm_obj->getId()][$item_id] = $status; } } } include_once './Services/Tracking/classes/class.ilLearningProgressBaseGUI.php'; } if (is_array($this->lp_cache[$this->lm_obj->getId()]) && isset($this->lp_cache[$this->lm_obj->getId()][$a_id])) { return ilLearningProgressBaseGUI::_getImagePathForStatus($this->lp_cache[$this->lm_obj->getId()][$a_id]); } }
/** * Test LP marks * @param * @return */ public function testLPMarks() { include_once './Services/Tracking/classes/class.ilLPMarks.php'; include_once './Services/Tracking/classes/class.ilLPStatusFactory.php'; $marks = new ilLPMarks(999, 888); $marks->setMark('Gut'); $marks->setComment('Weiter so'); $marks->setCompleted(true); $marks->update(); $marks = new ilLPMarks(999, 888); $mark = $marks->getMark(); $this->assertEquals($mark, 'Gut'); $comment = ilLPMarks::_lookupComment(888, 999); $this->assertEquals($comment, 'Weiter so'); $class = ilLPStatusFactory::_getClassById(999, ilLPObjSettings::LP_MODE_MANUAL); $completed = $class::_getCompleted(999); $this->assertEquals(array(888), $completed); ilLPMarks::deleteObject(999); }
protected function showtlt() { global $lng, $ilCtrl, $tpl, $ilUser; include_once "Services/Form/classes/class.ilPropertyFormGUI.php"; $form = new ilPropertyFormGUI(); $form->setFormAction($ilCtrl->getFormAction($this, "showtlt")); $form->setTitle($lng->txt("learning_progress")); $form->setDescription($lng->txt("trac_collection_tlt_learner_info")); $coll_items = array(); include_once './Services/Object/classes/class.ilObjectLP.php'; $olp = ilObjectLP::getInstance($this->getObjId()); $collection = $olp->getCollectionInstance(); if ($collection) { $coll_items = $collection->getItems(); $possible_items = $collection->getPossibleItems($this->getRefId()); // for titles } include_once "Services/Tracking/classes/class.ilLPStatusFactory.php"; $class = ilLPStatusFactory::_getClassById($this->getObjId(), ilLPObjSettings::LP_MODE_COLLECTION_TLT); $info = $class::_getStatusInfo($this->getObjId(), true); foreach ($coll_items as $item_id) { $field = new ilCustomInputGUI($possible_items[$item_id]["title"]); // lp status $status = ilLPStatus::LP_STATUS_NOT_ATTEMPTED_NUM; if (isset($info["completed"][$item_id]) && in_array($ilUser->getId(), $info["completed"][$item_id])) { $status = ilLPStatus::LP_STATUS_COMPLETED_NUM; } else { if (isset($info["in_progress"][$item_id]) && in_array($ilUser->getId(), $info["in_progress"][$item_id])) { $status = ilLPStatus::LP_STATUS_IN_PROGRESS_NUM; } } $path = ilLearningProgressBaseGUI::_getImagePathForStatus($status); $text = ilLearningProgressBaseGUI::_getStatusText($status); $field->setHtml(ilUtil::img($path, $text)); // stats $spent = 0; if (isset($info["tlt_users"][$item_id][$ilUser->getId()])) { $spent = $info["tlt_users"][$item_id][$ilUser->getId()]; } $needed = $info["tlt"][$item_id]; if ($needed) { $field->setInfo(sprintf($lng->txt("trac_collection_tlt_learner_subitem"), ilFormat::_secondsToString($spent), ilFormat::_secondsToString($needed), min(100, round(abs($spent) / $needed * 100)))); } $form->addItem($field); } $tpl->setContent($form->getHTML()); }
/** * Get participant ids for given object * * @param int $a_ref_id * @return array */ public static function getParticipantsForObject($a_ref_id) { global $tree; $obj_id = ilObject::_lookupObjectId($a_ref_id); $obj_type = ilObject::_lookupType($obj_id); // try to get participants from (parent) course/group switch ($obj_type) { case "crs": include_once "Modules/Course/classes/class.ilCourseParticipants.php"; $member_obj = ilCourseParticipants::_getInstanceByObjId($obj_id); return $member_obj->getMembers(); case "grp": include_once "Modules/Group/classes/class.ilGroupParticipants.php"; $member_obj = ilGroupParticipants::_getInstanceByObjId($obj_id); return $member_obj->getMembers(); default: // walk path to find course or group object and use members of that object $path = $tree->getPathId($a_ref_id); array_pop($path); foreach (array_reverse($path) as $path_ref_id) { $type = ilObject::_lookupType($path_ref_id, true); if ($type == "crs" || $type == "grp") { return self::getParticipantsForObject($path_ref_id); } } break; } $a_users = null; // no participants possible: use tracking/object data where possible switch ($obj_type) { case "sahs": include_once "./Modules/ScormAicc/classes/class.ilObjSAHSLearningModule.php"; $subtype = ilObjSAHSLearningModule::_lookupSubType($obj_id); if ($subtype == "scorm2004") { // based on cmi_node/cp_node, used for scorm tracking data views include_once "./Modules/Scorm2004/classes/class.ilObjSCORM2004LearningModule.php"; $mod = new ilObjSCORM2004LearningModule($obj_id, false); $all = $mod->getTrackedUsers(""); if ($all) { $a_users = array(); foreach ($all as $item) { $a_users[] = $item["user_id"]; } } } else { include_once "./Modules/ScormAicc/classes/SCORM/class.ilObjSCORMTracking.php"; $a_users = ilObjSCORMTracking::_getTrackedUsers($obj_id); } break; case "exc": include_once "./Modules/Exercise/classes/class.ilExerciseMembers.php"; include_once "./Modules/Exercise/classes/class.ilObjExercise.php"; $exc = new ilObjExercise($obj_id, false); $members = new ilExerciseMembers($exc); $a_users = $members->getMembers(); break; case "tst": include_once "Services/Tracking/classes/class.ilLPStatusFactory.php"; $class = ilLPStatusFactory::_getClassById($obj_id, ilLPObjSettings::LP_MODE_TEST_FINISHED); $a_users = $class::getParticipants($obj_id); break; default: // no sensible data: return null break; } return $a_users; }
/** * Get in progress users for object * * @param int $a_obj_id * @param array $a_user_ids * @return array */ public static function _lookupInProgressForObject($a_obj_id, $a_user_ids = null) { $class = ilLPStatusFactory::_getClassById($a_obj_id); return call_user_func_array(array($class, "_lookupInProgressForObject"), array($a_obj_id, $a_user_ids)); }
/** * This function checks whether the status for a given number of users is dirty and must be * recalculated. "Missing" records are not inserted! * * @param * @return */ static function checkStatusForObject($a_obj_id, $a_users = false) { global $ilDB; //@todo: there maybe the need to add extra handling for sessions here, since the // "in progress" status is time dependent here. On the other hand, if they registered // to the session, they already accessed the course and should have a "in progress" // anyway. But the status on the session itself may not be correct. $sql = "SELECT usr_id FROM ut_lp_marks WHERE " . " obj_id = " . $ilDB->quote($a_obj_id, "integer") . " AND " . " status_dirty = " . $ilDB->quote(1, "integer"); if (is_array($a_users) && count($a_users) > 0) { $sql .= " AND " . $ilDB->in("usr_id", $a_users, false, "integer"); } $set = $ilDB->query($sql); $dirty = false; if ($rec = $ilDB->fetchAssoc($set)) { $dirty = true; } // check if any records are missing $missing = false; if (!$dirty && is_array($a_users) && count($a_users) > 0) { $set = $ilDB->query("SELECT count(usr_id) cnt FROM ut_lp_marks WHERE " . " obj_id = " . $ilDB->quote($a_obj_id, "integer") . " AND " . $ilDB->in("usr_id", $a_users, false, "integer")); $r = $ilDB->fetchAssoc($set); if ($r["cnt"] < count($a_users)) { $missing = true; } } // refresh status, if records are dirty or missing if ($dirty || $missing) { $class = ilLPStatusFactory::_getClassById($a_obj_id); $trac_obj = new $class($a_obj_id); $trac_obj->refreshStatus($a_obj_id, $a_users); } }