/** * Clone folder * * @access public * @param int target id * @param int copy id * */ public function cloneObject($a_target_id, $a_copy_id = 0) { $new_obj = parent::cloneObject($a_target_id, $a_copy_id); // Copy learning progress settings include_once 'Services/Tracking/classes/class.ilLPObjSettings.php'; $obj_settings = new ilLPObjSettings($this->getId()); $obj_settings->cloneSettings($new_obj->getId()); unset($obj_settings); return $new_obj; }
/** * Translate operator * @param type $a_operator */ public static function translateOperator($a_obj_id, $a_operator) { switch ($a_operator) { case ilConditionHandler::OPERATOR_LP: $GLOBALS['lng']->loadLanguageModule('trac'); include_once './Services/Tracking/classes/class.ilLPObjSettings.php'; $obj_settings = new ilLPObjSettings($a_obj_id); return ilLPObjSettings::_mode2Text($obj_settings->getMode()); default: $GLOBALS['lng']->loadLanguageModule('rbac'); return $GLOBALS['lng']->txt('condition_' . $a_operator); } }
/** * check access to learning progress * * @param int $a_ref_id reference ifd of object * @param bool $a_allow_only_read read access is sufficient (see courses/groups) * @return * @static */ public static function checkAccess($a_ref_id, $a_allow_only_read = true) { global $ilUser, $ilAccess; if ($ilUser->getId() == ANONYMOUS_USER_ID) { return false; } include_once "Services/Tracking/classes/class.ilObjUserTracking.php"; if (!ilObjUserTracking::_enabledLearningProgress()) { return false; } if ($ilAccess->checkAccess('edit_learning_progress', '', $a_ref_id)) { return true; } if (!ilObjUserTracking::_hasLearningProgressLearner()) { return false; } include_once './Services/Tracking/classes/class.ilLPObjSettings.php'; if (ilLPObjSettings::_lookupMode(ilObject::_lookupObjId($a_ref_id)) == LP_MODE_DEACTIVATED) { return false; } if (!$ilAccess->checkAccess('read', '', $a_ref_id)) { return false; } if ($a_allow_only_read) { return true; } return false; }
function gatherCourseLPData() { global $tree, $ilDB; // process all courses $all_courses = array_keys(ilObject::_getObjectsByType("crs")); if ($all_courses) { // gather objects in trash $trashed_objects = $tree->getSavedNodeObjIds($all_courses); include_once 'Services/Tracking/classes/class.ilLPObjSettings.php'; include_once "Modules/Course/classes/class.ilCourseParticipants.php"; include_once "Services/Tracking/classes/class.ilLPStatusWrapper.php"; foreach ($all_courses as $crs_id) { // trashed objects will not change if (!in_array($crs_id, $trashed_objects)) { // only if LP is active $mode = ilLPObjSettings::_lookupMode($crs_id); if ($mode == LP_MODE_DEACTIVATED || $mode == LP_MODE_UNDEFINED) { continue; } // only save once per day $ilDB->manipulate("DELETE FROM obj_lp_stat WHERE" . " obj_id = " . $ilDB->quote($crs_id, "integer") . " AND fulldate = " . $ilDB->quote(date("Ymd", $this->date), "integer")); $members = new ilCourseParticipants($crs_id); $members = $members->getMembers(); $in_progress = count(ilLPStatusWrapper::_lookupInProgressForObject($crs_id, $members)); $completed = count(ilLPStatusWrapper::_lookupCompletedForObject($crs_id, $members)); $failed = count(ilLPStatusWrapper::_lookupFailedForObject($crs_id, $members)); // calculate with other values - there is not direct method $not_attempted = count($members) - $in_progress - $completed - $failed; $set = array("type" => array("text", "crs"), "obj_id" => array("integer", $crs_id), "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)), "mem_cnt" => array("integer", count($members)), "in_progress" => array("integer", $in_progress), "completed" => array("integer", $completed), "failed" => array("integer", $failed), "not_attempted" => array("integer", $not_attempted)); $ilDB->insert("obj_lp_stat", $set); } } } }
/** * Handle an event in a listener. * * @param string $a_component component, e.g. "Modules/Forum" or "Services/User" * @param string $a_event event e.g. "createUser", "updateUser", "deleteUser", ... * @param array $a_parameter parameter array (assoc), array("name" => ..., "phone_office" => ...) */ static function handleEvent($a_component, $a_event, $a_parameter) { global $ilUser; if ($a_component == "Services/Tracking" && $a_event == "updateStatus") { $obj_id = $a_parameter["obj_id"]; $user_id = $a_parameter["usr_id"]; $status = $a_parameter["status"]; if ($obj_id && $user_id) { if (ilObject::_lookupType($obj_id) != "crs") { return; } // determine couse setting only once if (!isset(self::$course_mode[$obj_id])) { include_once "./Modules/Course/classes/class.ilObjCourse.php"; $crs = new ilObjCourse($obj_id, false); if ($crs->getStatusDetermination() == ilObjCourse::STATUS_DETERMINATION_LP) { include_once './Services/Tracking/classes/class.ilLPObjSettings.php'; $lp_settings = new ilLPObjSettings($obj_id); $mode = $lp_settings->getMode(); } else { $mode = false; } self::$course_mode[$obj_id] = $mode; } $is_completed = $status == LP_STATUS_COMPLETED_NUM; // we are NOT using the members object because of performance issues switch (self::$course_mode[$obj_id]) { case LP_MODE_MANUAL_BY_TUTOR: include_once "Modules/Course/classes/class.ilCourseParticipants.php"; ilCourseParticipants::_updatePassed($obj_id, $user_id, $is_completed, $ilUser->getId()); break; case LP_MODE_COLLECTION: case LP_MODE_OBJECTIVES: if ($is_completed) { include_once "Modules/Course/classes/class.ilCourseParticipants.php"; ilCourseParticipants::_updatePassed($obj_id, $user_id, $is_completed, -1); } break; } } } }
/** * Init property form * * @return ilPropertyFormGUI $form */ protected function initFormSettings() { include_once './Services/Form/classes/class.ilPropertyFormGUI.php'; $form = new ilPropertyFormGUI(); $form->setTitle($this->lng->txt('tracking_settings')); $form->setFormAction($this->ctrl->getFormAction($this)); // Mode $mod = new ilRadioGroupInputGUI($this->lng->txt('trac_mode'), 'modus'); $mod->setRequired(true); $mod->setValue($this->obj_settings->getMode()); $form->addItem($mod); foreach ($this->obj_settings->getValidModes() as $mode_key => $mode_name) { $opt = new ilRadioOption($mode_name, $mode_key, ilLPObjSettings::_mode2InfoText($mode_key)); $opt->setValue($mode_key); $mod->addOption($opt); // Subitem for vistits if ($mode_key == LP_MODE_VISITS) { $vis = new ilNumberInputGUI($this->lng->txt('trac_visits'), 'visits'); $vis->setSize(3); $vis->setMaxLength(4); $vis->setInfo(sprintf($this->lng->txt('trac_visits_info'), ilObjUserTracking::_getValidTimeSpan())); $vis->setRequired(true); $vis->setValue($this->obj_settings->getVisits()); $opt->addSubItem($vis); } } /* // Info Active $act = new ilCustomInputGUI($this->lng->txt('trac_activated'), ''); $img = new ilTemplate('tpl.obj_settings_img_row.html',true,true,'Services/Tracking'); $img->setVariable("IMG_SRC", $activated = ilObjUserTracking::_enabledLearningProgress() ? ilUtil::getImagePath('icon_ok.png') : ilUtil::getImagePath('icon_not_ok.png') ); $act->setHTML($img->get()); $form->addItem($act); // Info Anonymized $ano = new ilCustomInputGUI($this->lng->txt('trac_anonymized'), ''); $img = new ilTemplate('tpl.obj_settings_img_row.html',true,true,'Services/Tracking'); $img->setVariable("IMG_SRC", $anonymized = !ilObjUserTracking::_enabledUserRelatedData() ? ilUtil::getImagePath('icon_ok.png') : ilUtil::getImagePath('icon_not_ok.png') ); $ano->setHTML($img->get()); $form->addItem($ano); */ $form->addCommandButton('saveSettings', $this->lng->txt('save')); return $form; }
function _showWarning($a_ref_id, $a_usr_id) { global $objDefinition; include_once './Services/Tracking/classes/class.ilLPCollectionCache.php'; include_once './Services/Tracking/classes/class.ilLPStatus.php'; include_once './Services/Tracking/classes/class.ilLPObjSettings.php'; global $ilObjDataCache; $obj_id = $ilObjDataCache->lookupObjId($a_ref_id); // if completed no warning if (ilLPStatus::_lookupStatus($obj_id, $a_usr_id) == LP_STATUS_COMPLETED_NUM) { return false; } // if editing time reached => show warning $timings =& ilTimingCache::_getTimings($a_ref_id); if ($timings['item']['timing_type'] == ilObjectActivation::TIMINGS_PRESETTING) { if ($timings['item']['changeable'] and $timings['user'][$a_usr_id]['end']) { $end = $timings['user'][$a_usr_id]['end']; } else { $end = $timings['item']['suggestion_end']; } if ($end < time()) { return true; } } // objective_ids would get confused with ref_ids ! if (ilLPObjSettings::_lookupMode($obj_id) != LP_MODE_OBJECTIVES && $objDefinition->isContainer(ilObject::_lookupType($obj_id))) { // No check subitems foreach (ilLPCollectionCache::_getItems($obj_id) as $item) { if (ilTimingCache::_showWarning($item, $a_usr_id)) { return true; } } } // Really ??? return false; }
/** * Clone group (no member data) * * @access public * @param int target ref_id * @param int copy id * */ public function cloneObject($a_target_id, $a_copy_id = 0) { global $ilDB, $ilUser; $new_obj = parent::cloneObject($a_target_id, $a_copy_id); $new_obj->setGroupType($this->getGroupType()); $new_obj->initGroupStatus($this->getGroupType() ? $this->getGroupType() : $this->readGroupStatus()); $this->cloneAutoGeneratedRoles($new_obj); $new_obj->setRegistrationType($this->getRegistrationType()); $new_obj->setInformation($this->getInformation()); $new_obj->setRegistrationStart($this->getRegistrationStart()); $new_obj->setRegistrationEnd($this->getRegistrationEnd()); $new_obj->enableUnlimitedRegistration($this->isRegistrationUnlimited()); $new_obj->setPassword($this->getPassword()); $new_obj->enableMembershipLimitation($this->isMembershipLimited()); $new_obj->setMaxMembers($this->getMaxMembers()); $new_obj->enableWaitingList($this->isWaitingListEnabled()); // map $new_obj->setLatitude($this->getLatitude()); $new_obj->setLongitude($this->getLongitude()); $new_obj->setLocationZoom($this->getLocationZoom()); $new_obj->setEnableGroupMap($this->getEnableGroupMap()); $new_obj->enableRegistrationAccessCode($this->isRegistrationAccessCodeEnabled()); include_once './Services/Membership/classes/class.ilMembershipRegistrationCodeUtils.php'; $new_obj->setRegistrationAccessCode(ilMembershipRegistrationCodeUtils::generateCode()); $new_obj->setViewMode($this->getViewMode()); $new_obj->setMailToMembersType($this->getMailToMembersType()); $new_obj->update(); global $ilLog; $ilLog->write(__METHOD__ . ': Starting add user'); // Assign user as admin include_once './Modules/Group/classes/class.ilGroupParticipants.php'; $part = ilGroupParticipants::_getInstanceByObjId($new_obj->getId()); $part->add($ilUser->getId(), IL_GRP_ADMIN); $part->updateNotification($ilUser->getId(), 1); // Copy learning progress settings include_once 'Services/Tracking/classes/class.ilLPObjSettings.php'; $obj_settings = new ilLPObjSettings($this->getId()); $obj_settings->cloneSettings($new_obj->getId()); unset($obj_settings); // clone icons $new_obj->saveIcons($this->getBigIconPath(), $this->getSmallIconPath(), $this->getTinyIconPath()); return $new_obj; }
/** * Clone learning module * * @access public * @param int target ref_id * @param int copy id * */ public function cloneObject($a_target_id, $a_copy_id = 0) { global $ilDB, $ilUser, $ilias; $new_obj = parent::cloneObject($a_target_id, $a_copy_id); $this->cloneMetaData($new_obj); //$new_obj->createProperties(); $new_obj->setTitle($this->getTitle()); $new_obj->setDescription($this->getDescription()); $new_obj->setLayoutPerPage($this->getLayoutPerPage()); $new_obj->setLayout($this->getLayout()); $new_obj->setTOCMode($this->getTOCMode()); $new_obj->setActiveLMMenu($this->isActiveLMMenu()); $new_obj->setActiveTOC($this->isActiveTOC()); $new_obj->setActiveNumbering($this->isActiveNumbering()); $new_obj->setActivePrintView($this->isActivePrintView()); $new_obj->setActivePreventGlossaryAppendix($this->isActivePreventGlossaryAppendix()); $new_obj->setActiveDownloads($this->isActiveDownloads()); $new_obj->setActiveDownloadsPublic($this->isActiveDownloadsPublic()); $new_obj->setPublicNotes($this->publicNotes()); $new_obj->setCleanFrames($this->cleanFrames()); $new_obj->setHistoryUserComments($this->isActiveHistoryUserComments()); $new_obj->setPublicAccessMode($this->getPublicAccessMode()); $new_obj->setPageHeader($this->getPageHeader()); $new_obj->setRating($this->hasRating()); $new_obj->update(); $new_obj->createLMTree(); // copy style include_once "./Services/Style/classes/class.ilObjStyleSheet.php"; $style_id = $this->getStyleSheetId(); if ($style_id > 0 && !ilObjStyleSheet::_lookupStandard($style_id)) { $style_obj = $ilias->obj_factory->getInstanceByObjId($style_id); $new_id = $style_obj->ilClone(); $new_obj->setStyleSheetId($new_id); $new_obj->update(); } // copy content $this->copyAllPagesAndChapters($new_obj); // Copy learning progress settings include_once 'Services/Tracking/classes/class.ilLPObjSettings.php'; $obj_settings = new ilLPObjSettings($this->getId()); $obj_settings->cloneSettings($new_obj->getId()); unset($obj_settings); return $new_obj; }
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(); }
/** * Clone exercise (no member data) * * @access public * @param int target ref_id * @param int copy id */ public function cloneObject($a_target_id, $a_copy_id = 0) { global $ilDB; // Copy settings $new_obj = parent::cloneObject($a_target_id, $a_copy_id); $new_obj->setInstruction($this->getInstruction()); $new_obj->setTimestamp($this->getTimestamp()); $new_obj->setPassMode($this->getPassMode()); $new_obj->saveData(); $new_obj->setPassNr($this->getPassNr()); $new_obj->setShowSubmissions($this->getShowSubmissions()); $new_obj->setCompletionBySubmission($this->isCompletionBySubmissionEnabled()); $new_obj->update(); // Copy assignments include_once "./Modules/Exercise/classes/class.ilExAssignment.php"; ilExAssignment::cloneAssignmentsOfExercise($this->getId(), $new_obj->getId()); //$tmp_file_obj =& new ilFileDataExercise($this->getId()); //$tmp_file_obj->ilClone($new_obj->getId()); //unset($tmp_file_obj); // Copy learning progress settings include_once 'Services/Tracking/classes/class.ilLPObjSettings.php'; $obj_settings = new ilLPObjSettings($this->getId()); $obj_settings->cloneSettings($new_obj->getId()); unset($obj_settings); return $new_obj; }
/** * Init attendance list object * * @return ilAttendanceList */ protected function initAttendanceList() { include_once './Modules/Group/classes/class.ilGroupParticipants.php'; $members_obj = ilGroupParticipants::_getInstanceByObjId($this->object->getId()); include_once 'Services/Membership/classes/class.ilAttendanceList.php'; $list = new ilAttendanceList($this, $members_obj); $list->setId('grpmemlst'); $list->setTitle($this->lng->txt('grp_members_print_title'), $this->lng->txt('obj_grp') . ': ' . $this->object->getTitle()); include_once './Services/Tracking/classes/class.ilObjUserTracking.php'; include_once './Services/Tracking/classes/class.ilLPObjSettings.php'; $this->show_tracking = (ilObjUserTracking::_enabledLearningProgress() and ilObjUserTracking::_enabledUserRelatedData() and ilLPObjSettings::_lookupMode($this->object->getId()) != LP_MODE_DEACTIVATED); if ($this->show_tracking) { $this->lng->loadLanguageModule('trac'); $list->addPreset('progress', $this->lng->txt('learning_progress'), true); } include_once './Services/PrivacySecurity/classes/class.ilPrivacySettings.php'; $privacy = ilPrivacySettings::_getInstance(); if ($privacy->enabledGroupAccessTimes()) { $list->addPreset('access', $this->lng->txt('last_access'), true); } return $list; }
function __readItemStatusInfo($a_items) { global $ilObjDataCache; include_once 'Services/Object/classes/class.ilObjectLP.php'; foreach ($a_items as $item_id) { $olp = ilObjectLP::getInstance($item_id); $this->obj_data[$item_id]['type'] = $ilObjDataCache->lookupType($item_id); $this->obj_data[$item_id]['mode'] = $olp->getCurrentMode(); if ($this->obj_data[$item_id]['mode'] == ilLPObjSettings::LP_MODE_TLT) { include_once './Services/MetaData/classes/class.ilMDEducational.php'; $this->obj_data[$item_id]['tlt'] = ilMDEducational::_getTypicalLearningTimeSeconds($item_id); } if ($this->obj_data[$item_id]['mode'] == ilLPObjSettings::LP_MODE_VISITS) { $this->obj_data[$item_id]['visits'] = ilLPObjSettings::_lookupVisits($item_id); } if ($this->obj_data[$item_id]['mode'] == ilLPObjSettings::LP_MODE_SCORM) { $collection = $olp->getCollectionInstance(); if ($collection) { $this->obj_data[$item_id]['scos'] = count($collection->getItems()); } } } }
/** * Get complete branch of tree (recursively) * * @param int $a_parent_ref_id * @param array $a_object_ids * @param array $a_ref_ids */ protected static function getSubTree($a_parent_ref_id, array &$a_object_ids, array &$a_ref_ids) { global $tree; $children = $tree->getChilds($a_parent_ref_id); if ($children) { foreach ($children as $child) { if ($child["type"] == "adm" || $child["type"] == "rolf") { continue; } // as there can be deactivated items in the collection // we should allow them here too $cmode = ilLPObjSettings::_lookupMode($child["obj_id"]); if ($cmode != LP_MODE_UNDEFINED) { $a_object_ids[] = $child["obj_id"]; $a_ref_ids[$child["obj_id"]] = $child["ref_id"]; } self::getSubTree($child["ref_id"], $a_object_ids, $a_ref_ids); } } }
/** * Init filter */ function initFilter() { global $lng, $ilSetting; if ($this->ref_id == ROOT_FOLDER_ID) { return parent::initFilter(true, false); } // show only if extended data was activated in lp settings include_once 'Services/Tracking/classes/class.ilObjUserTracking.php'; $tracking = new ilObjUserTracking(); $item = $this->addFilterItemByMetaType("user_total", ilTable2GUI::FILTER_NUMBER_RANGE, true, "∑ " . $lng->txt("users")); $this->filter["user_total"] = $item->getValue(); if ($tracking->hasExtendedData(ilObjUserTracking::EXTENDED_DATA_READ_COUNT)) { $item = $this->addFilterItemByMetaType("read_count", ilTable2GUI::FILTER_NUMBER_RANGE, true, "∑ " . $lng->txt("trac_read_count")); $this->filter["read_count"] = $item->getValue(); } if ($tracking->hasExtendedData(ilObjUserTracking::EXTENDED_DATA_SPENT_SECONDS)) { $item = $this->addFilterItemByMetaType("spent_seconds", ilTable2GUI::FILTER_DURATION_RANGE, true, "Ø " . $lng->txt("trac_spent_seconds") . " / " . $lng->txt("user")); $this->filter["spent_seconds"]["from"] = $item->getCombinationItem("from")->getValueInSeconds(); $this->filter["spent_seconds"]["to"] = $item->getCombinationItem("to")->getValueInSeconds(); } $item = $this->addFilterItemByMetaType("percentage", ilTable2GUI::FILTER_NUMBER_RANGE, true, "Ø " . $lng->txt("trac_percentage") . " / " . $lng->txt("user")); $this->filter["percentage"] = $item->getValue(); // do not show status if learning progress is deactivated $mode = ilLPObjSettings::_lookupMode($this->obj_id); if ($mode != LP_MODE_DEACTIVATED && $mode != LP_MODE_LP_MODE_UNDEFINED) { include_once "Services/Tracking/classes/class.ilLPStatus.php"; $item = $this->addFilterItemByMetaType("status", ilTable2GUI::FILTER_SELECT, true); $item->setOptions(array("" => $lng->txt("trac_all"), LP_STATUS_NOT_ATTEMPTED_NUM + 1 => $lng->txt(LP_STATUS_NOT_ATTEMPTED), LP_STATUS_IN_PROGRESS_NUM + 1 => $lng->txt(LP_STATUS_IN_PROGRESS), LP_STATUS_COMPLETED_NUM + 1 => $lng->txt(LP_STATUS_COMPLETED), LP_STATUS_FAILED_NUM + 1 => $lng->txt(LP_STATUS_FAILED))); $this->filter["status"] = $item->getValue(); if ($this->filter["status"]) { $this->filter["status"]--; } $item = $this->addFilterItemByMetaType("trac_status_changed", ilTable2GUI::FILTER_DATE_RANGE, true); $this->filter["status_changed"] = $item->getDate(); } if (ilObject::_lookupType($this->obj_id) != "lm") { $item = $this->addFilterItemByMetaType("mark", ilTable2GUI::FILTER_TEXT, true, $lng->txt("trac_mark")); $this->filter["mark"] = $item->getValue(); } if ($ilSetting->get("usr_settings_course_export_gender")) { $item = $this->addFilterItemByMetaType("gender", ilTable2GUI::FILTER_SELECT, true); $item->setOptions(array("" => $lng->txt("trac_all"), "m" => $lng->txt("gender_m"), "f" => $lng->txt("gender_f"))); $this->filter["gender"] = $item->getValue(); } if ($ilSetting->get("usr_settings_course_export_city")) { $item = $this->addFilterItemByMetaType("city", ilTable2GUI::FILTER_TEXT, true); $this->filter["city"] = $item->getValue(); } if ($ilSetting->get("usr_settings_course_export_country")) { $item = $this->addFilterItemByMetaType("country", ilTable2GUI::FILTER_TEXT, true); $this->filter["country"] = $item->getValue(); } if ($ilSetting->get("usr_settings_course_export_sel_country")) { $item = $this->addFilterItemByMetaType("sel_country", ilTable2GUI::FILTER_SELECT, true); $item->setOptions(array("" => $lng->txt("trac_all")) + $this->getSelCountryCodes()); $this->filter["sel_country"] = $item->getValue(); } $item = $this->addFilterItemByMetaType("language", ilTable2GUI::FILTER_LANGUAGE, true); $this->filter["language"] = $item->getValue(); if ($tracking->hasExtendedData(ilObjUserTracking::EXTENDED_DATA_LAST_ACCESS)) { $item = $this->addFilterItemByMetaType("trac_first_access", ilTable2GUI::FILTER_DATETIME_RANGE, true); $this->filter["first_access"] = $item->getDate(); $item = $this->addFilterItemByMetaType("trac_last_access", ilTable2GUI::FILTER_DATETIME_RANGE, true); $this->filter["last_access"] = $item->getDate(); } $item = $this->addFilterItemByMetaType("registration_filter", ilTable2GUI::FILTER_DATE_RANGE, true); $this->filter["registration"] = $item->getDate(); }
function __showEditUser($a_user_id, $a_ref_id, $a_cancel, $a_sub_id = false) { global $ilObjDataCache, $lng, $ilCtrl; include_once 'Services/Tracking/classes/class.ilLPMarks.php'; if (!$a_sub_id) { $obj_id = $ilObjDataCache->lookupObjId($a_ref_id); } else { $ilCtrl->setParameter($this, 'userdetails_id', $a_sub_id); $obj_id = $ilObjDataCache->lookupObjId($a_sub_id); } $marks = new ilLPMarks($obj_id, $a_user_id); $tpl = new ilTemplate('tpl.lp_edit_user.html', true, true, 'Services/Tracking'); $tpl->setVariable("OBJ_TITLE", $lng->txt("edit") . ": " . $ilObjDataCache->lookupTitle($obj_id)); $tpl->setVariable("OBJ_SUBTITLE", $this->lng->txt('trac_mode') . ": " . ilLPObjSettings::_mode2Text(ilLPObjSettings::_lookupMode($obj_id))); $ilCtrl->setParameter($this, 'user_id', $a_user_id); $ilCtrl->setParameter($this, 'details_id', $a_ref_id); $tpl->setVariable("FORMACTION", $ilCtrl->getFormAction($this)); $tpl->setVariable("TYPE_IMG", ilObjUser::_getPersonalPicturePath($a_user_id, 'xxsmall')); $tpl->setVariable("ALT_IMG", $ilObjDataCache->lookupTitle($a_user_id)); $tpl->setVariable("TXT_LP", $lng->txt('trac_learning_progress_tbl_header')); $tpl->setVariable("COMMENT", ilUtil::prepareFormOutput($marks->getComment(), false)); $type = $ilObjDataCache->lookupType($obj_id); if ($type != 'lm') { $tpl->setVariable("TXT_MARK", $lng->txt('trac_mark')); $tpl->setVariable("MARK", ilUtil::prepareFormOutput($marks->getMark(), false)); } $tpl->setVariable("TXT_COMMENT", $lng->txt('trac_comment')); $mode = ilLPObjSettings::_lookupMode($obj_id); if ($mode == LP_MODE_MANUAL or $mode == LP_MODE_MANUAL_BY_TUTOR) { include_once "./Services/Tracking/classes/class.ilLPStatus.php"; $completed = ilLPStatus::_lookupStatus($obj_id, $a_user_id); $tpl->setVariable("mode_manual"); $tpl->setVariable("TXT_COMPLETED", $lng->txt('trac_completed')); $tpl->setVariable("CHECK_COMPLETED", ilUtil::formCheckbox($completed == LP_STATUS_COMPLETED_NUM, 'completed', '1')); } $tpl->setVariable("TXT_CANCEL", $lng->txt('cancel')); $tpl->setVariable("TXT_SAVE", $lng->txt('save')); $tpl->setVariable("CMD_CANCEL", $a_cancel); return $tpl->get(); }
function &_getInstance($a_obj_id, $a_mode = NULL) { include_once 'Services/Tracking/classes/class.ilLPObjSettings.php'; if ($a_mode === NULL) { $a_mode = ilLPObjSettings::_lookupMode($a_obj_id); } switch ($a_mode) { case LP_MODE_VISITS: include_once 'Services/Tracking/classes/class.ilLPStatusVisits.php'; return new ilLPStatusVisits($a_obj_id); case LP_MODE_COLLECTION: include_once 'Services/Tracking/classes/class.ilLPStatusCollection.php'; return new ilLPStatusCollection($a_obj_id); case LP_MODE_TLT: include_once 'Services/Tracking/classes/class.ilLPStatusTypicalLearningTime.php'; return new ilLPStatusTypicalLearningTime($a_obj_id); case LP_MODE_SCORM: include_once 'Services/Tracking/classes/class.ilLPStatusSCORM.php'; return new ilLPStatusSCORM($a_obj_id); case LP_MODE_TEST_FINISHED: include_once 'Services/Tracking/classes/class.ilLPStatusTestFinished.php'; return new ilLPStatusTestFinished($a_obj_id); case LP_MODE_TEST_PASSED: include_once 'Services/Tracking/classes/class.ilLPStatusTestPassed.php'; return new ilLPStatusTestPassed($a_obj_id); case LP_MODE_MANUAL: include_once 'Services/Tracking/classes/class.ilLPStatusManual.php'; return new ilLPStatusManual($a_obj_id); case LP_MODE_MANUAL_BY_TUTOR: include_once 'Services/Tracking/classes/class.ilLPStatusManualByTutor.php'; return new ilLPStatusManualByTutor($a_obj_id); case LP_MODE_EXERCISE_RETURNED: include_once 'Services/Tracking/classes/class.ilLPStatusExerciseReturned.php'; return new ilLPStatusExerciseReturned($a_obj_id); case LP_MODE_OBJECTIVES: include_once 'Services/Tracking/classes/class.ilLPStatusObjectives.php'; return new ilLPStatusObjectives($a_obj_id); case LP_MODE_EVENT: include_once 'Services/Tracking/classes/class.ilLPStatusEvent.php'; return new ilLPStatusEvent($a_obj_id); case LP_MODE_PLUGIN: include_once 'Services/Tracking/classes/class.ilLPStatusPlugin.php'; return new ilLPStatusEvent($a_obj_id); case LP_MODE_UNDEFINED: $type = ilObject::_lookupType($a_obj_id); $mode = ilLPObjSettings::__getDefaultMode($a_obj_id, $type); if ($mode != LP_MODE_UNDEFINED) { return self::_getInstance($a_obj_id, $mode); } // fallthrough // fallthrough default: echo "ilLPStatusFactory: unknown type " . ilLPObjSettings::_lookupMode($a_obj_id); exit; } }
function &_getItems($a_obj_id, $a_use_subtree_by_id = false) { global $ilObjDataCache; global $ilDB, $tree; include_once 'Services/Tracking/classes/class.ilLPObjSettings.php'; $mode = ilLPObjSettings::_lookupMode($a_obj_id); if ($mode == LP_MODE_OBJECTIVES) { include_once 'Modules/Course/classes/class.ilCourseObjective.php'; return ilCourseObjective::_getObjectiveIds($a_obj_id); } if ($mode != LP_MODE_SCORM and $mode != LP_MODE_COLLECTION and $mode != LP_MODE_MANUAL_BY_TUTOR) { return array(); } if ($ilObjDataCache->lookupType($a_obj_id) != 'sahs') { $course_ref_ids = ilObject::_getAllReferences($a_obj_id); $course_ref_id = end($course_ref_ids); if (!$a_use_subtree_by_id) { $possible_items = ilLPCollections::_getPossibleItems($course_ref_id); } else { $possible_items = $tree->getSubTreeIds($course_ref_id); } $query = "SELECT * FROM ut_lp_collections utc " . "JOIN object_reference obr ON item_id = ref_id " . "JOIN object_data obd ON obr.obj_id = obd.obj_id " . "WHERE utc.obj_id = " . $ilDB->quote($a_obj_id, 'integer') . " " . "AND active = " . $ilDB->quote(1, 'integer') . " " . "ORDER BY title"; } else { // SAHS $query = "SELECT * FROM ut_lp_collections WHERE obj_id = " . $ilDB->quote($a_obj_id, 'integer') . " " . "AND active = " . $ilDB->quote(1, 'integer'); } $res = $ilDB->query($query); while ($row = $res->fetchRow(DB_FETCHMODE_OBJECT)) { if ($ilObjDataCache->lookupType($a_obj_id) != 'sahs') { if (!in_array($row->item_id, $possible_items)) { ilLPCollections::__deleteEntry($a_obj_id, $row->item_id); continue; } } // Check anonymized if ($ilObjDataCache->lookupType($item_obj_id = $ilObjDataCache->lookupObjId($row->item_id)) == 'tst') { include_once './Modules/Test/classes/class.ilObjTest.php'; if (ilObjTest::_lookupAnonymity($item_obj_id)) { ilLPCollections::__deleteEntry($a_obj_id, $row->item_id); continue; } } $items[] = $row->item_id; } return $items ? $items : array(); }
function __getDefaultMode($a_obj_id, $a_type) { global $ilDB, $objDefinition; #$type = strlen($a_type) ? $a_type : $this->obj_type; switch ($a_type) { case 'crs': // If objectives are enabled return deactivated if (ilLPObjSettings::_checkObjectives($a_obj_id)) { return LP_MODE_OBJECTIVES; } return LP_MODE_MANUAL_BY_TUTOR; case 'dbk': case 'lm': case 'htlm': return LP_MODE_MANUAL; case 'sahs': return LP_MODE_DEACTIVATED; case 'dbk': return LP_MODE_MANUAL; case 'tst': return LP_MODE_TEST_PASSED; case 'exc': return LP_MODE_EXERCISE_RETURNED; case 'grp': return LP_MODE_DEACTIVATED; case 'fold': return LP_MODE_DEACTIVATED; case 'sess': return LP_MODE_EVENT; default: if ($objDefinition->isPluginTypeName(ilObject::_lookupType($a_obj_id))) { return LP_MODE_PLUGIN; } return LP_MODE_UNDEFINED; } }
/** * Get selectable columns * * @param * @return */ function getSelectableColumns() { global $lng, $ilSetting; if ($this->selectable_columns) { return $this->selectable_columns; } $anonymized_object = false; include_once './Modules/Test/classes/class.ilObjTest.php'; if (ilObjTest::_lookupAnonymity($this->obj_id)) { $anonymized_object = true; } include_once "./Services/User/classes/class.ilUserProfile.php"; $up = new ilUserProfile(); $up->skipGroup("preferences"); $up->skipGroup("settings"); $ufs = $up->getStandardFields(); // default fields $cols = array(); $cols["login"] = array("txt" => $lng->txt("login"), "default" => true); if (!$anonymized_object) { $cols["firstname"] = array("txt" => $lng->txt("firstname"), "default" => true); $cols["lastname"] = array("txt" => $lng->txt("lastname"), "default" => true); } // show only if extended data was activated in lp settings include_once 'Services/Tracking/classes/class.ilObjUserTracking.php'; $tracking = new ilObjUserTracking(); if ($tracking->hasExtendedData(ilObjUserTracking::EXTENDED_DATA_LAST_ACCESS)) { $cols["first_access"] = array("txt" => $lng->txt("trac_first_access"), "default" => true); $cols["last_access"] = array("txt" => $lng->txt("trac_last_access"), "default" => true); } if ($tracking->hasExtendedData(ilObjUserTracking::EXTENDED_DATA_READ_COUNT)) { $cols["read_count"] = array("txt" => $lng->txt("trac_read_count"), "default" => true); } if ($tracking->hasExtendedData(ilObjUserTracking::EXTENDED_DATA_SPENT_SECONDS)) { $cols["spent_seconds"] = array("txt" => $lng->txt("trac_spent_seconds"), "default" => true); } if ($this->isPercentageAvailable($this->obj_id)) { $cols["percentage"] = array("txt" => $lng->txt("trac_percentage"), "default" => true); } // do not show status if learning progress is deactivated $mode = ilLPObjSettings::_lookupMode($this->obj_id); if ($mode != LP_MODE_DEACTIVATED && $mode != LP_MODE_LP_MODE_UNDEFINED) { $cols["status"] = array("txt" => $lng->txt("trac_status"), "default" => true); $cols['status_changed'] = array('txt' => $lng->txt('trac_status_changed'), 'default' => false); } if ($this->type != "lm") { $cols["mark"] = array("txt" => $lng->txt("trac_mark"), "default" => true); } $cols["u_comment"] = array("txt" => $lng->txt("trac_comment"), "default" => false); $cols["create_date"] = array("txt" => $lng->txt("create_date"), "default" => false); $cols["language"] = array("txt" => $lng->txt("language"), "default" => false); // add user data only if object is [part of] course if (!$anonymized_object && ($this->in_course || $this->in_group)) { // only show if export permission is granted include_once 'Services/PrivacySecurity/classes/class.ilPrivacySettings.php'; if (ilPrivacySettings::_getInstance()->checkExportAccess($this->ref_id)) { $this->user_fields = array(); // other user profile fields foreach ($ufs as $f => $fd) { if (!isset($cols[$f]) && $f != "username" && !$fd["lists_hide"]) { if ($this->in_course && !($fd["course_export_fix_value"] || $ilSetting->get("usr_settings_course_export_" . $f))) { continue; } if ($this->in_group && !($fd["group_export_fix_value"] || $ilSetting->get("usr_settings_group_export_" . $f))) { continue; } $cols[$f] = array("txt" => $lng->txt($f), "default" => false); $this->user_fields[] = $f; } } // additional defined user data fields include_once './Services/User/classes/class.ilUserDefinedFields.php'; $user_defined_fields = ilUserDefinedFields::_getInstance(); if ($this->in_course) { $user_defined_fields = $user_defined_fields->getCourseExportableFields(); } else { $user_defined_fields = $user_defined_fields->getGroupExportableFields(); } foreach ($user_defined_fields as $definition) { if ($definition["field_type"] != UDF_TYPE_WYSIWYG) { $f = "udf_" . $definition["field_id"]; $cols[$f] = array("txt" => $definition["field_name"], "default" => false); $this->user_fields[] = $f; } } } } $this->selectable_columns = $cols; return $cols; }
function __initDetails($a_details_id) { global $ilObjDataCache; if (!$a_details_id) { $a_details_id = $this->getRefId(); } if ($a_details_id) { $_GET['details_id'] = $a_details_id; $this->details_id = $a_details_id; $this->details_obj_id = $ilObjDataCache->lookupObjId($this->details_id); $this->details_type = $ilObjDataCache->lookupType($this->details_obj_id); $this->details_mode = ilLPObjSettings::_lookupMode($this->details_obj_id); } }
/** * Parse one item * @param array $item */ protected function parseCollectionItem($item) { $tmp['ref_id'] = $item; $tmp['id'] = $item; $tmp['obj_id'] = ilObject::_lookupObjId($item); $tmp['type'] = ilObject::_lookupType($tmp['obj_id']); $tmp['title'] = ilObject::_lookupTitle($tmp['obj_id']); $tmp['description'] = ilObject::_lookupDescription($tmp['obj_id']); // mode to text (sorting) $tmp["mode_id"] = ilLPObjSettings::_lookupMode($tmp['obj_id']); $tmp["mode"] = ilLPObjSettings::_mode2Text($tmp["mode_id"]); // status (sorting) $tmp["status"] = $this->getCollection()->isAssigned($item); return $tmp; }
/** * Determine percentage * * @param integer object id * @param integer user id * @param object object (optional depends on object type) * @return integer percentage */ function determinePercentage($a_obj_id, $a_user_id, $a_obj = null) { include_once 'Services/Tracking/classes/class.ilLPObjSettings.php'; $reqv = ilLPObjSettings::_lookupVisits($a_obj_id); $re = ilChangeEvent::_lookupReadEvents($a_obj_id, $a_user_id); $rc = (int) $re[0]["read_count"]; if ($reqv > 0) { $per = min(100, 100 / $reqv * $rc); } else { $per = 100; } return $per; }
public function getModeInfoText($a_mode) { return ilLPObjSettings::_mode2InfoText($a_mode); }
/** * Init filter */ function initFilter() { global $lng, $rbacreview, $ilUser; // for scorm and objectives this filter does not make sense / is not implemented include_once "Services/Tracking/classes/class.ilLPObjSettings.php"; $mode = ilLPObjSettings::_lookupMode($this->obj_id); if ($mode == LP_MODE_SCORM || $mode == LP_MODE_OBJECTIVES) { return; } include_once "./Services/Form/classes/class.ilSubEnabledFormPropertyGUI.php"; include_once "./Services/Table/interfaces/interface.ilTableFilterItem.php"; // show collection only/all include_once "./Services/Form/classes/class.ilRadioGroupInputGUI.php"; include_once "./Services/Form/classes/class.ilRadioOption.php"; $ti = new ilRadioGroupInputGUI($lng->txt("trac_view_mode"), "view_mode"); $ti->addOption(new ilRadioOption($lng->txt("trac_view_mode_all"), "")); $ti->addOption(new ilRadioOption($lng->txt("trac_view_mode_collection"), "coll")); $this->addFilterItem($ti); $ti->readFromSession(); $this->filter["view_mode"] = $ti->getValue(); }
/** * set settings for learning progress determination per default at upload */ function setLearningProgressSettingsAtUpload() { global $ilSetting; //condition 1 if ($ilSetting->get('scorm_lp_auto_activate', 0)) { return; } //condition 2 include_once "./Services/Tracking/classes/class.ilObjUserTracking.php"; if (ilObjUserTracking::_enabledLearningProgress() == false) { return; } //set Learning Progress to Automatic by Collection of SCORM Items include_once "./Services/Tracking/classes/class.ilLPObjSettings.php"; $lm_set = new ilLPObjSettings($this->getId()); $lm_set->setMode(ilLPObjSettings::LP_MODE_SCORM); $lm_set->insert(); //select all SCOs as relevant for Learning Progress include_once "Services/Tracking/classes/collection/class.ilLPCollectionOfSCOs.php"; $collection = new ilLPCollectionOfSCOs($this->getId(), ilLPObjSettings::LP_MODE_SCORM); $scos = array(); foreach ($collection->getPossibleItems() as $sco_id => $item) { $scos[] = $sco_id; } $collection->activateEntries($scos); }
/** * Clone course (no member data) * * @access public * @param int target ref_id * @param int copy id * */ public function cloneObject($a_target_id, $a_copy_id = 0) { global $ilDB, $ilUser, $ilAppEventHandler; $new_obj = parent::cloneObject($a_target_id, $a_copy_id); $this->read(); // Copy settings $this->cloneSettings($new_obj); // Clone appointment $new_app = $this->getFirstAppointment()->cloneObject($new_obj->getId()); $new_obj->setAppointments(array($new_app)); $new_obj->update(); // Clone session files foreach ($this->files as $file) { $file->cloneFiles($new_obj->getEventId()); } // Raise update forn new appointments // Copy learning progress settings include_once 'Services/Tracking/classes/class.ilLPObjSettings.php'; $obj_settings = new ilLPObjSettings($this->getId()); $obj_settings->cloneSettings($new_obj->getId()); unset($obj_settings); return $new_obj; }
/** * create recurring sessions * * @access protected * @param bool $a_activate_lp * @return */ protected function createRecurringSessions($a_activate_lp = true) { global $tree; if (!$this->rec->getFrequenceType()) { return true; } include_once './Services/Calendar/classes/class.ilCalendarRecurrenceCalculator.php'; $calc = new ilCalendarRecurrenceCalculator($this->object->getFirstAppointment(), $this->rec); $period_start = clone $this->object->getFirstAppointment()->getStart(); $period_end = clone $this->object->getFirstAppointment()->getStart(); $period_end->increment(IL_CAL_YEAR, 5); $date_list = $calc->calculateDateList($period_start, $period_end); $period_diff = $this->object->getFirstAppointment()->getEnd()->get(IL_CAL_UNIX) - $this->object->getFirstAppointment()->getStart()->get(IL_CAL_UNIX); $parent_id = $tree->getParentId($this->object->getRefId()); include_once './Modules/Session/classes/class.ilEventItems.php'; $evi = new ilEventItems($this->object->getId()); $eitems = $evi->getItems(); $counter = 0; foreach ($date_list->get() as $date) { if (!$counter++) { continue; } $new_obj = $this->object->cloneObject($parent_id); $new_obj->read(); $new_obj->getFirstAppointment()->setStartingTime($date->get(IL_CAL_UNIX)); $new_obj->getFirstAppointment()->setEndingTime($date->get(IL_CAL_UNIX) + $period_diff); $new_obj->getFirstAppointment()->update(); $new_obj->update(); // #14547 - active is default if (!$a_activate_lp) { include_once "Services/Tracking/classes/class.ilLPObjSettings.php"; $lp_obj_settings = new ilLPObjSettings($new_obj->getId()); $lp_obj_settings->setMode(ilLPObjSettings::LP_MODE_DEACTIVATED); $lp_obj_settings->update(false); } $new_evi = new ilEventItems($new_obj->getId()); $new_evi->setItems($eitems); $new_evi->update(); } }
/** * Clone course (no member data) * * @access public * @param int target ref_id * @param int copy id * */ public function cloneObject($a_target_id, $a_copy_id = 0) { global $ilDB, $ilUser; $new_obj = parent::cloneObject($a_target_id, $a_copy_id); $this->cloneAutoGeneratedRoles($new_obj); $this->cloneMetaData($new_obj); // Assign admin $new_obj->getMemberObject()->add($ilUser->getId(), IL_CRS_ADMIN); // #14596 $cwo = ilCopyWizardOptions::_getInstance($a_copy_id); if ($cwo->isRootNode($this->getRefId())) { $this->setOfflineStatus(true); } // Copy settings $this->cloneSettings($new_obj); // Course Defined Fields include_once 'Modules/Course/classes/Export/class.ilCourseDefinedFieldDefinition.php'; ilCourseDefinedFieldDefinition::_clone($this->getId(), $new_obj->getId()); // Clone course files include_once 'Modules/Course/classes/class.ilCourseFile.php'; ilCourseFile::_cloneFiles($this->getId(), $new_obj->getId()); // Copy learning progress settings include_once 'Services/Tracking/classes/class.ilLPObjSettings.php'; $obj_settings = new ilLPObjSettings($this->getId()); $obj_settings->cloneSettings($new_obj->getId()); unset($obj_settings); // clone icons global $ilLog; $ilLog->write(__METHOD__ . ': ' . $this->getBigIconPath() . ' ' . $this->getSmallIconPath()); $new_obj->saveIcons($this->getBigIconPath(), $this->getSmallIconPath(), $this->getTinyIconPath()); // clone certificate (#11085) include_once "./Services/Certificate/classes/class.ilCertificate.php"; include_once "./Modules/Course/classes/class.ilCourseCertificateAdapter.php"; $cert = new ilCertificate(new ilCourseCertificateAdapter($this)); $newcert = new ilCertificate(new ilCourseCertificateAdapter($new_obj)); $cert->cloneCertificate($newcert); return $new_obj; }
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; }