function getItems() { include_once "Services/Tracking/classes/class.ilTrQuery.php"; $data = ilTrQuery::getObjectStatisticsMonthlySummary(); // #11855 foreach ($data as $idx => $item) { $data[$idx]["id"] = $item["month"]; $data[$idx]["month"] = substr($item["month"], 0, 4) . "-" . str_pad(substr($item["month"], 5), 2, "0", STR_PAD_LEFT); } $this->setData($data); }
public function parse($userSelected, $report, $reports) { global $ilCtrl, $lng; $lng->loadLanguageModule("scormtrac"); $this->form = new ilPropertyFormGUI(); $this->form->setFormAction($ilCtrl->getFormAction($this->parent_obj)); $options = array("all" => $lng->txt("all")); include_once "Services/Tracking/classes/class.ilTrQuery.php"; $users = ilTrQuery::getParticipantsForObject($this->parent_obj->object->ref_id); include_once './Services/PrivacySecurity/classes/class.ilPrivacySettings.php'; $privacy = ilPrivacySettings::_getInstance(); $allowExportPrivacy = $privacy->enabledExportSCORM(); //$users = $this->parent_obj->object->getTrackedUsers(""); foreach ($users as $user) { if (ilObject::_exists($user) && ilObject::_lookUpType($user) == 'usr') { if ($allowExportPrivacy == true) { $e_user = new ilObjUser($user); $options[$user] = $e_user->getLastname() . ", " . $e_user->getFirstname(); } else { $options[$user] = 'User Id: ' . $user; } } } $si = new ilSelectInputGUI($lng->txt("user"), "userSelected"); $si->setOptions($options); $si->setValue($userSelected); $this->form->addItem($si); $options = array("choose" => $lng->txt("please_choose")); for ($i = 0; $i < count($reports); $i++) { $options[$reports[$i]] = $lng->txt(strtolower($reports[$i])); } $si = new ilSelectInputGUI($lng->txt("report"), "report"); $si->setOptions($options); $si->setValue($report); $this->form->addItem($si); $this->form->addCommandButton($this->parent_cmd, $lng->txt("apply_filter")); }
/** * Get user items */ function getItems() { global $lng; $this->determineOffsetAndOrder(); include_once "./Services/Tracking/classes/class.ilTrQuery.php"; $additional_fields = $this->getSelectedColumns(); // only if object is [part of] course/group $check_agreement = false; if ($this->in_course) { // privacy (if course agreement is activated) include_once "Services/PrivacySecurity/classes/class.ilPrivacySettings.php"; $privacy = ilPrivacySettings::_getInstance(); if ($privacy->courseConfirmationRequired()) { $check_agreement = $this->in_course; } } else { if ($this->in_group) { // privacy (if group agreement is activated) include_once "Services/PrivacySecurity/classes/class.ilPrivacySettings.php"; $privacy = ilPrivacySettings::_getInstance(); if ($privacy->groupConfirmationRequired()) { $check_agreement = $this->in_group; } } } $tr_data = ilTrQuery::getUserDataForObject($this->ref_id, ilUtil::stripSlashes($this->getOrderField()), ilUtil::stripSlashes($this->getOrderDirection()), ilUtil::stripSlashes($this->getOffset()), ilUtil::stripSlashes($this->getLimit()), $this->getCurrentFilter(), $additional_fields, $check_agreement, $this->user_fields); if (count($tr_data["set"]) == 0 && $this->getOffset() > 0) { $this->resetOffset(); $tr_data = ilTrQuery::getUserDataForObject($this->ref_id, ilUtil::stripSlashes($this->getOrderField()), ilUtil::stripSlashes($this->getOrderDirection()), ilUtil::stripSlashes($this->getOffset()), ilUtil::stripSlashes($this->getLimit()), $this->getCurrentFilter(), $additional_fields, $check_agreement, $this->user_fields); } $this->setMaxCount($tr_data["cnt"]); $this->setData($tr_data["set"]); }
protected function gatherTypesData() { global $ilDB; $count = 0; include_once "Services/Tracking/classes/class.ilTrQuery.php"; $data = ilTrQuery::getObjectTypeStatistics(); foreach ($data as $type => $item) { // only save once per day $ilDB->manipulate("DELETE FROM obj_type_stat WHERE" . " type = " . $ilDB->quote($type, "text") . " AND fulldate = " . $ilDB->quote(date("Ymd", $this->date), "integer")); $set = array("type" => array("text", $type), "yyyy" => array("integer", date("Y", $this->date)), "mm" => array("integer", date("m", $this->date)), "dd" => array("integer", date("d", $this->date)), "fulldate" => array("integer", date("Ymd", $this->date)), "cnt_references" => array("integer", (int) $item["references"]), "cnt_objects" => array("integer", (int) $item["objects"]), "cnt_deleted" => array("integer", (int) $item["deleted"])); $ilDB->insert("obj_type_stat", $set); $count++; } return $count; }
/** * Show tracking table * @global ilTabs $ilTabs * $global ilToolbar $ilToolbar */ protected function showTrackingItems() { global $ilTabs; ilObjSCORMLearningModuleGUI::setSubTabs(); $ilTabs->setTabActive('cont_tracking_data'); $ilTabs->setSubTabActive('cont_tracking_byuser'); $reports = array('exportSelectedSuccess', 'exportSelectedCore', 'exportSelectedInteractions', 'exportSelectedObjectives', 'exportSelectedRaw'); $userSelected = "all"; if (isset($_GET["userSelected"])) { $userSelected = ilUtil::stripSlashes($_GET["userSelected"]); } if (isset($_POST["userSelected"])) { $userSelected = ilUtil::stripSlashes($_POST["userSelected"]); } $this->ctrl->setParameter($this, 'userSelected', $userSelected); $report = "choose"; if (isset($_GET["report"])) { $report = ilUtil::stripSlashes($_GET["report"]); } if (isset($_POST["report"])) { $report = ilUtil::stripSlashes($_POST["report"]); } $this->ctrl->setParameter($this, 'report', $report); include_once './Modules/ScormAicc/classes/class.ilSCORMTrackingItemsPerUserFilterGUI.php'; $filter = new ilSCORMTrackingItemsPerUserFilterGUI($this, 'showTrackingItems'); $filter->parse($userSelected, $report, $reports); if ($report == "choose") { $this->tpl->setContent($filter->form->getHTML()); } else { $usersSelected = array(); if ($userSelected != "all") { $usersSelected[] = $userSelected; } else { include_once "Services/Tracking/classes/class.ilTrQuery.php"; $users = ilTrQuery::getParticipantsForObject($this->ref_id); foreach ($users as $user) { if (ilObject::_exists($user) && ilObject::_lookUpType($user) == 'usr') { $usersSelected[] = $user; } } } $scosSelected = array(); $scos = $this->object->getTrackedItems(); foreach ($scos as $row) { $scosSelected[] = (int) $row->getId(); } //with check for course ... // include_once "Services/Tracking/classes/class.ilTrQuery.php"; // $a_users=ilTrQuery::getParticipantsForObject($this->ref_id); // var_dump($this->object->getTrackedUsers("")); include_once './Modules/ScormAicc/classes/class.ilSCORMTrackingItemsTableGUI.php'; $tbl = new ilSCORMTrackingItemsTableGUI($this->object->getId(), $this, 'showTrackingItems', $usersSelected, $scosSelected, $report); $this->tpl->setContent($filter->form->getHTML() . $tbl->getHTML()); } return true; }
function getItems() { include_once "Services/Tracking/classes/class.ilTrQuery.php"; $res = ilTrQuery::getObjectTypeStatisticsPerMonth($this->filter["aggregation"], $this->filter["year"]); // get plugin titles include_once "./Services/Repository/classes/class.ilRepositoryObjectPluginSlot.php"; $plugins = array(); $plugins = ilRepositoryObjectPluginSlot::addCreatableSubObjects($plugins); $data = array(); foreach ($res as $type => $months) { $data[$type]["type"] = $type; // to enable sorting by title if (array_key_exists($type, $plugins)) { include_once "./Services/Component/classes/class.ilPlugin.php"; $data[$type]["title"] = ilPlugin::lookupTxt("rep_robj", $type, "obj_" . $type); $data[$type]["icon"] = ilObject::_getIcon("", "tiny", $type); } else { $data[$type]["title"] = $this->lng->txt("objs_" . $type); $data[$type]["icon"] = ilUtil::getTypeIconPath($type, null, "tiny"); } foreach ($months as $month => $row) { $value = $row[$this->filter["measure"]]; $data[$type]["month_" . $month] = $value; } } // add live data if ($this->filter["year"] == date("Y")) { $live = ilTrQuery::getObjectTypeStatistics(); foreach ($live as $type => $item) { $data[$type]["type"] = $type; // to enable sorting by title if (array_key_exists($type, $plugins)) { include_once "./Services/Component/classes/class.ilPlugin.php"; $data[$type]["title"] = ilPlugin::lookupTxt("rep_robj", $type, "obj_" . $type); $data[$type]["icon"] = ilObject::_getIcon("", "tiny", $type); } else { $data[$type]["title"] = $this->lng->txt("objs_" . $type); $data[$type]["icon"] = ilUtil::getTypeIconPath($type, null, "tiny"); } $value = $item[$this->filter["measure"]]; $data[$type]["month_live"] = $value; } } $this->setData($data); }
function getItems() { $data = array(); $objects = $this->searchObjects($this->getCurrentFilter(true), "read"); if ($objects) { include_once "Services/Tracking/classes/class.ilTrQuery.php"; $yearmonth = explode("-", $this->filter["yearmonth"]); if (sizeof($yearmonth) == 1) { $stat_objects = ilTrQuery::getObjectDailyStatistics($objects, $yearmonth[0]); } else { $stat_objects = ilTrQuery::getObjectDailyStatistics($objects, $yearmonth[0], (int) $yearmonth[1]); } foreach ($stat_objects as $obj_id => $hours) { $data[$obj_id]["obj_id"] = $obj_id; $data[$obj_id]["title"] = ilObject::_lookupTitle($obj_id); foreach ($hours as $hour => $values) { // table data $data[$obj_id]["hour" . floor($hour / 2) * 2] += (int) $values[$this->filter["measure"]]; $data[$obj_id]["sum"] += (int) $values[$this->filter["measure"]]; // graph data $data[$obj_id]["graph"]["hour" . $hour] = $values[$this->filter["measure"]]; } } // add objects with no usage data foreach ($objects as $obj_id => $ref_ids) { if (!isset($data[$obj_id])) { $data[$obj_id]["obj_id"] = $obj_id; $data[$obj_id]["title"] = ilObject::_lookupTitle($obj_id); } } } $this->setData($data); }
/** * Get user items */ function getItems() { global $lng, $tree; $this->determineOffsetAndOrder(); $additional_fields = $this->getSelectedColumns(); include_once "./Services/Tracking/classes/class.ilTrQuery.php"; $tr_data = ilTrQuery::getObjectsDataForUser($this->user_id, $this->obj_id, $this->ref_id, ilUtil::stripSlashes($this->getOrderField()), ilUtil::stripSlashes($this->getOrderDirection()), ilUtil::stripSlashes($this->getOffset()), ilUtil::stripSlashes($this->getLimit()), $this->filter, $additional_fields, $this->filter["view_mode"]); if (count($tr_data["set"]) == 0 && $this->getOffset() > 0) { $this->resetOffset(); $tr_data = ilTrQuery::getObjectsDataForUser($this->user_id, $this->obj_id, $this->ref_id, ilUtil::stripSlashes($this->getOrderField()), ilUtil::stripSlashes($this->getOrderDirection()), ilUtil::stripSlashes($this->getOffset()), ilUtil::stripSlashes($this->getLimit()), $this->filter, $additional_fields, $this->filter["view_mode"]); } $this->setMaxCount($tr_data["cnt"]); if ($this->getOrderField() == "title") { // sort alphabetically, move parent object to 1st position $set = array(); $parent = false; foreach ($tr_data["set"] as $idx => $row) { if ($row['obj_id'] == $this->obj_id) { $parent = $row; } else { if (isset($row["sort_title"])) { $set[strtolower($row["sort_title"]) . "__" . $idx] = $row; } else { $set[strtolower($row["title"]) . "__" . $idx] = $row; } } } unset($tr_data["set"]); if ($this->getOrderDirection() == "asc") { ksort($set); } else { krsort($set); } $set = array_values($set); if ($parent) { array_unshift($set, $parent); } $this->setData($set); } else { $this->setData($tr_data["set"]); } }
function getItems(array $a_user_fields, array $a_privary_fields = null) { include_once "./Services/Tracking/classes/class.ilTrQuery.php"; $collection = ilTrQuery::getObjectIds($this->obj_id, $this->ref_id, true); if ($collection["object_ids"]) { // we need these for the timing warnings $this->ref_ids = $collection["ref_ids"]; // only if object is [part of] course/group $check_agreement = false; if ($this->in_course) { // privacy (if course agreement is activated) include_once "Services/PrivacySecurity/classes/class.ilPrivacySettings.php"; $privacy = ilPrivacySettings::_getInstance(); if ($privacy->courseConfirmationRequired()) { $check_agreement = $this->in_course; } } else { if ($this->in_group) { // privacy (if group agreement is activated) include_once "Services/PrivacySecurity/classes/class.ilPrivacySettings.php"; $privacy = ilPrivacySettings::_getInstance(); if ($privacy->groupConfirmationRequired()) { $check_agreement = $this->in_group; } } } $data = ilTrQuery::getUserObjectMatrix($this->ref_id, $collection["object_ids"], $this->filter["name"], $a_user_fields, $a_privary_fields, $check_agreement); if ($collection["objectives_parent_id"] && $data["users"]) { // sub-items: learning objectives $objectives = ilTrQuery::getUserObjectiveMatrix($collection["objectives_parent_id"], $data["users"]); $this->objective_ids = array(); foreach ($objectives as $user_id => $objectives) { if (isset($data["set"][$user_id])) { foreach ($objectives as $objective_id => $status) { $obj_id = "objtv_" . $objective_id; $data["set"][$user_id][$obj_id] = $status; if (!in_array($obj_id, $this->objective_ids)) { $this->objective_ids[$objective_id] = ilCourseObjective::lookupObjectiveTitle($objective_id); } } } } } // sub-items: SCOs if ($collection["scorm"] && $data["set"]) { $this->sco_ids = array(); foreach (array_keys($data["set"]) as $user_id) { foreach ($collection["scorm"]["scos"] as $sco) { if (!in_array($sco, $this->sco_ids)) { $this->sco_ids[$sco] = $collection["scorm"]["scos_title"][$sco]; } // alex, 5 Nov 2011: we got users being in failed and in // completed status, I changed the setting in: first check failed // then check completed since failed should superseed completed // (before completed has been checked before failed) $status = ilLPStatus::LP_STATUS_NOT_ATTEMPTED_NUM; if (in_array($user_id, $collection["scorm"]["failed"][$sco])) { $status = ilLPStatus::LP_STATUS_FAILED_NUM; } else { if (in_array($user_id, $collection["scorm"]["completed"][$sco])) { $status = ilLPStatus::LP_STATUS_COMPLETED_NUM; } else { if (in_array($user_id, $collection["scorm"]["in_progress"][$sco])) { $status = ilLPStatus::LP_STATUS_IN_PROGRESS_NUM; } } } $obj_id = "objsco_" . $sco; $data["set"][$user_id][$obj_id] = $status; } } } // sub-items: generic, e.g. lm chapter if ($collection["subitems"] && $data["set"]) { foreach (array_keys($data["set"]) as $user_id) { foreach ($collection["subitems"]["items"] as $item_id) { $this->subitem_ids[$item_id] = $collection["subitems"]["item_titles"][$item_id]; $status = ilLPStatus::LP_STATUS_NOT_ATTEMPTED_NUM; if (in_array($user_id, $collection["subitems"]["completed"][$item_id])) { $status = ilLPStatus::LP_STATUS_COMPLETED_NUM; } else { if (is_array($collection["subitems"]["in_progress"]) && in_array($user_id, $collection["subitems"]["in_progress"][$item_id])) { $status = ilLPStatus::LP_STATUS_IN_PROGRESS_NUM; } } $obj_id = "objsub_" . $item_id; $data["set"][$user_id][$obj_id] = $status; } } } // percentage export if ($data["set"]) { $this->perc_map = array(); foreach ($data["set"] as $row) { foreach ($row as $column => $value) { if (substr($column, -5) == "_perc") { if ((int) $value > 0) { $obj_id = explode("_", $column); $obj_id = (int) $obj_id[1]; $this->perc_map[$obj_id] = true; } } } } } $this->setMaxCount($data["cnt"]); $this->setData($data["set"]); return $collection["object_ids"]; } return false; }
function getItems() { $data = array(); $objects = $this->searchObjects($this->getCurrentFilter(true), "read"); if ($objects) { include_once "Services/Tracking/classes/class.ilTrQuery.php"; $yearmonth = explode("-", $this->filter["yearmonth"]); if (sizeof($yearmonth) == 1) { foreach (ilTrQuery::getObjectAccessStatistics($objects, $yearmonth[0]) as $obj_id => $months) { $data[$obj_id]["obj_id"] = $obj_id; $data[$obj_id]["title"] = ilObject::_lookupTitle($obj_id); foreach ($months as $month => $values) { $idx = $yearmonth[0] . "-" . str_pad($month, 2, "0", STR_PAD_LEFT); $data[$obj_id]["month_" . $idx] = (int) $values[$this->filter["measure"]]; $data[$obj_id]["total"] += (int) $values[$this->filter["measure"]]; } } } else { foreach (ilTrQuery::getObjectAccessStatistics($objects, $yearmonth[0], (int) $yearmonth[1]) as $obj_id => $days) { $data[$obj_id]["obj_id"] = $obj_id; $data[$obj_id]["title"] = ilObject::_lookupTitle($obj_id); foreach ($days as $day => $values) { $data[$obj_id]["day_" . $day] = (int) $values[$this->filter["measure"]]; $data[$obj_id]["total"] += (int) $values[$this->filter["measure"]]; } } } // add objects with no usage data foreach (array_keys($objects) as $obj_id) { if (!isset($data[$obj_id])) { $data[$obj_id]["obj_id"] = $obj_id; $data[$obj_id]["title"] = ilObject::_lookupTitle($obj_id); } } } $this->setData($data); }
function getItems() { global $objDefinition; include_once "Services/Tracking/classes/class.ilTrQuery.php"; $res = ilTrQuery::getObjectTypeStatisticsPerMonth($this->filter["aggregation"], $this->filter["year"]); $data = array(); foreach ($res as $type => $months) { // inactive plugins, etc. if (!$objDefinition->getLocation($type)) { continue; } $data[$type]["type"] = $type; // to enable sorting by title if ($objDefinition->isPluginTypeName($type)) { include_once "./Services/Component/classes/class.ilPlugin.php"; $data[$type]["title"] = ilPlugin::lookupTxt("rep_robj", $type, "obj_" . $type); $data[$type]["icon"] = ilObject::_getIcon("", "tiny", $type); } else { $data[$type]["title"] = $this->lng->txt("objs_" . $type); $data[$type]["icon"] = ilUtil::getTypeIconPath($type, null, "tiny"); } foreach ($months as $month => $row) { $value = $row[$this->filter["measure"]]; $data[$type]["month_" . $month] = $value; } } // add live data if ($this->filter["year"] == date("Y")) { $live = ilTrQuery::getObjectTypeStatistics(); foreach ($live as $type => $item) { // inactive plugins, etc. if (!$objDefinition->getLocation($type)) { continue; } $data[$type]["type"] = $type; // to enable sorting by title if ($objDefinition->isPluginTypeName($type)) { include_once "./Services/Component/classes/class.ilPlugin.php"; $data[$type]["title"] = ilPlugin::lookupTxt("rep_robj", $type, "obj_" . $type); $data[$type]["icon"] = ilObject::_getIcon("", "tiny", $type); } else { $data[$type]["title"] = $this->lng->txt("objs_" . $type); $data[$type]["icon"] = ilUtil::getTypeIconPath($type, null, "tiny"); } $value = $item[$this->filter["measure"]]; $data[$type]["month_live"] = $value; } } $this->setData($data); }
function getItems() { global $lng, $tree; // $this->determineOffsetAndOrder(); include_once "./Services/Tracking/classes/class.ilTrQuery.php"; $collection = ilTrQuery::getObjectIds($this->obj_id, $this->ref_id, true); if ($collection["object_ids"]) { // we need these for the timing warnings $this->ref_ids = $collection["ref_ids"]; $data = ilTrQuery::getUserObjectMatrix($this->ref_id, $collection["object_ids"], $this->filter["name"]); if ($collection["objectives_parent_id"] && $data["users"]) { $objectives = ilTrQuery::getUserObjectiveMatrix($collection["objectives_parent_id"], $data["users"]); if ($objectives["cnt"]) { $this->objective_ids = array(); $objective_columns = array(); foreach ($objectives["set"] as $row) { if (isset($data["set"][$row["usr_id"]])) { $obj_id = "objtv_" . $row["obj_id"]; $data["set"][$row["usr_id"]]["objects"][$obj_id] = array("status" => $row["status"]); if (!in_array($obj_id, $this->objective_ids)) { $this->objective_ids[$obj_id] = $row["title"]; } } } } } if ($collection["scorm"] && $data["set"]) { $this->sco_ids = array(); foreach (array_keys($data["set"]) as $user_id) { foreach ($collection["scorm"]["scos"] as $sco) { if (!in_array($sco, $this->sco_ids)) { $this->sco_ids[$sco] = $collection["scorm"]["scos_title"][$sco]; } // alex, 5 Nov 2011: we got users being in failed and in // completed status, I changed the setting in: first check failed // then check completed since failed should superseed completed // (before completed has been checked before failed) $status = LP_STATUS_NOT_ATTEMPTED_NUM; if (in_array($user_id, $collection["scorm"]["failed"][$sco])) { $status = LP_STATUS_FAILED_NUM; } else { if (in_array($user_id, $collection["scorm"]["completed"][$sco])) { $status = LP_STATUS_COMPLETED_NUM; } else { if (in_array($user_id, $collection["scorm"]["in_progress"][$sco])) { $status = LP_STATUS_IN_PROGRESS_NUM; } } } $obj_id = "objsco_" . $sco; $data["set"][$user_id]["objects"][$obj_id] = array("status" => $status); } } } $this->setMaxCount($data["cnt"]); $this->setData($data["set"]); //var_dump($this->sco_ids); return $collection["object_ids"]; } return false; }
/** * Return all Placeholders of Learning Progress data * * @param ilObjCourse $course * @param ilObjUser $user * @return array */ protected function parseLearningProgressPlaceholders(ilObjCourse $course, ilObjUser $user) { $passed_datetime = ilCourseParticipants::getDateTimeOfPassed($course->getId(), $user->getId()); $lp_fields = array('first_access', 'last_access', 'percentage', 'status', 'read_count', 'childs_spent_seconds'); $lp_data = ilTrQuery::getObjectsDataForUser($user->getId(), $course->getId(), $course->getRefId(), '', '', 0, 9999, null, $lp_fields); $lp_avg = $this->buildAvgPercentageOfCourseObjects($lp_data); $lp_crs = array(); $max_last_access = 0; foreach ($lp_data['set'] as $v) { if ($v['type'] == 'crs') { $lp_crs = $v; $lp_crs['first_access'] = strtotime($v['first_access']); // First access is not stored as UNIX timestamp... } if ($v['last_access'] > $max_last_access) { $max_last_access = $v['last_access']; } } $lp_crs['last_access'] = $max_last_access; // calculates spent time different for scorm modules if enabled in config /** @var $cert_def srCertificateDefinition */ $cert_definition = $this->certificate->getDefinition(); if ($cert_definition->getScormTiming()) { $spent_seconds = 0; require_once './Services/Object/classes/class.ilObjectLP.php'; $ilScormLP = ilObjectLP::getInstance($course->getId()); /** * @var $ilLPCollection ilLPCollection */ $ilLPCollection = $ilScormLP->getCollectionInstance(); if ($ilLPCollection instanceof ilLPCollection) { foreach ($ilLPCollection->getItems() as $item) { $spent_seconds += $this->getSpentSeconds(ilObject::_lookupObjectId($item), $user->getId()); } } $lp_crs['childs_spent_seconds'] = $spent_seconds; } $lp_spent_time = $this->buildLpSpentTime($lp_crs); return array('DATE_COMPLETED' => $this->formatDate('DATE_COMPLETED', strtotime($passed_datetime)), 'DATETIME_COMPLETED' => $this->formatDateTime('DATETIME_COMPLETED', strtotime($passed_datetime)), 'LP_FIRST_ACCESS' => $this->formatDateTime('LP_FIRST_ACCESS', (int) $lp_crs['first_access']), 'LP_LAST_ACCESS' => $this->formatDateTime('LP_LAST_ACCESS', (int) $lp_crs['last_access']), 'LP_SPENT_TIME' => $lp_spent_time, 'LP_SPENT_SECONDS' => $lp_crs['childs_spent_seconds'], 'LP_READ_COUNT' => $lp_crs['read_count'], 'LP_STATUS' => $lp_crs['status'], 'LP_AVG_PERCENTAGE' => $lp_avg); }
protected function getCoursesOfUser($a_user_id, $a_add_path = false) { global $tree; // see ilPDSelectedItemsBlockGUI include_once 'Modules/Course/classes/class.ilObjCourseAccess.php'; include_once 'Services/Membership/classes/class.ilParticipants.php'; $items = ilParticipants::_getMembershipByType($a_user_id, 'crs'); $repo_title = $tree->getNodeData(ROOT_FOLDER_ID); $repo_title = $repo_title["title"]; if ($repo_title == "ILIAS") { $repo_title = $this->lng->txt("repository"); } $references = $lp_obj_refs = array(); foreach ($items as $obj_id) { $ref_id = ilObject::_getAllReferences($obj_id); if (is_array($ref_id) && count($ref_id)) { $ref_id = array_pop($ref_id); if (!$tree->isDeleted($ref_id)) { $visible = false; $active = ilObjCourseAccess::_isActivated($obj_id, $visible, false); if ($active && $visible) { $references[$ref_id] = array('ref_id' => $ref_id, 'obj_id' => $obj_id, 'title' => ilObject::_lookupTitle($obj_id)); if ($a_add_path) { $path = array(); foreach ($tree->getPathFull($ref_id) as $item) { $path[] = $item["title"]; } // top level comes first if (sizeof($path) == 2) { $path[0] = 0; } else { $path[0] = 1; } $references[$ref_id]["path_sort"] = implode("__", $path); array_shift($path); array_pop($path); if (!sizeof($path)) { array_unshift($path, $repo_title); } $references[$ref_id]["path"] = implode(" › ", $path); } $lp_obj_refs[$obj_id] = $ref_id; } } } } // get lp data for valid courses if (sizeof($lp_obj_refs)) { // listing the objectives should NOT depend on any LP status / setting include_once 'Modules/Course/classes/class.ilObjCourse.php'; foreach ($lp_obj_refs as $obj_id => $ref_id) { // only if set in DB (default mode is not relevant if (ilObjCourse::_lookupViewMode($obj_id) == IL_CRS_VIEW_OBJECTIVE) { $references[$ref_id]["objectives"] = $this->parseObjectives($obj_id, $a_user_id); } } // LP must be active, personal and not anonymized include_once "Services/Tracking/classes/class.ilObjUserTracking.php"; if (ilObjUserTracking::_enabledLearningProgress() && ilObjUserTracking::_enabledUserRelatedData() && ilObjUserTracking::_hasLearningProgressLearner()) { // see ilLPProgressTableGUI include_once "Services/Tracking/classes/class.ilTrQuery.php"; include_once "Services/Tracking/classes/class.ilLPStatusFactory.php"; $lp_data = ilTrQuery::getObjectsStatusForUser($a_user_id, $lp_obj_refs); foreach ($lp_data as $item) { $ref_id = $item["ref_ids"]; $references[$ref_id]["lp_status"] = $item["status"]; } } } return $references; }
/** * Get timestamp of the last_status according to LP * * @param srCertificate $cert * @return int|null */ protected function getLastLPStatus(srCertificate $cert) { $ref_id = $cert->getDefinition()->getRefId(); $obj_id = ilObject::_lookupObjectId($ref_id); $lp_data = ilTrQuery::getObjectsDataForUser($cert->getUserId(), $obj_id, $ref_id, '', '', 0, 9999, null, array('last_access')); $last_status = null; foreach ($lp_data['set'] as $data) { if ($data['type'] == 'crs') { $last_status = $data['last_access']; break; } } return (int) $last_status; }
protected function getCoursesOfUser($a_user_id) { global $tree; // see ilPDSelectedItemsBlockGUI include_once 'Modules/Course/classes/class.ilObjCourseAccess.php'; include_once 'Services/Membership/classes/class.ilParticipants.php'; $items = ilParticipants::_getMembershipByType($a_user_id, 'crs'); $references = $lp_obj_refs = array(); foreach ($items as $obj_id) { $ref_id = ilObject::_getAllReferences($obj_id); if (is_array($ref_id) && count($ref_id)) { $ref_id = array_pop($ref_id); if (!$tree->isDeleted($ref_id)) { $visible = false; $active = ilObjCourseAccess::_isActivated($obj_id, $visible, false); if ($active && $visible) { $references[$ref_id] = array('ref_id' => $ref_id, 'obj_id' => $obj_id, 'title' => ilObject::_lookupTitle($obj_id)); $lp_obj_refs[$obj_id] = $ref_id; } } } } // get lp data for valid courses if (sizeof($lp_obj_refs)) { // lp must be active, personal and not anonymized include_once "Services/Tracking/classes/class.ilObjUserTracking.php"; if (ilObjUserTracking::_enabledLearningProgress() && ilObjUserTracking::_enabledUserRelatedData() && ilObjUserTracking::_hasLearningProgressLearner()) { // see ilLPProgressTableGUI include_once "Services/Tracking/classes/class.ilTrQuery.php"; include_once "Services/Tracking/classes/class.ilLPStatusFactory.php"; $lp_data = ilTrQuery::getObjectsStatusForUser($a_user_id, $lp_obj_refs); foreach ($lp_data as $item) { $ref_id = $item["ref_ids"]; $references[$ref_id]["lp_status"] = $item["status"]; // add objectives if ($item["u_mode"] == ilLPObjSettings::LP_MODE_OBJECTIVES) { // we need the collection for the correct order include_once "Services/Tracking/classes/collection/class.ilLPCollectionOfObjectives.php"; $coll_objtv = new ilLPCollectionOfObjectives($item["obj_id"], $item["u_mode"]); $coll_objtv = $coll_objtv->getItems(); if ($coll_objtv) { // #13373 $lo_results = $this->parseLOUserResults($item["obj_id"], $a_user_id); $tmp = array(); include_once "Modules/Course/classes/class.ilCourseObjective.php"; foreach ($coll_objtv as $objective_id) { $tmp[$objective_id] = array("id" => $objective_id, "title" => ilCourseObjective::lookupObjectiveTitle($objective_id)); if (array_key_exists($objective_id, $lo_results)) { $lo_result = $lo_results[$objective_id]; $tmp[$objective_id]["result_perc"] = $lo_result["result_perc"]; $tmp[$objective_id]["limit_perc"] = $lo_result["limit_perc"]; $tmp[$objective_id]["status"] = $lo_result["status"]; $tmp[$objective_id]["type"] = $lo_result["type"]; } } // order foreach ($coll_objtv as $objtv_id) { $references[$ref_id]["objectives"][] = $tmp[$objtv_id]; } } } } } } $references = ilUtil::sortArray($references, "title", "ASC"); return $references; }
function getItems() { $obj_ids = $this->obj_ids; if (!$obj_ids && !$this->details) { // restrict courses/groups to objects where current user is member $membership_ids = null; if ($this->filter["type"] == "crs" || $this->filter["type"] == "grp") { include_once "Services/Membership/classes/class.ilParticipants.php"; $membership_ids = ilParticipants::_getMembershipByType($this->tracked_user->getId(), $this->filter["type"]); } if ($membership_ids === null || sizeof($membership_ids)) { $obj_ids = $this->searchObjects($this->getCurrentFilter(true), "read", $membership_ids); } } if ($obj_ids) { include_once "./Services/Tracking/classes/class.ilTrQuery.php"; switch ($this->mode) { case LP_MODE_SCORM: $data = ilTrQuery::getSCOsStatusForUser($this->tracked_user->getId(), $this->parent_obj_id, $obj_ids); break; case LP_MODE_OBJECTIVES: $data = ilTrQuery::getObjectivesStatusForUser($this->tracked_user->getId(), $obj_ids); break; default: $data = ilTrQuery::getObjectsStatusForUser($this->tracked_user->getId(), $obj_ids); foreach ($data as $idx => $item) { if (!$item["status"] && !$this->filter["status"]) { unset($data[$idx]); } else { $data[$idx]["offline"] = ilLearningProgressBaseGUI::isObjectOffline($item["obj_id"], $item["type"]); } } break; } $this->setData($data); } }
/** * Get user items */ function getItems() { global $rbacsystem; $this->determineOffsetAndOrder(); $additional_fields = $this->getSelectedColumns(); include_once "./Services/Tracking/classes/class.ilTrQuery.php"; $tr_data = ilTrQuery::getObjectsDataForUser($this->user_id, $this->obj_id, $this->ref_id, ilUtil::stripSlashes($this->getOrderField()), ilUtil::stripSlashes($this->getOrderDirection()), ilUtil::stripSlashes($this->getOffset()), ilUtil::stripSlashes($this->getLimit()), $this->filter, $additional_fields, $this->filter["view_mode"]); if (count($tr_data["set"]) == 0 && $this->getOffset() > 0) { $this->resetOffset(); $tr_data = ilTrQuery::getObjectsDataForUser($this->user_id, $this->obj_id, $this->ref_id, ilUtil::stripSlashes($this->getOrderField()), ilUtil::stripSlashes($this->getOrderDirection()), ilUtil::stripSlashes($this->getOffset()), ilUtil::stripSlashes($this->getLimit()), $this->filter, $additional_fields, $this->filter["view_mode"]); } // #13807 foreach ($tr_data["set"] as $idx => $row) { if ($row["ref_id"] && !$rbacsystem->checkAccess("read_learning_progress", $row["ref_id"])) { foreach (array_keys($row) as $col_id) { if (!in_array($col_id, array("type", "obj_id", "ref_id", "title", "sort_title"))) { $tr_data["set"][$idx][$col_id] = null; } } $tr_data["set"][$idx]["privacy_conflict"] = true; } } $this->setMaxCount($tr_data["cnt"]); if ($this->getOrderField() == "title") { // sort alphabetically, move parent object to 1st position $set = array(); $parent = false; foreach ($tr_data["set"] as $idx => $row) { if ($row['obj_id'] == $this->obj_id) { $parent = $row; } else { if (isset($row["sort_title"])) { $set[strtolower($row["sort_title"]) . "__" . $idx] = $row; } else { $set[strtolower($row["title"]) . "__" . $idx] = $row; } } } unset($tr_data["set"]); if ($this->getOrderDirection() == "asc") { ksort($set); } else { krsort($set); } $set = array_values($set); if ($parent) { array_unshift($set, $parent); } $this->setData($set); } else { $this->setData($tr_data["set"]); } }
protected function getDetailItems($a_obj_id) { $data = array(); $all_status = array_merge(array("mem_cnt"), $this->status); include_once "Services/Tracking/classes/class.ilTrQuery.php"; foreach (ilTrQuery::getObjectLPStatistics(array($a_obj_id), $this->filter["yearmonth"]) as $item) { $month = "month_" . $item["yyyy"] . "-" . str_pad($item["mm"], 2, "0", STR_PAD_LEFT); foreach ($all_status as $status) { // status-id to field name if ($status != "mem_cnt") { $field = $this->status_map[$status]; } else { $field = $status; } // aggregated fields foreach ($this->types as $type) { $value = $item[$field . "_" . $type]; $idx = $item["yyyy"] . "-" . str_pad($item["mm"], 2, "0", STR_PAD_LEFT); $data[$status . "_" . $type]["month_" . $idx] = $value; } } } // add captions foreach (array_keys($data) as $figure) { $status = substr($figure, 0, -4); $type = substr($figure, -3); if ($status != "mem_cnt") { $path = ilLearningProgressBaseGUI::_getImagePathForStatus((int) $status); $text = ilLearningProgressBaseGUI::_getStatusText((int) $status); $icon = ilUtil::img($path, $text); $text = $icon . " " . $text; } else { $text = $this->lng->txt("members"); } if ($type != "avg") { $caption = $text . " " . $this->lng->txt("trac_object_stat_lp_" . $type); } else { $caption = $text . " Ø"; } $data[$figure]["figure"] = $caption; } $this->setData($data); }
/** * Build summary item rows for given object and filter(s * * @param int $a_object_id * @param int $a_ref_id */ function getItems($a_object_id, $a_ref_id) { global $lng; include_once "./Services/Tracking/classes/class.ilTrQuery.php"; $preselected_obj_ids = $filter = NULL; if ($this->is_root) { // using search to get all relevant objects // #8498/#8499: restrict to objects with at least "edit_learning_progress" access $preselected_obj_ids = $this->searchObjects($this->getCurrentFilter(true), "edit_learning_progress"); } else { // using summary filters $filter = $this->getCurrentFilter(); } $data = ilTrQuery::getObjectsSummaryForObject($a_object_id, $a_ref_id, ilUtil::stripSlashes($this->getOrderField()), ilUtil::stripSlashes($this->getOrderDirection()), ilUtil::stripSlashes($this->getOffset()), ilUtil::stripSlashes($this->getLimit()), $filter, $this->getSelectedColumns(), $preselected_obj_ids); // 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); $status_map = array(); foreach ($valid_status as $status) { $path = ilLearningProgressBaseGUI::_getImagePathForStatus($status); $text = ilLearningProgressBaseGUI::_getStatusText($status); $status_map[$status] = ilUtil::img($path, $text); } // language map $lng->loadLanguageModule("meta"); $languages = array(); foreach ($lng->getInstalledLanguages() as $lang_key) { $languages[$lang_key] = $lng->txt("meta_l_" . $lang_key); } $rows = array(); foreach ($data["set"] as $idx => $result) { // sessions have no title if ($result["title"] == "" && $result["type"] == "sess") { include_once "Modules/Session/classes/class.ilObjSession.php"; $sess = new ilObjSession($result["obj_id"], false); $data["set"][$idx]["title"] = $sess->getFirstAppointment()->appointmentToString(); } $data["set"][$idx]["offline"] = ilLearningProgressBaseGUI::isObjectOffline($result["obj_id"], $result["type"]); // percentages $users_no = $result["user_total"]; $data["set"][$idx]["country"] = $this->getItemsPercentages($result["country"], $users_no); $data["set"][$idx]["gender"] = $this->getItemsPercentages($result["gender"], $users_no, array("m" => $lng->txt("gender_m"), "f" => $lng->txt("gender_f"))); $data["set"][$idx]["city"] = $this->getItemsPercentages($result["city"], $users_no); $data["set"][$idx]["sel_country"] = $this->getItemsPercentages($result["sel_country"], $users_no, $this->getSelCountryCodes()); $data["set"][$idx]["mark"] = $this->getItemsPercentages($result["mark"], $users_no); $data["set"][$idx]["language"] = $this->getItemsPercentages($result["language"], $users_no, $languages); // if we encounter any invalid status codes, e.g. null, map them to not attempted instead foreach ($result["status"] as $status_code => $status_counter) { // null is cast to "" if ($status_code === "" || !in_array($status_code, $valid_status)) { $result["status"][ilLPStatus::LP_STATUS_NOT_ATTEMPTED_NUM] += $status_counter; unset($result["status"][$status_code]); } } $data["set"][$idx]["status"] = $this->getItemsPercentagesStatus($result["status"], $users_no, $status_map); if (!$this->isPercentageAvailable($result["obj_id"])) { $data["set"][$idx]["percentage_avg"] = NULL; } } $this->setMaxCount($data["cnt"]); $this->setData($data["set"]); }
protected function showAggregationInfo($a_show_link = true) { global $ilAccess, $lng, $ilCtrl; include_once "Services/Tracking/classes/class.ilTrQuery.php"; $info = ilTrQuery::getObjectStatisticsLogInfo(); $info_date = ilDatePresentation::formatDate(new ilDateTime($info["tstamp"], IL_CAL_UNIX)); $link = ""; if ($a_show_link && $ilAccess->checkAccess("write", "", $this->ref_id)) { $link = " <a href=\"" . $ilCtrl->getLinkTarget($this, "admin") . "\">»" . $lng->txt("trac_log_info_link") . "</a>"; } ilUtil::sendInfo(sprintf($lng->txt("trac_log_info"), $info_date, $info["counter"]) . $link); }
function getItems() { include_once "Services/Tracking/classes/class.ilTrQuery.php"; $data = ilTrQuery::getObjectStatisticsMonthlySummary(); $this->setData($data); }