コード例 #1
0
 protected function renderMyCourses($a_user_id)
 {
     global $ilAccess, $ilUser;
     if ($this->getOutputMode() == "preview") {
         return $this->renderMyCoursesTeaser($a_user_id);
     }
     if (!$this->isMyCoursesActive()) {
         return;
     }
     $img_path = null;
     if ($this->getOutputMode() == "offline") {
         $this->export_material["images"][] = "./templates/default/images/icon_crs.svg";
         $this->export_material["images"][] = "./templates/default/images/icon_lobj.svg";
         $this->export_material["images"][] = "./templates/default/images/scorm/complete.svg";
         $this->export_material["images"][] = "./templates/default/images/scorm/not_attempted.svg";
         $this->export_material["images"][] = "./templates/default/images/scorm/failed.svg";
         $this->export_material["images"][] = "./templates/default/images/scorm/incomplete.svg";
         $img_path = "images/";
     }
     $user_id = $this->getPageContentUserId($a_user_id);
     $data = $this->getCoursesOfUser($user_id);
     if (sizeof($data)) {
         $tpl = new ilTemplate("tpl.pc_my_courses.html", true, true, "Modules/Portfolio");
         $tpl->setVariable("TITLE", $this->lng->txt("prtf_page_element_my_courses_title"));
         $tpl->setVariable("INFO", $this->lng->txt("prtf_page_element_my_courses_info"));
         // #14464
         include_once "./Services/Tracking/classes/class.ilLearningProgressBaseGUI.php";
         $this->lng->loadLanguageModule("trac");
         $this->lng->loadLanguageModule("crs");
         include_once "./Services/Container/classes/class.ilContainerObjectiveGUI.php";
         include_once "./Services/Link/classes/class.ilLink.php";
         foreach ($data as $course) {
             if (isset($course["lp_status"])) {
                 $lp_icon = ilLearningProgressBaseGUI::_getImagePathForStatus($course["lp_status"]);
                 $lp_alt = ilLearningProgressBaseGUI::_getStatusText($course["lp_status"]);
                 if ($img_path) {
                     $lp_icon = $img_path . basename($lp_icon);
                 }
                 $tpl->setCurrentBlock("lp_bl");
                 $tpl->setVariable("LP_ICON_URL", $lp_icon);
                 $tpl->setVariable("LP_ICON_ALT", $lp_alt);
                 $tpl->parseCurrentBlock();
             }
             if (isset($course["objectives"])) {
                 include_once './Modules/Course/classes/Objectives/class.ilLOSettings.php';
                 $loc_settings = ilLOSettings::getInstanceByObjId($course["obj_id"]);
                 $has_initial_test = (bool) $loc_settings->getInitialTest();
                 foreach ($course["objectives"] as $objtv) {
                     $objtv_icon = ilUtil::getTypeIconPath("lobj", $objtv["id"]);
                     if ($img_path) {
                         $objtv_icon = $img_path . basename($objtv_icon);
                     }
                     $tpl->setCurrentBlock("objective_bl");
                     $tpl->setVariable("OBJECTIVE_TITLE", $objtv["title"]);
                     $tpl->setVariable("OBJTV_ICON_URL", $objtv_icon);
                     $tpl->setVariable("OBJTV_ICON_ALT", $this->lng->txt("crs_objectives"));
                     if ($objtv["type"]) {
                         $tpl->setVariable("LP_OBJTV_PROGRESS", ilContainerObjectiveGUI::buildObjectiveProgressBar($has_initial_test, $objtv["id"], $objtv, true));
                     }
                     $tpl->parseCurrentBlock();
                 }
             }
             // always check against current user
             if ($ilAccess->checkAccessOfUser($ilUser->getId(), "read", "", $course["ref_id"], "crs") || $ilAccess->checkAccessOfUser($ilUser->getId(), "visible", "", $course["ref_id"], "crs") && $ilAccess->checkAccessOfUser($ilUser->getId(), "join", "", $course["ref_id"], "crs")) {
                 $tpl->setCurrentBlock("course_link_bl");
                 $tpl->setVariable("COURSE_LINK_TITLE", $course["title"]);
                 $tpl->setVariable("COURSE_LINK_URL", ilLink::_getLink($course["ref_id"]));
                 $tpl->parseCurrentBlock();
             } else {
                 $tpl->setCurrentBlock("course_nolink_bl");
                 $tpl->setVariable("COURSE_NOLINK_TITLE", $course["title"]);
                 $tpl->parseCurrentBlock();
             }
             $crs_icon = ilUtil::getTypeIconPath("crs", $course["obj_id"]);
             if ($img_path) {
                 $crs_icon = $img_path . basename($crs_icon);
             }
             $tpl->setCurrentBlock("course_bl");
             $tpl->setVariable("CRS_ICON_URL", $crs_icon);
             $tpl->setVariable("CRS_ICON_ALT", $this->lng->txt("obj_crs"));
             $tpl->parseCurrentBlock();
         }
         return $tpl->get();
     }
 }
