function __construct($a_mode, $a_ref_id)
 {
     parent::__construct($a_mode, $a_ref_id);
     $this->obj_settings = new ilLPObjSettings($this->getObjId());
     include_once './Services/Object/classes/class.ilObjectLP.php';
     $this->obj_lp = ilObjectLP::getInstance($this->getObjId());
 }
 function ilLPListOfObjectsGUI($a_mode, $a_ref_id)
 {
     global $ilUser, $ilObjDataCache;
     parent::ilLearningProgressBaseGUI($a_mode, $a_ref_id);
     // Set item id for details
     $this->__initDetails((int) $_REQUEST['details_id']);
 }
 function ilLPObjectStatisticsGUI($a_mode, $a_ref_id = 0)
 {
     parent::ilLearningProgressBaseGUI($a_mode, $a_ref_id);
     if (!$this->ref_id) {
         $this->ref_id = (int) $_REQUEST["ref_id"];
     }
 }
 function ilLPListOfProgressGUI($a_mode, $a_ref_id, $a_user_id = 0)
 {
     parent::ilLearningProgressBaseGUI($a_mode, $a_ref_id, $a_user_id);
     $this->__initUser($a_user_id);
     // Set item id for details
     $this->__initDetails((int) $_GET['details_id']);
     $this->ctrl->saveParameter($this, 'details_id', $_REQUEST['details_id']);
 }
 /**
  * @description This adds the collumn for status.
  *
  * @param ilDataCollectionRecord $record
  * @param ilDataCollectionField  $field
  *
  * @return string
  */
 protected function getStatus(ilDataCollectionRecord $record, ilDataCollectionField $field)
 {
     $record_field = ilDataCollectionCache::getRecordFieldCache($record, $field);
     $return = "";
     if ($status = $record_field->getStatus()) {
         $return = "<img src='" . ilLearningProgressBaseGUI::_getImagePathForStatus($status->status) . "'>";
     }
     return $return;
 }
 protected function fillRowCSV($a_csv, $a_set)
 {
     global $lng;
     $lng->loadLanguageModule("trac");
     include_once "./Services/Tracking/classes/class.ilLearningProgressBaseGUI.php";
     foreach ($this->getSelectedColumns() as $c) {
         if ($c != 'status') {
             $val = $this->parseValue($c, $a_set[$c], "user");
         } else {
             $val = ilLearningProgressBaseGUI::_getStatusText((int) $a_set[$c]);
         }
         $a_csv->addColumn($val);
     }
     $a_csv->addRow();
 }
 function __appendLPDetails(&$info, $item_id, $user_id)
 {
     global $ilObjDataCache;
     $type = $ilObjDataCache->lookupType($item_id);
     // Section learning_progress
     // $info->addSection($this->lng->txt('trac_learning_progress'));
     // see ilLPTableBaseGUI::parseTitle();
     $info->addSection($this->lng->txt("trac_progress") . ": " . ilObject::_lookupTitle($item_id));
     $olp = ilObjectLP::getInstance($item_id);
     $info->addProperty($this->lng->txt('trac_mode'), $olp->getModeText($olp->getCurrentMode()));
     switch ($type) {
         case 'lm':
         case 'htlm':
             include_once 'Services/Tracking/classes/class.ilLearningProgress.php';
             $progress = ilLearningProgress::_getProgress($user_id, $item_id);
             if ($progress['access_time']) {
                 $info->addProperty($this->lng->txt('last_access'), ilDatePresentation::formatDate(new ilDateTime($progress['access_time'], IL_CAL_DATETIME)));
             } else {
                 $info->addProperty($this->lng->txt('last_access'), $this->lng->txt('trac_not_accessed'));
             }
             $info->addProperty($this->lng->txt('trac_visits'), (int) $progress['visits']);
             if ($type == 'lm') {
                 $info->addProperty($this->lng->txt('trac_spent_time'), ilFormat::_secondsToString($progress['spent_seconds']));
             }
             // fallthrough
         // fallthrough
         case 'exc':
         case 'tst':
         case 'crs':
         case 'sahs':
         case 'grp':
             // display status as image
             include_once "./Services/Tracking/classes/class.ilLearningProgressBaseGUI.php";
             $status = $this->__readStatus($item_id, $user_id);
             $status_path = ilLearningProgressBaseGUI::_getImagePathForStatus($status);
             $status_text = ilLearningProgressBaseGUI::_getStatusText($status);
             $info->addProperty($this->lng->txt('trac_status'), ilUtil::img($status_path, $status_text) . " " . $status_text);
             // #15334 - see ilLPTableBaseGUI::isPercentageAvailable()
             $mode = $olp->getCurrentMode();
             if (in_array($mode, array(ilLPObjSettings::LP_MODE_TLT, ilLPObjSettings::LP_MODE_VISITS, ilLPObjSettings::LP_MODE_SCORM, ilLPObjSettings::LP_MODE_TEST_PASSED))) {
                 include_once 'Services/Tracking/classes/class.ilLPStatus.php';
                 $perc = ilLPStatus::_lookupPercentage($item_id, $user_id);
                 $info->addProperty($this->lng->txt('trac_percentage'), (int) $perc . "%");
             }
             break;
     }
     include_once 'Services/Tracking/classes/class.ilLPMarks.php';
     if (strlen($mark = ilLPMarks::_lookupMark($user_id, $item_id))) {
         $info->addProperty($this->lng->txt('trac_mark'), $mark);
     }
     if (strlen($comment = ilLPMarks::_lookupComment($user_id, $item_id))) {
         $info->addProperty($this->lng->txt('trac_comment'), $comment);
     }
 }
 protected function fillRowCSV($a_csv, $a_set)
 {
     $a_csv->addColumn($this->lng->txt($a_set["type"]));
     $a_csv->addColumn($a_set["title"]);
     $a_csv->addColumn(ilLearningProgressBaseGUI::_getStatusText($a_set["status"]));
     ilDatePresentation::setUseRelativeDates(false);
     $a_csv->addColumn(ilDatePresentation::formatDate(new ilDateTime($a_set['status_changed'], IL_CAL_DATETIME)));
     ilDatePresentation::resetToDefaults();
     $a_csv->addColumn(sprintf("%d%%", $a_set["percentage"]));
     $a_csv->addColumn($a_set["mark"]);
     $a_csv->addColumn($a_set["comment"]);
     $a_csv->addColumn(ilLPObjSettings::_mode2Text($a_set["u_mode"]));
     /*
     // path
     $path = $this->buildPath($a_set["ref_ids"]);
     if($path)
     {
     	$col = 7;
     	foreach($path as $path_item)
     	{
     		$a_csv->addColumn(strip_tags($path_item));
     		$col++;
     	}
     }
     */
     $a_csv->addRow();
 }
 protected function parseValue($id, $value, $type)
 {
     global $lng;
     // get rid of aggregation
     $pos = strrpos($id, "_");
     if ($pos !== false) {
         $function = strtoupper(substr($id, $pos + 1));
         if (in_array($function, array("MIN", "MAX", "SUM", "AVG", "COUNT"))) {
             $id = substr($id, 0, $pos);
         }
     }
     if (trim($value) == "" && $id != "status") {
         if ($id == "title" && get_class($this) != "ilTrObjectUsersPropsTableGUI" && get_class($this) != "ilTrMatrixTableGUI") {
             return "--" . $lng->txt("none") . "--";
         }
         return " ";
     }
     switch ($id) {
         case "first_access":
         case "create_date":
         case 'status_changed':
             $value = ilDatePresentation::formatDate(new ilDateTime($value, IL_CAL_DATETIME));
             break;
         case "last_access":
             $value = ilDatePresentation::formatDate(new ilDateTime($value, IL_CAL_UNIX));
             break;
         case "birthday":
             $value = ilDatePresentation::formatDate(new ilDate($value, IL_CAL_DATE));
             break;
         case "spent_seconds":
             if (in_array($type, array("exc"))) {
                 $value = "-";
             } else {
                 include_once "./Services/Utilities/classes/class.ilFormat.php";
                 $value = ilFormat::_secondsToString($value, $value < 3600 ? true : false);
                 // #14858
             }
             break;
         case "percentage":
             /* :TODO:
             			if(in_array(strtolower($this->status_class),
             					  array("illpstatusmanual", "illpstatusscormpackage", "illpstatustestfinished")) ||
             			$type == "exc"))
             			*/
             if (false) {
                 $value = "-";
             } else {
                 $value = $value . "%";
             }
             break;
         case "mark":
             if (in_array($type, array("lm", "dbk"))) {
                 $value = "-";
             }
             break;
         case "gender":
             $value = $lng->txt("gender_" . $value);
             break;
         case "status":
             include_once "./Services/Tracking/classes/class.ilLearningProgressBaseGUI.php";
             $path = ilLearningProgressBaseGUI::_getImagePathForStatus($value);
             $text = ilLearningProgressBaseGUI::_getStatusText($value);
             $value = ilUtil::img($path, $text);
             break;
         case "language":
             $lng->loadLanguageModule("meta");
             $value = $lng->txt("meta_l_" . $value);
             break;
         case "sel_country":
             $value = $lng->txt("meta_c_" . $value);
             break;
     }
     return $value;
 }
 /**
  * Export selected user tracking data
  * @global ilDB $ilDB
  * @global ilObjUser $ilUser
  * @param bool $a_all
  * @param array $a_users
  */
 public function exportSelected($a_all, $a_users = array())
 {
     global $ilDB, $ilUser;
     include_once './Modules/ScormAicc/classes/class.ilSCORMTrackingItems.php';
     include_once "./Services/Tracking/classes/class.ilLearningProgressBaseGUI.php";
     include_once './Services/PrivacySecurity/classes/class.ilPrivacySettings.php';
     $privacy = ilPrivacySettings::_getInstance();
     $allowExportPrivacy = $privacy->enabledExportSCORM();
     $csv = "";
     $query = 'SELECT * FROM sahs_user WHERE obj_id = %s';
     if (count($a_users) > 0) {
         $query .= ' AND ' . $ilDB->in('user_id', $a_users, false, 'integer');
     }
     $res = $ilDB->queryF($query, array('integer'), array($this->getId()));
     while ($data = $ilDB->fetchAssoc($res)) {
         $csv = $csv . $data["obj_id"] . ";\"" . $this->getTitle() . "\"" . ";" . $data["module_version"] . ";\"" . implode("\";\"", ilSCORMTrackingItems::userDataArrayForExport($data["user_id"], $allowExportPrivacy)) . "\"" . ";\"" . $data["last_access"] . "\"" . ";\"" . ilLearningProgressBaseGUI::__readStatus($data["obj_id"], $data["user_id"]) . "\"" . ";" . $data["package_attempts"] . ";" . $data["percentage_completed"] . ";" . $data["sco_total_time_sec"] . "\n";
     }
     $udh = ilSCORMTrackingItems::userDataHeaderForExport();
     $header = "LearningModuleId;LearningModuleTitle;LearningModuleVersion;" . str_replace(',', ';', $udh["cols"]) . ";" . "LastAccess;Status;Attempts;percentageCompletedSCOs;SumTotal_timeSeconds\n";
     $this->sendExportFile($header, $csv);
 }
 function getGraph(array $a_graph_items)
 {
     global $lng;
     $a_graph_items = array(array_pop($a_graph_items));
     include_once "Services/Chart/classes/class.ilChart.php";
     $chart = new ilChart("objstlp", 700, 500);
     $legend = new ilChartLegend();
     $chart->setLegend($legend);
     // needed for correct stacking
     $custom_order = array(ilLPStatus::LP_STATUS_IN_PROGRESS_NUM => array("#f7d408", "#fffa00"), ilLPStatus::LP_STATUS_FAILED_NUM => array("#cf0202", "#f15b5b"), ilLPStatus::LP_STATUS_COMPLETED_NUM => array("#17aa0e", "#6ce148"), ilLPStatus::LP_STATUS_NOT_ATTEMPTED_NUM => array("#a4a4a4", "#c4c4c4"));
     $chart->setColors(array());
     $max_value = 0;
     foreach ($this->chart_data as $object_id => $days) {
         if (in_array($object_id, $a_graph_items)) {
             $series = array();
             foreach ($custom_order as $status => $colors) {
                 /*
                 if(strpos($this->filter["yearmonth"], "-") === false)
                 {
                 	$series[$status] = new ilChartData("lines");
                 	$series[$status]->setLineSteps(true);
                 }
                 else
                 {						
                 	$series[$status] = new ilChartData("bars");
                 	$series[$status]->setBarOptions(0.75);
                 	$series[$status]->setFill(true, $colors[1]);
                 }										
                 $series[$status]->setStackingId($object_id);					
                 */
                 $series[$status] = new ilChartData("lines");
                 $series[$status]->setLabel(ilLearningProgressBaseGUI::_getStatusText($status));
                 $chart_colors[] = $colors[0];
             }
             $chart->setColors($chart_colors);
             if (strpos($this->filter["yearmonth"], "-") === false) {
                 $x_axis = $this->lng->txt("month");
                 $counter = 0;
                 foreach (array_keys($this->getMonthsYear($this->filter["yearmonth"])) as $month) {
                     for ($loop = 1; $loop < 32; $loop++) {
                         $item_day = $month . "-" . str_pad($loop, 2, "0", STR_PAD_LEFT);
                         foreach (array_keys($custom_order) as $status) {
                             if (isset($days[$item_day])) {
                                 // as there is only 1 entry per day, avg == sum
                                 $value = (int) $days[$item_day][$this->status_map[$status] . "_avg"];
                             } else {
                                 $value = 0;
                             }
                             $max_value = max($max_value, $value);
                             $value = $this->anonymizeValue($value, true);
                             $series[$status]->addPoint($counter, $value);
                         }
                         $counter++;
                     }
                 }
             } else {
                 $x_axis = $this->lng->txt("day");
                 for ($loop = 1; $loop < 32; $loop++) {
                     foreach (array_keys($custom_order) as $status) {
                         if (isset($days[$loop])) {
                             // as there is only 1 entry per day, avg == sum
                             $value = (int) $days[$loop][$this->status_map[$status] . "_avg"];
                         } else {
                             $value = 0;
                         }
                         $max_value = max($max_value, $value);
                         $value = $this->anonymizeValue($value, true);
                         $series[$status]->addPoint($loop, $value);
                     }
                 }
             }
             foreach (array_keys($custom_order) as $status) {
                 $chart->addData($series[$status]);
             }
         }
     }
     $value_ticks = $this->buildValueScale($max_value, true);
     $labels = array();
     if (strpos($this->filter["yearmonth"], "-") === false) {
         $counter = 0;
         foreach ($this->getMonthsYear($this->filter["yearmonth"], true) as $caption) {
             $labels[$counter] = $caption;
             $counter += 31;
         }
     } else {
         for ($loop = 1; $loop < 32; $loop++) {
             $labels[$loop] = $loop . ".";
         }
     }
     $chart->setTicks($labels, $value_ticks, true);
     return $chart->getHTML();
 }
 protected function fillRowCSV($a_csv, $a_set)
 {
     $a_csv->addColumn($a_set["login"]);
     foreach ($this->getSelectedColumns() as $c) {
         switch ($c) {
             case substr($c, 0, 4) == "obj_":
                 $obj_id = substr($c, 4);
                 $val = ilLearningProgressBaseGUI::_getStatusText((int) $a_set[$c]);
                 $a_csv->addColumn($val);
                 if (is_array($this->perc_map) && $this->perc_map[$obj_id]) {
                     $perc = (int) $a_set[$c . "_perc"];
                     if (!$perc) {
                         $perc = null;
                     }
                     $a_csv->addColumn($perc);
                 }
                 break;
             case substr($c, 0, 6) == "objtv_":
             case substr($c, 0, 7) == "objsco_":
             case substr($c, 0, 7) == "objsub_":
                 $val = ilLearningProgressBaseGUI::_getStatusText((int) $a_set[$c]);
                 $a_csv->addColumn($val);
                 break;
                 /* #14142
                 			case "last_access":
                 			case "spent_seconds":
                 			case "status_changed":				 
                 			*/
             /* #14142
             			case "last_access":
             			case "spent_seconds":
             			case "status_changed":				 
             			*/
             default:
                 $val = $this->parseValue($c, $a_set[$c], "user");
                 $a_csv->addColumn($val);
                 break;
         }
     }
     $a_csv->addRow();
 }
 protected function fillHeaderCSV($a_csv)
 {
     $a_csv->addColumn($this->lng->txt("title"));
     $labels = $this->getSelectableColumns();
     foreach ($this->getSelectedColumns() as $c) {
         $label = $labels[$c]["txt"];
         $label = str_replace("&#216;", $this->lng->txt("trac_average"), $label);
         $label = str_replace("&#8721;", $this->lng->txt("trac_sum"), $label);
         if (!$this->isArrayColumn($c)) {
             $a_csv->addColumn($label);
         } else {
             if ($c != "status") {
                 $a_csv->addColumn($label . " #1");
                 $a_csv->addColumn($label . " #1");
                 $a_csv->addColumn($label . " #1 %");
                 $a_csv->addColumn($label . " #2");
                 $a_csv->addColumn($label . " #2");
                 $a_csv->addColumn($label . " #2 %");
                 $a_csv->addColumn($label . " #3");
                 $a_csv->addColumn($label . " #3");
                 $a_csv->addColumn($label . " #3 %");
                 $a_csv->addColumn($label . " " . $this->lng->txt("trac_others"));
                 $a_csv->addColumn($label . " " . $this->lng->txt("trac_others"));
                 $a_csv->addColumn($label . " " . $this->lng->txt("trac_others") . " %");
             } else {
                 // build status to image map
                 include_once "./Services/Tracking/classes/class.ilLearningProgressBaseGUI.php";
                 include_once "./Services/Tracking/classes/class.ilLPStatus.php";
                 $valid_status = array(ilLPStatus::LP_STATUS_NOT_ATTEMPTED_NUM, ilLPStatus::LP_STATUS_IN_PROGRESS_NUM, ilLPStatus::LP_STATUS_COMPLETED_NUM, ilLPStatus::LP_STATUS_FAILED_NUM);
                 foreach ($valid_status as $status) {
                     $text = ilLearningProgressBaseGUI::_getStatusText($status);
                     $a_csv->addColumn($text);
                     $a_csv->addColumn($text . " %");
                 }
             }
         }
     }
     $a_csv->addRow();
 }
 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();
     }
 }
 function __appendLPDetails(&$info, $item_id, $user_id)
 {
     global $ilObjDataCache;
     $type = $ilObjDataCache->lookupType($item_id);
     // Section learning_progress
     $info->addSection($this->lng->txt('trac_learning_progress'));
     switch ($type) {
         case 'lm':
         case 'htlm':
             include_once 'Services/Tracking/classes/class.ilLearningProgress.php';
             $progress = ilLearningProgress::_getProgress($user_id, $item_id);
             if ($progress['access_time']) {
                 $info->addProperty($this->lng->txt('last_access'), ilDatePresentation::formatDate(new ilDateTime($progress['access_time'], IL_CAL_DATETIME)));
             } else {
                 $info->addProperty($this->lng->txt('last_access'), $this->lng->txt('trac_not_accessed'));
             }
             $info->addProperty($this->lng->txt('trac_visits'), (int) $progress['visits']);
             if ($type == 'lm') {
                 $info->addProperty($this->lng->txt('trac_spent_time'), ilFormat::_secondsToString($progress['spent_seconds']));
             }
             // display status as image
             include_once "./Services/Tracking/classes/class.ilLearningProgressBaseGUI.php";
             $status = $this->__readStatus($item_id, $user_id);
             $status_path = ilLearningProgressBaseGUI::_getImagePathForStatus($status);
             $status_text = ilLearningProgressBaseGUI::_getStatusText($status);
             $info->addProperty($this->lng->txt('trac_status'), ilUtil::img($status_path, $status_text) . " " . $status_text);
             break;
         case 'exc':
         case 'tst':
         case 'crs':
         case 'sahs':
         case 'grp':
             // display status as image
             include_once "./Services/Tracking/classes/class.ilLearningProgressBaseGUI.php";
             $status = $this->__readStatus($item_id, $user_id);
             $status_path = ilLearningProgressBaseGUI::_getImagePathForStatus($status);
             $status_text = ilLearningProgressBaseGUI::_getStatusText($status);
             $info->addProperty($this->lng->txt('trac_status'), ilUtil::img($status_path, $status_text) . " " . $status_text);
             break;
     }
     include_once 'Services/Tracking/classes/class.ilLPMarks.php';
     if (strlen($mark = ilLPMarks::_lookupMark($user_id, $item_id))) {
         $info->addProperty($this->lng->txt('trac_mark'), $mark);
     }
     if (strlen($comment = ilLPMarks::_lookupComment($user_id, $item_id))) {
         $info->addProperty($this->lng->txt('trac_comment'), $comment);
     }
 }
 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());
 }
 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();
     }
 }
 function ilLMStatisticsGUI($a_mode, $a_ref_id)
 {
     parent::ilLearningProgressBaseGUI($a_mode, $a_ref_id);
     $this->lm_statistics = new ilLMStatistics($this->obj_id);
 }
 function ilLearningProgressGUI($a_mode, $a_ref_id = 0, $a_user_id = 0)
 {
     parent::ilLearningProgressBaseGUI($a_mode, $a_ref_id, $a_user_id);
 }
 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]);
     }
 }
 protected function fillRowCSV($a_csv, $a_set)
 {
     $a_csv->addColumn($a_set["login"]);
     foreach ($this->getSelectedColumns() as $c) {
         switch ($c) {
             case "last_access":
             case "spent_seconds":
             case "status_changed":
                 $val = $this->parseValue($c, $a_set[$c], "user");
                 break;
             case substr($c, 0, 4) == "obj_":
                 $obj_id = substr($c, 4);
                 $val = ilLearningProgressBaseGUI::_getStatusText((int) $a_set["objects"][$obj_id]["status"]);
                 break;
             case substr($c, 0, 6) == "objtv_":
             case substr($c, 0, 7) == "objsco_":
                 $obj_id = $c;
                 $val = ilLearningProgressBaseGUI::_getStatusText((int) $a_set["objects"][$obj_id]["status"]);
                 break;
         }
         $a_csv->addColumn($val);
     }
     $a_csv->addRow();
 }
 protected function fillRowCSV($a_csv, $a_set)
 {
     $a_csv->addColumn($this->lng->txt($a_set["type"]));
     $a_csv->addColumn($a_set["title"]);
     foreach ($this->getSelectedColumns() as $c) {
         if ($c != 'status') {
             $val = $this->parseValue($c, $a_set[$c], "user");
         } else {
             $val = ilLearningProgressBaseGUI::_getStatusText((int) $a_set[$c]);
         }
         $a_csv->addColumn($val);
     }
     $a_csv->addRow();
 }
 public static function preloadListGUIData($a_obj_ids)
 {
     global $ilDB, $ilUser, $lng;
     $res = array();
     include_once "Services/Tracking/classes/class.ilObjUserTracking.php";
     if ($ilUser->getId() != ANONYMOUS_USER_ID && ilObjUserTracking::_enabledLearningProgress() && ilObjUserTracking::_hasLearningProgressLearner() && ilObjUserTracking::_hasLearningProgressListGUI()) {
         include_once "Services/Object/classes/class.ilObjectLP.php";
         // validate objects
         $valid = array();
         $existing = ilLPObjSettings::_lookupDBModeForObjects($a_obj_ids);
         foreach ($existing as $obj_id => $obj_mode) {
             if ($obj_mode != ilLPObjSettings::LP_MODE_DEACTIVATED) {
                 $valid[$obj_id] = $obj_id;
             }
         }
         if (sizeof($existing) != sizeof($a_obj_ids)) {
             // missing objects (default mode)
             foreach (array_diff($a_obj_ids, $existing) as $obj_id) {
                 $olp = ilObjectLP::getInstance($obj_id);
                 $mode = $olp->getCurrentMode();
                 if ($mode == ilLPObjSettings::LP_MODE_DEACTIVATED) {
                     // #11141
                     unset($valid[$obj_id]);
                 } else {
                     if ($mode != ilLPObjSettings::LP_MODE_UNDEFINED) {
                         $valid[$obj_id] = $obj_id;
                     }
                 }
             }
             unset($existing);
         }
         $valid = array_values($valid);
         // get user lp data
         $sql = "SELECT status, status_dirty, obj_id FROM ut_lp_marks" . " WHERE " . $ilDB->in("obj_id", $valid, "", "integer") . " AND usr_id = " . $ilDB->quote($ilUser->getId(), "integer");
         $set = $ilDB->query($sql);
         while ($row = $ilDB->fetchAssoc($set)) {
             if (!$row["status_dirty"]) {
                 $res[$row["obj_id"]] = $row["status"];
             } else {
                 $res[$row["obj_id"]] = self::_lookupStatus($row["obj_id"], $ilUser->getId());
             }
         }
         // process missing user entries (same as dirty entries, see above)
         foreach ($valid as $obj_id) {
             if (!isset($res[$obj_id])) {
                 $res[$obj_id] = self::_lookupStatus($obj_id, $ilUser->getId());
                 if ($res[$obj_id] === null) {
                     $res[$obj_id] = self::LP_STATUS_NOT_ATTEMPTED_NUM;
                 }
             }
         }
         // value to icon
         $lng->loadLanguageModule("trac");
         include_once "./Services/Tracking/classes/class.ilLearningProgressBaseGUI.php";
         foreach ($res as $obj_id => $status) {
             $path = ilLearningProgressBaseGUI::_getImagePathForStatus($status);
             $text = ilLearningProgressBaseGUI::_getStatusText($status);
             $res[$obj_id] = ilUtil::img($path, $text);
         }
     }
     self::$list_gui_cache = $res;
 }
 function details()
 {
     global $ilToolbar, $ilCtrl, $rbacsystem;
     // Show back button to crs if called from crs. Otherwise if called from personal desktop or administration
     // show back to list
     if ((int) $_GET['crs_id']) {
         $this->ctrl->setParameter($this, 'details_id', (int) $_GET['crs_id']);
         $ilToolbar->addButton($this->lng->txt('trac_view_crs'), $this->ctrl->getLinkTarget($this, 'details'));
     } elseif ($this->getMode() == self::LP_CONTEXT_PERSONAL_DESKTOP or $this->getMode() == self::LP_CONTEXT_ADMINISTRATION or $this->getMode() == self::LP_CONTEXT_USER_FOLDER) {
         $ilToolbar->addButton($this->lng->txt('trac_view_list'), $this->ctrl->getLinkTarget($this, 'show'));
     }
     $this->tpl->addBlockFile('ADM_CONTENT', 'adm_content', 'tpl.lp_progress_container.html', 'Services/Tracking');
     $olp = ilObjectLP::getInstance($this->details_obj_id);
     $collection = $olp->getCollectionInstance();
     include_once "./Services/InfoScreen/classes/class.ilInfoScreenGUI.php";
     $info = new ilInfoScreenGUI($this);
     $info->setFormAction($ilCtrl->getFormAction($this));
     $this->__appendUserInfo($info, $this->tracked_user);
     $this->__showObjectDetails($info, $this->details_obj_id, false);
     // START PATCH RUBRIC CPKN 2016
     include_once './Services/Tracking/classes/rubric/class.ilLPRubricGrade.php';
     include_once './Services/Tracking/classes/rubric/class.ilLPRubricGradeGUI.php';
     //if the user is viewing history show the old status/mark/etc.
     if ($olp->getCurrentMode() == 92 && $_REQUEST['grader_history'] !== 'current' && !is_null($_REQUEST['grader_history'])) {
         $marks = ilLPRubricGrade::_lookupRubricHistoryLP($_REQUEST['grader_history']);
         include_once "./Services/Tracking/classes/class.ilLearningProgressBaseGUI.php";
         $status_path = ilLearningProgressBaseGUI::_getImagePathForStatus($marks['status']);
         $status_text = ilLearningProgressBaseGUI::_getStatusText($marks['status']);
         $info->addSection($this->lng->txt("trac_progress") . ": " . ilObject::_lookupTitle($this->details_obj_id));
         $info->addProperty($this->lng->txt('trac_mode'), $olp->getModeText($olp->getCurrentMode()));
         $info->addProperty($this->lng->txt('trac_status'), ilUtil::img($status_path, $status_text) . " " . $status_text);
         $info->addProperty($this->lng->txt('trac_mark'), $marks['mark']);
         $info->addProperty($this->lng->txt('trac_comment'), $marks['comments']);
     } else {
         $this->__appendLPDetails($info, $this->details_obj_id, $this->tracked_user->getId());
     }
     // END PATCH RUBRIC CPKN 2016
     // Finally set template variable
     $this->tpl->setVariable("LM_INFO", $info->getHTML());
     include_once './Services/Object/classes/class.ilObjectLP.php';
     if ($collection) {
         $obj_ids = array();
         foreach ($collection->getItems() as $item_id) {
             if ($collection instanceof ilLPCollectionOfRepositoryObjects) {
                 $obj_ids[ilObject::_lookupObjectId($item_id)] = array($item_id);
             } else {
                 $obj_ids[] = $item_id;
             }
         }
     }
     // #15247
     if (sizeof($obj_ids)) {
         // seems obsolete
         $personal_only = !$rbacsystem->checkAccess('read_learning_progress', $this->getRefId());
         include_once "./Services/Tracking/classes/repository_statistics/class.ilLPProgressTableGUI.php";
         $lp_table = new ilLPProgressTableGUI($this, "details", $this->tracked_user, $obj_ids, true, $this->details_mode, $personal_only, $this->details_obj_id, $this->details_id);
         $this->tpl->setVariable("LP_OBJECTS", $lp_table->getHTML());
     }
     $this->tpl->setVariable("LEGEND", $this->__getLegendHTML());
     // START PATCH RUBRIC CPKN 2015
     if ($olp->getCurrentMode() == ilLPObjSettings::LP_MODE_RUBRIC) {
         $rubricObj = new ilLPRubricGrade($this->getObjId());
         $rubricGui = new ilLPRubricGradeGUI();
         $a_user = ilObjectFactory::getInstanceByObjId($_SESSION['AccountId']);
         if ($rubricObj->objHasRubric() && $rubricObj->isRubricComplete()) {
             $rubricGui->setUserHistoryId($_REQUEST['grader_history']);
             $rubricGui->setUserHistory($rubricObj->getUserHistory($_SESSION['AccountId']));
             $rubricGui->setRubricData($rubricObj->load());
             $rubricGui->setUserData($rubricObj->getRubricUserGradeData($_SESSION['AccountId'], $_REQUEST['grader_history']));
             $rubricGui->setRubricComment($rubricObj->getRubricComment($_SESSION['AccountId'], $_REQUEST['grader_history']));
             $this->tpl->setVariable("LP_OBJECTS", $rubricGui->getStudentViewHTML($this->ctrl->getFormAction($this), $a_user->getFullname(), $_SESSION['AccountId']));
         }
     }
     // END PATCH RUBRIC CPKN 2015
 }
 function ilLPListOfSettingsGUI($a_mode, $a_ref_id)
 {
     parent::ilLearningProgressBaseGUI($a_mode, $a_ref_id);
     $this->obj_settings = new ilLPObjSettings($this->getObjId());
 }