function getSelectableColumns() { global $ilObjDataCache; $columns = array(); if ($this->obj_ids === NULL) { $this->obj_ids = $this->getItems(); } if ($this->obj_ids) { $tmp_cols = array(); foreach ($this->obj_ids as $obj_id) { if ($obj_id == $this->obj_id) { $parent = array("txt" => $this->lng->txt("status"), "default" => true); } else { $title = $ilObjDataCache->lookupTitle($obj_id); $type = $ilObjDataCache->lookupType($obj_id); $icon = ilObject::_getIcon("", "tiny", $type); if ($type == "sess") { include_once "Modules/Session/classes/class.ilObjSession.php"; $sess = new ilObjSession($obj_id, false); $title = $sess->getPresentationTitle(); } $tmp_cols[strtolower($title) . "#~#obj_" . $obj_id] = array("txt" => $title, "icon" => $icon, "type" => $type, "default" => true); } } if (sizeof($this->objective_ids)) { foreach ($this->objective_ids as $obj_id => $title) { $tmp_cols[strtolower($title) . "#~#objtv_" . $obj_id] = array("txt" => $title, "default" => true); } } if (sizeof($this->sco_ids)) { foreach ($this->sco_ids as $obj_id => $title) { $icon = ilUtil::getTypeIconPath("sco", $obj_id, "tiny"); $tmp_cols[strtolower($title) . "#~#objsco_" . $obj_id] = array("txt" => $title, "icon" => $icon, "default" => true); } } // alex, 5 Nov 2011: Do not sort SCORM items if (!sizeof($this->sco_ids)) { ksort($tmp_cols); } foreach ($tmp_cols as $id => $def) { $id = explode('#~#', $id); $columns[$id[1]] = $def; } unset($tmp_cols); if ($parent) { $columns["obj_" . $this->obj_id] = $parent; } } $columns["status_changed"] = array("txt" => $this->lng->txt("trac_status_changed"), "id" => "status_changed", "default" => false); include_once 'Services/Tracking/classes/class.ilObjUserTracking.php'; $tracking = new ilObjUserTracking(); if ($tracking->hasExtendedData(ilObjUserTracking::EXTENDED_DATA_LAST_ACCESS)) { $columns["last_access"] = array("txt" => $this->lng->txt("last_access"), "id" => "last_access", "default" => false); } if ($tracking->hasExtendedData(ilObjUserTracking::EXTENDED_DATA_SPENT_SECONDS)) { $columns["spent_seconds"] = array("txt" => $this->lng->txt("trac_spent_seconds"), "id" => "spent_seconds", "default" => false); } return $columns; }
/** * Determine status * * @param integer object id * @param integer user id * @param object object (optional depends on object type) * @return integer status */ function determineStatus($a_obj_id, $a_user_id, $a_obj = null) { global $ilObjDataCache, $ilDB; $status = LP_STATUS_NOT_ATTEMPTED_NUM; switch ($ilObjDataCache->lookupType($a_obj_id)) { case 'sess': include_once './Modules/Session/classes/class.ilEventParticipants.php'; include_once './Modules/Session/classes/class.ilSessionAppointment.php'; include_once './Modules/Session/classes/class.ilObjSession.php'; $time_info = ilSessionAppointment::_lookupAppointment($a_obj_id); $registration = ilObjSession::_lookupRegistrationEnabled($a_obj_id); // If registration is disabled in_progress is not available // If event has occured in_progress is impossible if ($registration && $time_info['start'] >= time()) { // is user registered -> in progress if (ilEventParticipants::_isRegistered($a_user_id, $a_obj_id)) { $status = LP_STATUS_IN_PROGRESS_NUM; } } if (ilEventParticipants::_hasParticipated($a_user_id, $a_obj_id)) { $status = LP_STATUS_COMPLETED_NUM; } break; } return $status; }
/** * Import record * * @param * @return */ function importRecord($a_entity, $a_types, $a_rec, $a_mapping, $a_schema_version) { switch ($a_entity) { case "sess": include_once "./Modules/Session/classes/class.ilObjSession.php"; include_once "./Modules/Session/classes/class.ilSessionAppointment.php"; if ($new_id = $a_mapping->getMapping('Services/Container', 'objs', $a_rec['Id'])) { $newObj = ilObjectFactory::getInstanceByObjId($new_id, false); } else { $newObj = new ilObjSession(); $newObj->setType("sess"); $newObj->create(true); } $newObj->setTitle($a_rec["Title"]); $newObj->setDescription($a_rec["Description"]); $newObj->setLocation($a_rec["Location"]); $newObj->setName($a_rec["TutorName"]); $newObj->setPhone($a_rec["TutorPhone"]); $newObj->setEmail($a_rec["TutorEmail"]); $newObj->setDetails($a_rec["Details"]); $newObj->update(); $start = new ilDateTime($a_rec["EventStart"], IL_CAL_DATETIME, "UTC"); $end = new ilDateTime($a_rec["EventEnd"], IL_CAL_DATETIME, "UTC"); //echo "<br>".$start->get(IL_CAL_UNIX); //echo "<br>".$start->get(IL_CAL_DATETIME); $app = new ilSessionAppointment(); $app->setStart($a_rec["EventStart"]); $app->setEnd($a_rec["EventEnd"]); $app->setStartingTime($start->get(IL_CAL_UNIX)); $app->setEndingTime($end->get(IL_CAL_UNIX)); $app->toggleFullTime($a_rec["Fulltime"]); $app->setSessionId($newObj->getId()); $app->create(); //$newObj->setAppointments(array($app)); //$newObj->update(); $this->current_obj = $newObj; $a_mapping->addMapping("Modules/Session", "sess", $a_rec["Id"], $newObj->getId()); //var_dump($a_mapping->mappings["Services/News"]["news_context"]); break; case "sess_item": if ($obj_id = $a_mapping->getMapping('Services/Container', 'objs', $a_rec['ItemId'])) { $ref_id = current(ilObject::_getAllReferences($obj_id)); include_once './Modules/Session/classes/class.ilEventItems.php'; $evi = new ilEventItems($this->current_obj->getId()); $evi->addItem($ref_id); $evi->update(); } break; } }
/** * 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"]); }
function getSelectableColumns() { global $ilObjDataCache, $rbacsystem; $user_cols = $this->getSelectableUserColumns($this->in_course, $this->in_group); if ($this->obj_ids === NULL) { // we cannot use the selected columns because they are not ready yet // so we use all available columns, should be ok anyways $this->obj_ids = $this->getItems(array_keys($user_cols[0]), $user_cols[1]); } if ($this->obj_ids) { $tmp_cols = array(); foreach ($this->obj_ids as $obj_id) { if ($obj_id == $this->obj_id) { $parent = array("txt" => $this->lng->txt("status"), "default" => true); } else { $no_perm = false; $ref_id = $this->ref_ids[$obj_id]; if ($ref_id && !$rbacsystem->checkAccess('read_learning_progress', $ref_id)) { $no_perm = true; $this->privacy_cols[] = $obj_id; } $title = $ilObjDataCache->lookupTitle($obj_id); $type = $ilObjDataCache->lookupType($obj_id); $icon = ilObject::_getIcon("", "tiny", $type); if ($type == "sess") { include_once "Modules/Session/classes/class.ilObjSession.php"; $sess = new ilObjSession($obj_id, false); $title = $sess->getPresentationTitle(); } $tmp_cols[strtolower($title) . "#~#obj_" . $obj_id] = array("txt" => $title, "icon" => $icon, "type" => $type, "default" => true, "no_permission" => $no_perm); } } if (sizeof($this->objective_ids)) { foreach ($this->objective_ids as $obj_id => $title) { $tmp_cols[strtolower($title) . "#~#objtv_" . $obj_id] = array("txt" => $title, "default" => true); } } if (sizeof($this->sco_ids)) { foreach ($this->sco_ids as $obj_id => $title) { $icon = ilUtil::getTypeIconPath("sco", $obj_id, "tiny"); $tmp_cols[strtolower($title) . "#~#objsco_" . $obj_id] = array("txt" => $title, "icon" => $icon, "default" => true); } } if (sizeof($this->subitem_ids)) { foreach ($this->subitem_ids as $obj_id => $title) { $icon = ilUtil::getTypeIconPath("st", $obj_id, "tiny"); $tmp_cols[strtolower($title) . "#~#objsub_" . $obj_id] = array("txt" => $title, "icon" => $icon, "default" => true); } } // alex, 5 Nov 2011: Do not sort SCORM items or "chapters" if (!sizeof($this->sco_ids) && !sizeof($this->subitem_ids)) { ksort($tmp_cols); } foreach ($tmp_cols as $id => $def) { $id = explode('#~#', $id); $columns[$id[1]] = $def; } unset($tmp_cols); if ($parent) { $columns["obj_" . $this->obj_id] = $parent; } } unset($user_cols[0]["status"]); unset($user_cols[0]["login"]); foreach ($user_cols[0] as $col_id => $col_def) { if (!isset($columns[$col_id])) { // these are all additional fields, no default $col_def["default"] = false; $columns[$col_id] = $col_def; } } return $columns; }
/** * clone settings * * @access public * @param ilObjSession * @return */ public function cloneSettings(ilObjSession $new_obj) { // @var $new_obj->setLocation($this->getLocation()); $new_obj->setName($this->getName()); $new_obj->setPhone($this->getPhone()); $new_obj->setEmail($this->getEmail()); $new_obj->setDetails($this->getDetails()); $new_obj->setRegistrationType($this->getRegistrationType()); $new_obj->enableRegistrationUserLimit($this->isRegistrationUserLimitEnabled()); $new_obj->enableRegistrationWaitingList($this->isRegistrationWaitingListEnabled()); $new_obj->setRegistrationMaxUsers($this->getRegistrationMaxUsers()); $new_obj->update(); return true; }
/** * get properties * * @access public * @param * @return */ public function getProperties() { $app_info = $this->getAppointmentInfo(); /* $props[] = array( 'alert' => false, 'property' => $this->lng->txt('event_date'), 'value' => ilSessionAppointment::_appointmentToString($app_info['start'],$app_info['end'],$app_info['fullday'])); */ if ($this->getDetailsLevel() == ilObjectListGUI::DETAILS_MINIMAL) { if ($items = self::lookupAssignedMaterials($this->obj_id)) { $props[] = array('alert' => false, 'property' => $this->lng->txt('event_ass_materials_prop'), 'value' => count($items)); } } if ($this->getDetailsLevel() == ilObjectListGUI::DETAILS_ALL) { include_once './Modules/Session/classes/class.ilObjSession.php'; $session_data = ilObjSession::lookupSession($this->obj_id); if (strlen($session_data['location'])) { $props[] = array('alert' => false, 'property' => $this->lng->txt('event_location'), 'value' => $session_data['location']); } if (strlen($session_data['details'])) { $props[] = array('alert' => false, 'property' => $this->lng->txt('event_details_workflow'), 'value' => nl2br($session_data['details']), 'newline' => true); } $has_new_line = false; if (strlen($session_data['name'])) { $props[] = array('alert' => false, 'property' => $this->lng->txt('event_lecturer'), 'value' => $session_data['name'], 'newline' => true); $has_new_line = true; } if (strlen($session_data['email'])) { $props[] = array('alert' => false, 'property' => $this->lng->txt('tutor_email'), 'value' => $session_data['email'], 'newline' => $has_new_line ? false : true); $has_new_line = true; } if (strlen($session_data['phone'])) { $props[] = array('alert' => false, 'property' => $this->lng->txt('tutor_phone'), 'value' => $session_data['phone'], 'newline' => $has_new_line ? false : true); $has_new_line = true; } } return $props; }