コード例 #2
0
 protected function renderMyCourses($a_user_id, $a_default_sorting)
 {
     global $ilAccess, $ilUser, $ilCtrl;
     if ($this->getOutputMode() == "preview") {
         return $this->renderMyCoursesTeaser($a_user_id, $a_default_sorting);
     }
     if (!$this->isMyCoursesActive()) {
         return;
     }
     $img_path = null;
     if ($this->getOutputMode() == "offline") {
         $this->export_material["images"][] = "./templates/default/images/icon_crs.svg";
         $this->export_material["images"][] = "./templates/default/images/icon_lobj.svg";
         $this->export_material["images"][] = "./templates/default/images/scorm/complete.svg";
         $this->export_material["images"][] = "./templates/default/images/scorm/not_attempted.svg";
         $this->export_material["images"][] = "./templates/default/images/scorm/failed.svg";
         $this->export_material["images"][] = "./templates/default/images/scorm/incomplete.svg";
         $img_path = "images/";
     }
     $user_id = $this->getPageContentUserId($a_user_id);
     // sorting pref
     if ($_POST["srt"] && in_array($_POST["srt"], array("alpha", "loc"))) {
         $ilUser->writePref("prtf_mcrs_sort", $_POST["srt"]);
     }
     $sorting = $ilUser->getPref("prtf_mcrs_sort");
     if (!$sorting) {
         $sorting = $a_default_sorting;
     }
     $data = $this->getCoursesOfUser($user_id, $sorting == "loc");
     if (sizeof($data)) {
         if ($sorting != "loc") {
             $data = ilUtil::sortArray($data, "title", "ASC");
         } else {
             $data = ilUtil::sortArray($data, "path_sort", "ASC");
         }
         $tpl = new ilTemplate("tpl.pc_my_courses.html", true, true, "Modules/Portfolio");
         $tpl->setVariable("TITLE", $this->lng->txt("prtf_page_element_my_courses_title"));
         $tpl->setVariable("INFO", $this->lng->txt("prtf_page_element_my_courses_info"));
         // #14464
         include_once "./Services/Tracking/classes/class.ilLearningProgressBaseGUI.php";
         $this->lng->loadLanguageModule("trac");
         $this->lng->loadLanguageModule("crs");
         include_once "./Services/Container/classes/class.ilContainerObjectiveGUI.php";
         include_once "./Services/Link/classes/class.ilLink.php";
         // sorting
         $options = array("alpha" => $this->lng->txt("cont_mycourses_sortorder_alphabetical"), "loc" => $this->lng->txt("cont_mycourses_sortorder_location"));
         $tpl->setVariable("SORT_SELECT", ilUtil::formSelect($sorting, "srt", $options, false, true, 0, "", array("onchange" => "form.submit()")));
         $tpl->setVariable("SORT_FORM", $ilCtrl->getFormActionByClass("ilobjportfoliogui", "preview"));
         $old_path = null;
         foreach ($data as $course) {
             if ($sorting == "loc") {
                 if ($course["path"] != $old_path) {
                     $tpl->setCurrentBlock("path_bl");
                     $tpl->setVariable("PATH", $course["path"]);
                     $tpl->parseCurrentBlock();
                     $old_path = $course["path"];
                 }
             }
             if (isset($course["lp_status"])) {
                 $lp_icon = ilLearningProgressBaseGUI::_getImagePathForStatus($course["lp_status"]);
                 $lp_alt = ilLearningProgressBaseGUI::_getStatusText($course["lp_status"]);
                 if ($img_path) {
                     $lp_icon = $img_path . basename($lp_icon);
                 }
                 $tpl->setCurrentBlock("lp_bl");
                 $tpl->setVariable("LP_ICON_URL", $lp_icon);
                 $tpl->setVariable("LP_ICON_ALT", $lp_alt);
                 $tpl->parseCurrentBlock();
             }
             $do_links = false;
             if ($ilUser->getId() != ANONYMOUS_USER_ID) {
                 $do_links = $ilAccess->checkAccessOfUser($ilUser->getId(), "read", "", $course["ref_id"], "crs") || $ilAccess->checkAccessOfUser($ilUser->getId(), "visible", "", $course["ref_id"], "crs") && $ilAccess->checkAccessOfUser($ilUser->getId(), "join", "", $course["ref_id"], "crs");
             }
             if (isset($course["objectives"])) {
                 include_once './Modules/Course/classes/Objectives/class.ilLOSettings.php';
                 $loc_settings = ilLOSettings::getInstanceByObjId($course["obj_id"]);
                 $has_initial_test = (bool) $loc_settings->getInitialTest();
                 foreach ($course["objectives"] as $objtv) {
                     if ($do_links) {
                         $params = array("oobj" => $objtv["id"]);
                         $url = ilLink::_getLink($course["ref_id"], "crs", $params);
                         // #15510
                         $url .= "#objtv_acc_" . $objtv["id"];
                         $tpl->setCurrentBlock("objective_link_bl");
                         if (trim($objtv["desc"])) {
                             $desc = nl2br($objtv["desc"]);
                             $tt_id = "objtvtt_" . $objtv["id"] . "_" . (int) self::$initialized;
                             include_once "Services/UIComponent/Tooltip/classes/class.ilTooltipGUI.php";
                             ilToolTipGUI::addTooltip($tt_id, $desc, "", "bottom center", "top center", false);
                             $tpl->setVariable("OBJECTIVE_LINK_ID", $tt_id);
                         }
                         $tpl->setVariable("OBJECTIVE_LINK_URL", $url);
                         $tpl->setVariable("OBJECTIVE_LINK_TITLE", $objtv["title"]);
                         $tpl->parseCurrentBlock();
                     } else {
                         $tpl->setCurrentBlock("objective_nolink_bl");
                         $tpl->setVariable("OBJECTIVE_NOLINK_TITLE", $objtv["title"]);
                         $tpl->parseCurrentBlock();
                     }
                     $objtv_icon = ilUtil::getTypeIconPath("lobj", $objtv["id"]);
                     if ($img_path) {
                         $objtv_icon = $img_path . basename($objtv_icon);
                     }
                     $tpl->setCurrentBlock("objective_bl");
                     $tpl->setVariable("OBJTV_ICON_URL", $objtv_icon);
                     $tpl->setVariable("OBJTV_ICON_ALT", $this->lng->txt("crs_objectives"));
                     if ($objtv["type"]) {
                         $tpl->setVariable("LP_OBJTV_PROGRESS", ilContainerObjectiveGUI::buildObjectiveProgressBar($has_initial_test, $objtv["id"], $objtv, true, (int) self::$initialized));
                     }
                     $tpl->parseCurrentBlock();
                 }
                 $tpl->setCurrentBlock("objectives_bl");
                 $tpl->setVariable("OBJTV_LIST_CRS_ID", $course["obj_id"]);
                 $tpl->parseCurrentBlock();
             }
             // always check against current user
             if ($do_links) {
                 $tpl->setCurrentBlock("course_link_bl");
                 $tpl->setVariable("COURSE_LINK_TITLE", $course["title"]);
                 $tpl->setVariable("COURSE_LINK_URL", ilLink::_getLink($course["ref_id"]));
                 $tpl->parseCurrentBlock();
             } else {
                 $tpl->setCurrentBlock("course_nolink_bl");
                 $tpl->setVariable("COURSE_NOLINK_TITLE", $course["title"]);
                 $tpl->parseCurrentBlock();
             }
             $crs_icon = ilUtil::getTypeIconPath("crs", $course["obj_id"]);
             if ($img_path) {
                 $crs_icon = $img_path . basename($crs_icon);
             }
             $tpl->setCurrentBlock("course_bl");
             if (isset($course["objectives"])) {
                 $tpl->setVariable("TOGGLE_CLASS", "ilPCMyCoursesToggle");
             } else {
                 $tpl->setVariable("NO_TOGGLE", ' style="visibility:hidden;"');
             }
             $tpl->setVariable("CRS_ICON_URL", $crs_icon);
             $tpl->setVariable("CRS_ICON_ALT", $this->lng->txt("obj_crs"));
             $tpl->parseCurrentBlock();
         }
         // #15508
         if (!self::$initialized) {
             $GLOBALS["tpl"]->addJavaScript("Modules/Portfolio/js/ilPortfolio.js");
             $GLOBALS["tpl"]->addOnLoadCode("ilPortfolio.init()");
         }
         self::$initialized++;
         return $tpl->get();
     }
 }