protected function getItems() { global $ilUser, $ilObjDataCache, $ilAccess; include_once './Modules/Course/classes/class.ilCourseLMHistory.php'; include_once './Services/Link/classes/class.ilLink.php'; $lm_continue = new ilCourseLMHistory($this->start_object->getRefId(), $ilUser->getId()); $continue_data = $lm_continue->getLMHistory(); $items = array(); $counter = 0; foreach ($this->start_object->getStartObjects() as $start) { $obj_id = $ilObjDataCache->lookupObjId($start['item_ref_id']); $ref_id = $start['item_ref_id']; $type = $ilObjDataCache->lookupType($obj_id); if (!$ilAccess->checkAccess("visible", "", $ref_id)) { continue; } // start object status if ($this->start_object->isFullfilled($ilUser->getId(), $ref_id)) { $accomplished = 'accomplished'; } else { $accomplished = 'not_accomplished'; } // add/remove desktop $actions = array(); if ((bool) $this->enable_desktop) { // add to desktop link if (!$ilUser->isDesktopItem($ref_id, $type)) { if ($ilAccess->checkAccess('read', '', $ref_id)) { $this->ctrl->setParameter($this->getParentObject(), 'item_ref_id', $ref_id); $this->ctrl->setParameter($this->getParentObject(), 'item_id', $ref_id); $this->ctrl->setParameter($this->getParentObject(), 'type', $type); $url = $this->ctrl->getLinkTarget($this->getParentObject(), 'addToDesk'); $actions[$url] = $this->lng->txt("to_desktop"); } } else { $this->ctrl->setParameter($this->getParentObject(), 'item_ref_id', $ref_id); $this->ctrl->setParameter($this->getParentObject(), 'item_id', $ref_id); $this->ctrl->setParameter($this->getParentObject(), 'type', $type); $url = $this->ctrl->getLinkTarget($this->getParentObject(), 'removeFromDesk'); $actions[$url] = $this->lng->txt("unsubscribe"); } } $default_params = null; if ($type == "tst") { $default_params["crs_show_result"] = $ref_id; } /* continue is currently inactive if(isset($continue_data[$ref_id])) { // :TODO: should "continue" be default or 2nd link/action? // $this->lng->txt('continue_work') $default_params["obj_id"] = $continue_data[$ref_id]['lm_page_id']; } */ if ($accomplished == 'accomplished') { $icon = ilUtil::getImagePath("icon_ok.svg"); } else { $icon = ilUtil::getImagePath("icon_not_ok.svg"); } $items[] = array("nr" => ++$counter, "obj_id" => $obj_id, "ref_id" => $ref_id, "type" => $type, "append_default" => $default_params, "title" => $ilObjDataCache->lookupTitle($obj_id), "description" => $ilObjDataCache->lookupDescription($obj_id), "status" => $this->lng->txt('crs_objective_' . $accomplished), "status_img" => $icon, "actions" => $actions); } include_once "./Services/Object/classes/class.ilObjectListGUIPreloader.php"; $preloader = new ilObjectListGUIPreloader(ilObjectListGUI::CONTEXT_REPOSITORY); foreach ($items as $item) { $preloader->addItem($item["obj_id"], $item["type"], $item["ref_id"]); } $preloader->preload(); unset($preloader); reset($items); $this->setData($items); }
public function isFullfilled($a_user_id, $a_item_id) { global $ilObjDataCache; $obj_id = $ilObjDataCache->lookupObjId($a_item_id); $type = $ilObjDataCache->lookupType($obj_id); switch ($type) { case 'tst': include_once './Modules/Test/classes/class.ilObjTestAccess.php'; if (!ilObjTestAccess::checkCondition($obj_id, 'finished', '', $a_user_id)) { return false; } break; case 'svy': include_once './Modules/Survey/classes/class.ilObjSurveyAccess.php'; if (!ilObjSurveyAccess::_lookupFinished($obj_id, $a_user_id)) { return false; } break; case 'sahs': include_once 'Services/Tracking/classes/class.ilLPStatus.php'; if (!ilLPStatus::_hasUserCompleted($obj_id, $a_user_id)) { return false; } break; default: include_once './Modules/Course/classes/class.ilCourseLMHistory.php'; $lm_continue = new ilCourseLMHistory($this->getRefId(), $a_user_id); $continue_data = $lm_continue->getLMHistory(); if (!isset($continue_data[$a_item_id])) { return false; } break; } return true; }