/**
  * Import relevant properties from given course
  *
  * @param ilObjCourse $a_course
  * @return object
  */
 public static function createFromCourse(ilObjCourse $a_course, $a_user_id)
 {
     global $lng;
     $lng->loadLanguageModule("crs");
     $newObj = new self();
     $newObj->setTitle($a_course->getTitle());
     $newObj->setDescription($a_course->getDescription());
     include_once "Services/Tracking/classes/class.ilLPMarks.php";
     $lp_marks = new ilLPMarks($a_course->getId(), $a_user_id);
     $newObj->setProperty("issued_on", new ilDate($lp_marks->getStatusChanged(), IL_CAL_DATETIME));
     // create certificate
     include_once "Services/Certificate/classes/class.ilCertificate.php";
     include_once "Modules/Course/classes/class.ilCourseCertificateAdapter.php";
     $certificate = new ilCertificate(new ilCourseCertificateAdapter($a_course));
     $certificate = $certificate->outCertificate(array("user_id" => $a_user_id), false);
     // save pdf file
     if ($certificate) {
         // we need the object id for storing the certificate file
         $newObj->create();
         $path = self::initStorage($newObj->getId(), "certificate");
         $file_name = "crs_" . $a_course->getId() . "_" . $a_user_id . ".pdf";
         if (file_put_contents($path . $file_name, $certificate)) {
             $newObj->setProperty("file", $file_name);
             $newObj->update();
             return $newObj;
         }
         // file creation failed, so remove to object, too
         $newObj->delete();
     }
 }
 public function getSinglePool($CourseID, $PoolID)
 {
     global $ilUser, $ilObjDataCache;
     $retval = array();
     $items = ilParticipants::_getMembershipByType($ilUser->getId(), 'crs');
     // $items = ilParticipants::_getMembershipByType(12855, 'crs');
     $itemId = array_search($CourseID, $items);
     if ($itemId !== FALSE && $itemId >= 0) {
         $obj_id = $items[$itemId];
         $item_references = ilObject::_getAllReferences($obj_id);
         reset($item_references);
         if (strcmp($this->iliasVersion, "4.2") === 0) {
             require_once 'Modules/Course/classes/class.ilCourseItems.php';
             foreach ($item_references as $ref_id) {
                 // Antique Ilias
                 $courseItems = new ilCourseItems($ref_id, 0, $ilUser->getId());
                 $courseItemList = $courseItems->getAllItems();
                 $retval = $this->mapItems($courseItemList, $PoolID);
                 $retval = $retval[0];
             }
         } else {
             // Modern Ilias
             $crs = new ilObjCourse($item_references, true);
             $courseItemList = $crs->getSubItems();
             $retval = $this->mapItems($courseItemList["_all"], $PoolID);
             $retval = $retval[0];
         }
     }
     return $retval;
 }
 /**
  * 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") {
         // #13905
         include_once "Services/Tracking/classes/class.ilObjUserTracking.php";
         if (!ilObjUserTracking::_enabledLearningProgress()) {
             return;
         }
         $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/Object/classes/class.ilObjectLP.php';
                     $olp = ilObjectLP::getInstance($obj_id);
                     $mode = $olp->getCurrentMode();
                 } else {
                     $mode = false;
                 }
                 self::$course_mode[$obj_id] = $mode;
             }
             $is_completed = $status == ilLPStatus::LP_STATUS_COMPLETED_NUM;
             // we are NOT using the members object because of performance issues
             switch (self::$course_mode[$obj_id]) {
                 case ilLPObjSettings::LP_MODE_MANUAL_BY_TUTOR:
                     // #11600
                     include_once "Modules/Course/classes/class.ilCourseParticipants.php";
                     ilCourseParticipants::_updatePassed($obj_id, $user_id, $is_completed, true);
                     break;
                 case ilLPObjSettings::LP_MODE_COLLECTION:
                 case ilLPObjSettings::LP_MODE_OBJECTIVES:
                     // overwrites course passed status if it was set automatically (full sync)
                     // or toggle manually set passed status to completed (1-way-sync)
                     $do_update = $is_completed;
                     include_once "Modules/Course/classes/class.ilCourseParticipants.php";
                     if (!$do_update) {
                         $part = new ilCourseParticipants($obj_id);
                         $passed = $part->getPassedInfo($user_id);
                         if (!is_array($passed) || $passed["user_id"] == -1) {
                             $do_update = true;
                         }
                     }
                     if ($do_update) {
                         ilCourseParticipants::_updatePassed($obj_id, $user_id, $is_completed);
                     }
                     break;
             }
         }
     }
 }
 protected function checkObjectives()
 {
     include_once "Modules/Course/classes/class.ilObjCourse.php";
     if (ilObjCourse::_lookupViewMode($this->obj_id) == IL_CRS_VIEW_OBJECTIVE) {
         return true;
     }
     return false;
 }
 /**
  * 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;
             }
         }
     }
 }
 /**
  * Set Course title and icon in header
  *
  */
 protected function initHeader()
 {
     $lgui = ilObjectListGUIFactory::_getListGUIByType($this->crs->getType());
     $this->tpl->setTitle($this->crs->getTitle());
     $this->tpl->setDescription($this->crs->getDescription());
     if ($this->crs->getOfflineStatus()) {
         $this->tpl->setAlertProperties($lgui->getAlertProperties());
     }
     $this->tpl->setTitleIcon(ilUtil::getTypeIconPath('crs', $this->crs->getId(), 'big'));
     $this->ctrl->setParameterByClass('ilrepositorygui', 'ref_id', $this->ref_id);
     $this->tabs->setBackTarget($this->pl->txt('back_to_course'), $this->ctrl->getLinkTargetByClass('ilrepositorygui'));
 }
 function addCourse($sid, $target_id, $crs_xml)
 {
     $this->initAuth($sid);
     $this->initIlias();
     if (!$this->__checkSession($sid)) {
         return $this->__raiseError($this->__getMessage(), $this->__getMessageCode());
     }
     if (!is_numeric($target_id)) {
         return $this->__raiseError('No valid target id given. Please choose an existing reference id of an ILIAS category', 'Client');
     }
     global $rbacsystem;
     if (!($target_obj =& ilObjectFactory::getInstanceByRefId($target_id, false))) {
         return $this->__raiseError('No valid target given.', 'Client');
     }
     if (ilObject::_isInTrash($target_id)) {
         return $this->__raiseError("Parent with ID {$target_id} has been deleted.", 'CLIENT_OBJECT_DELETED');
     }
     if (!$rbacsystem->checkAccess('create', $target_id, 'crs')) {
         return $this->__raiseError('Check access failed. No permission to create courses', 'Server');
     }
     // Start import
     include_once "Modules/Course/classes/class.ilObjCourse.php";
     $newObj = new ilObjCourse();
     $newObj->setType('crs');
     $newObj->setTitle('dummy');
     $newObj->setDescription("");
     $newObj->create(true);
     // true for upload
     $newObj->createReference();
     $newObj->putInTree($target_id);
     $newObj->setPermissions($target_id);
     include_once 'Modules/Course/classes/class.ilCourseXMLParser.php';
     $xml_parser = new ilCourseXMLParser($newObj);
     $xml_parser->setXMLContent($crs_xml);
     $xml_parser->startParsing();
     return $newObj->getRefId() ? $newObj->getRefId() : "0";
 }
 /**
  * Returns the parent object of the role folder object which contains the specified role.
  */
 function getCourseMembersObjectForRole($a_role_id)
 {
     global $rbacreview, $rbacadmin, $tree;
     if (array_key_exists($a_role_id . '_courseMembersObject', $this->localRoleCache)) {
         return $this->localRoleCache[$a_role_id . '_courseMembersObject'];
     } else {
         require_once "Modules/Course/classes/class.ilObjCourse.php";
         require_once "Modules/Course/classes/class.ilCourseParticipants.php";
         $rolf_refs = $rbacreview->getFoldersAssignedToRole($a_role_id, true);
         $course_ref = $tree->getParentId($rolf_refs[0]);
         $course_obj = new ilObjCourse($course_ref, true);
         $crsmembers_obj = ilCourseParticipants::_getInstanceByObjId($course_obj->getId());
         $this->localRoleCache[$a_role_id . '_courseMembersObject'] = $crsmembers_obj;
         return $crsmembers_obj;
     }
 }
 /**
  * Modify Item ListGUI for presentation in container
  */
 function modifyItemGUI($a_item_list_gui, $a_item_data, $a_show_path)
 {
     global $tree;
     // if folder is in a course, modify item list gui according to course requirements
     if ($course_ref_id = $tree->checkForParentType($this->object->getRefId(), 'crs')) {
         // #10611
         include_once "Services/Object/classes/class.ilObjectActivation.php";
         ilObjectActivation::addListGUIActivationProperty($a_item_list_gui, $a_item_data);
         include_once "./Modules/Course/classes/class.ilObjCourse.php";
         include_once "./Modules/Course/classes/class.ilObjCourseGUI.php";
         $course_obj_id = ilObject::_lookupObjId($course_ref_id);
         ilObjCourseGUI::_modifyItemGUI($a_item_list_gui, get_class($this), $a_item_data, $a_show_path, ilObjCourse::_lookupAboStatus($course_obj_id), $course_ref_id, $course_obj_id, $this->object->getRefId());
     }
 }
Example #10
0
 function _checkGoto($a_target)
 {
     global $objDefinition, $ilPluginAdmin, $ilUser;
     if (is_object($ilPluginAdmin)) {
         // get user interface plugins
         $pl_names = $ilPluginAdmin->getActivePluginsForSlot(IL_COMP_SERVICE, "UIComponent", "uihk");
         // search
         foreach ($pl_names as $pl) {
             $ui_plugin = ilPluginAdmin::getPluginObject(IL_COMP_SERVICE, "UIComponent", "uihk", $pl);
             $gui_class = $ui_plugin->getUIClassInstance();
             $resp = $gui_class->checkGotoHook($a_target);
             if ($resp["target"] !== false) {
                 $a_target = $resp["target"];
                 break;
             }
         }
     }
     if ($a_target == "") {
         return false;
     }
     $t_arr = explode("_", $a_target);
     $type = $t_arr[0];
     if ($type == "git") {
         $type = "glo";
     }
     if ($type == "pg" | $type == "st") {
         $type = "lm";
     }
     $class = $objDefinition->getClassName($type);
     if ($class == "") {
         return false;
     }
     $location = $objDefinition->getLocation($type);
     $full_class = "ilObj" . $class . "Access";
     include_once $location . "/class." . $full_class . ".php";
     $ret = call_user_func(array($full_class, "_checkGoto"), $a_target);
     // if no access and repository object => check for parent course/group
     if (!$ret && !stristr($a_target, "_wsp") && $ilUser->getId() != ANONYMOUS_USER_ID && !$objDefinition->isAdministrationObject($type) && $objDefinition->isRBACObject($type) && $t_arr[1]) {
         global $tree, $rbacsystem, $ilAccess;
         // original type "pg" => pg_<page_id>[_<ref_id>]
         if ($t_arr[0] == "pg") {
             if (isset($t_arr[2])) {
                 $ref_id = $t_arr[2];
             } else {
                 $lm_id = ilLMObject::_lookupContObjID($t_arr[1]);
                 $ref_id = ilObject::_getAllReferences($lm_id);
                 if ($ref_id) {
                     $ref_id = array_shift($ref_id);
                 }
             }
         } else {
             $ref_id = $t_arr[1];
         }
         include_once "Services/Membership/classes/class.ilParticipants.php";
         $block_obj = array();
         // walk path to find parent container
         $path = $tree->getPathId($ref_id);
         array_pop($path);
         foreach ($path as $path_ref_id) {
             $redirect_infopage = false;
             $add_member_role = false;
             $ptype = ilObject::_lookupType($path_ref_id, true);
             $pobj_id = ilObject::_lookupObjId($path_ref_id);
             // core checks: timings/object-specific
             if (!$ilAccess->doActivationCheck("read", "", $path_ref_id, $ilUser->getId(), $pobj_id, $ptype) || !$ilAccess->doStatusCheck("read", "", $path_ref_id, $ilUser->getId(), $pobj_id, $ptype)) {
                 // object in path is inaccessible - aborting
                 return false;
             } else {
                 if ($ptype == "crs") {
                     // check if already participant
                     include_once "Modules/Course/classes/class.ilCourseParticipant.php";
                     $participants = new ilCourseParticipant($pobj_id, $ilUser->getId());
                     if (!$participants->isAssigned()) {
                         // subscription currently possible?
                         include_once "Modules/Course/classes/class.ilObjCourse.php";
                         if (ilObjCourse::_isActivated($pobj_id) && ilObjCourse::_registrationEnabled($pobj_id)) {
                             $block_obj[] = $path_ref_id;
                             $add_member_role = true;
                         } else {
                             $redirect_infopage = true;
                         }
                     }
                 } else {
                     if ($ptype == "grp") {
                         // check if already participant
                         include_once "Modules/Group/classes/class.ilGroupParticipants.php";
                         if (!ilGroupParticipants::_isParticipant($path_ref_id, $ilUser->getId())) {
                             // subscription currently possible?
                             include_once "Modules/Group/classes/class.ilObjGroup.php";
                             $group_obj = new ilObjGroup($path_ref_id);
                             if ($group_obj->isRegistrationEnabled()) {
                                 $block_obj[] = $path_ref_id;
                                 $add_member_role = true;
                             } else {
                                 $redirect_infopage = true;
                             }
                         }
                     }
                 }
             }
             // add members roles for all "blocking" objects
             if ($add_member_role) {
                 // cannot join? goto will never work, so redirect to current object
                 $rbacsystem->resetPACache($ilUser->getId(), $path_ref_id);
                 if (!$rbacsystem->checkAccess("join", $path_ref_id)) {
                     $redirect_infopage = true;
                 } else {
                     $rbacsystem->addTemporaryRole($ilUser->getId(), ilParticipants::getDefaultMemberRole($path_ref_id));
                 }
             }
             // redirect to infopage of 1st blocking object in path
             if ($redirect_infopage) {
                 if ($rbacsystem->checkAccess("visible", $path_ref_id)) {
                     ilUtil::redirect("ilias.php?baseClass=ilRepositoryGUI" . "&ref_id=" . $path_ref_id . "&cmd=infoScreen");
                 } else {
                     return false;
                 }
             }
         }
         // check if access will be possible with all (possible) member roles added
         $rbacsystem->resetPACache($ilUser->getId(), $ref_id);
         if ($rbacsystem->checkAccess("read", $ref_id) && sizeof($block_obj)) {
             // this won't work with lm-pages (see above)
             // include_once "Services/Link/classes/class.ilLink.php";
             // $_SESSION["pending_goto"] = ilLink::_getStaticLink($ref_id, $type);
             // keep original target
             $_SESSION["pending_goto"] = "goto.php?target=" . $a_target;
             // redirect to 1st non-member object in path
             ilUtil::redirect("ilias.php?baseClass=ilRepositoryGUI" . "&ref_id=" . array_shift($block_obj));
         }
     }
     return $ret;
 }
Example #11
0
 public function getUserCourse($courseId)
 {
     global $ilUser, $ilObjDataCache;
     $this->log($courseId);
     $items = ilParticipants::_getMembershipByType($ilUser->getId(), 'crs');
     foreach ($items as $obj_id) {
         $this->log($obj_id . " :: " . $courseId);
         if ($obj_id == $courseId) {
             $crs = new ilObjCourse($obj_id, false);
             $crs->read();
             $title = $crs->getTitle();
             $description = $crs->getDescription();
             // $this->log($crs->getOfflineStatus());
             if ($crs->getOfflineStatus() == 1) {
                 // skip offline courses
                 continue;
             }
             $course = array("id" => $obj_id, "title" => $title, "description" => $description);
             // 2 get course objects
             $item_references = ilObject::_getAllReferences($obj_id);
             reset($item_references);
             if (strcmp($this->iliasVersion, "4.2") === 0) {
                 foreach ($item_references as $ref_id => $x) {
                     // Antique Ilias
                     // For some strange reason remains the $crs->getRefId() remains empty
                     $crs = new ilObjCourse($ref_id);
                     // TODO: Verify that the course is online
                     // TODO: If the course is offline, check if the user is admin.
                     // TODO: skip offline student courses
                     require_once 'Modules/Course/classes/class.ilCourseItems.php';
                     $courseItems = new ilCourseItems($crs->getRefId(), 0, $ilUser->getId());
                     $courseItemList = $courseItems->getAllItems();
                     $course["content-type"] = $this->mapItemTypes($courseItemList, false);
                     break;
                 }
             } else {
                 // Modern Ilias
                 foreach ($item_references as $ref_id => $x) {
                     $crs = new ilObjCourse($ref_id);
                     // TODO: Verify that the course is online
                     // TODO: If the course is offline, check if the user is admin.
                     // TODO: skip offline student courses
                     $courseItemList = $crs->getSubItems();
                     // TODO check with Ilias 4.4 and 4.3
                     //                    $this->log(">>> IL >>> " . json_encode($courseItemList["_all"]));
                     $course["content-type"] = $this->mapItemTypes($courseItemList, true);
                 }
             }
             return $course;
         }
     }
     return null;
 }
 /**
  * Create course data from json
  * @return ilObjCourse
  */
 protected function createCourseData($course)
 {
     include_once './Modules/Course/classes/class.ilObjCourse.php';
     $course_obj = new ilObjCourse();
     $title = $course->title;
     $GLOBALS['ilLog']->write(__METHOD__ . ': Creating new course instance from ecs : ' . $title);
     $course_obj->setTitle($title);
     $course_obj->create();
     return $course_obj;
 }
Example #13
0
 /**
  * translate view mode 
  * @param int $a_obj_id
  * @param int $a_view_mode
  * @param int $a_ref_id
  * @return int 
  */
 protected static function translateViewMode($a_obj_id, $a_view_mode, $a_ref_id = null)
 {
     global $tree;
     if (!$a_view_mode) {
         $a_view_mode = ilContainer::VIEW_DEFAULT;
     }
     // view mode is inherit => check for parent course
     if ($a_view_mode == ilContainer::VIEW_INHERIT) {
         if (!$a_ref_id) {
             $ref = ilObject::_getAllReferences($a_obj_id);
             $a_ref_id = end($ref);
         }
         $crs_ref = $tree->checkForParentType($a_ref_id, 'crs');
         if (!$crs_ref) {
             return ilContainer::VIEW_DEFAULT;
         }
         include_once './Modules/Course/classes/class.ilObjCourse.php';
         $view_mode = ilObjCourse::_lookupViewMode(ilObject::_lookupObjId($crs_ref));
         // validate course view mode
         if (!in_array($view_mode, array(ilContainer::VIEW_SESSIONS, ilContainer::VIEW_BY_TYPE, ilContainer::VIEW_SIMPLE))) {
             return ilContainer::VIEW_DEFAULT;
         }
         return $view_mode;
     }
     return $a_view_mode;
 }
 function _checkObjectives($a_obj_id)
 {
     global $ilDB, $ilObjDataCache;
     // Return deactivate for course with objective view
     if ($ilObjDataCache->lookupType($a_obj_id) == 'crs') {
         include_once 'Modules/Course/classes/class.ilObjCourse.php';
         if (ilObjCourse::_lookupViewMode($a_obj_id) == IL_CRS_VIEW_OBJECTIVE) {
             return true;
         }
     }
     return false;
 }
 /**
  * checks wether a single condition is fulfilled
  * every trigger object type must implement a static method
  * _checkCondition($a_operator, $a_value)
  */
 function _checkCondition($a_id, $a_usr_id = 0)
 {
     global $ilUser;
     $a_usr_id = $a_usr_id ? $a_usr_id : $ilUser->getId();
     $condition = ilConditionHandler::_getCondition($a_id);
     switch ($condition['trigger_type']) {
         case "tst":
             include_once './Modules/Test/classes/class.ilObjTestAccess.php';
             return ilObjTestAccess::_checkCondition($condition['trigger_obj_id'], $condition['operator'], $condition['value'], $a_usr_id);
         case "crs":
             include_once './Modules/Course/classes/class.ilObjCourse.php';
             return ilObjCourse::_checkCondition($condition['trigger_obj_id'], $condition['operator'], $condition['value'], $a_usr_id);
         case 'exc':
             include_once './Modules/Exercise/classes/class.ilObjExercise.php';
             return ilObjExercise::_checkCondition($condition['trigger_obj_id'], $condition['operator'], $condition['value'], $a_usr_id);
         case 'crsg':
             include_once './Modules/Course/classes/class.ilObjCourseGrouping.php';
             return ilObjCourseGrouping::_checkCondition($condition['trigger_obj_id'], $condition['operator'], $condition['value'], $a_usr_id);
         case 'sahs':
             include_once './Services/Tracking/classes/class.ilLPStatus.php';
             return ilLPStatus::_lookupStatus($condition['trigger_obj_id'], $a_usr_id) == LP_STATUS_COMPLETED_NUM;
         case 'svy':
             include_once './Modules/Survey/classes/class.ilObjSurvey.php';
             return ilObjSurvey::_checkCondition($condition['trigger_obj_id'], $condition['operator'], $condition['value'], $a_usr_id);
         default:
             return false;
     }
 }
 /**
  * Modify Item ListGUI for presentation in container
  */
 function modifyItemGUI($a_item_list_gui, $a_item_data, $a_show_path)
 {
     global $tree;
     // if folder is in a course, modify item list gui according to course requirements
     if ($course_ref_id = $tree->checkForParentType($this->object->getRefId(), 'crs')) {
         include_once "./Modules/Course/classes/class.ilObjCourse.php";
         include_once "./Modules/Course/classes/class.ilObjCourseGUI.php";
         $course_obj_id = ilObject::_lookupObjId($course_ref_id);
         ilObjCourseGUI::_modifyItemGUI($a_item_list_gui, 'ilcoursecontentgui', $a_item_data, $a_show_path, ilObjCourse::_lookupAboStatus($course_obj_id), $course_ref_id, $course_obj_id, $this->object->getRefId());
     }
 }
 /**
  * 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(" &rsaquo; ", $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;
 }
Example #19
0
 /**
  * Generate courses
  *
  * @param
  * @return
  */
 function generateCourses($a_start = 1, $a_end = 500, $a_course_per_cat = 10, $a_title_base = "Course")
 {
     global $tree;
     include_once "./Modules/Course/classes/class.ilObjCourse.php";
     $this->log("Creating Courses");
     $a_current = $a_start;
     // how many categories do we need?
     $needed_cats = ceil(($a_end - $a_start + 1) / $a_course_per_cat);
     // get all categories and sort them by depth
     $nodes = $tree->getFilteredSubTree($tree->getRootId(), array("adm", "crs", "fold", "grp"));
     $nodes = ilUtil::sortArray($nodes, "depth", "desc");
     foreach ($nodes as $node) {
         if ($node["type"] == "cat" && $a_current <= $a_end) {
             for ($i = 1; $i <= $a_course_per_cat; $i++) {
                 if ($a_current <= $a_end) {
                     $this->log($a_title_base . " " . $a_current);
                     $new_crs = new ilObjCourse();
                     $new_crs->setTitle($a_title_base . " " . $a_current);
                     $new_crs->create();
                     $new_crs->createReference();
                     $new_crs->putInTree($node["child"]);
                     $new_crs->setPermissions($node["child"]);
                     $a_current++;
                 }
             }
         }
     }
 }
Example #20
0
 /**
  * We need a static version of this, e.g. in folders of the course
  */
 static function _modifyItemGUI($a_item_list_gui, $a_cmd_class, $a_item_data, $a_show_path, $a_abo_status, $a_course_ref_id, $a_course_obj_id, $a_parent_ref_id = 0)
 {
     global $lng, $ilAccess;
     // this is set for folders within the course
     if ($a_parent_ref_id == 0) {
         $a_parent_ref_id = $a_course_ref_id;
     }
     // Special handling for tests in courses with learning objectives
     if ($a_item_data['type'] == 'tst' and ilObjCourse::_lookupViewMode($a_course_obj_id) == ilContainer::VIEW_OBJECTIVE) {
         $a_item_list_gui->addCommandLinkParameter(array('crs_show_result' => $a_course_ref_id));
     }
     $a_item_list_gui->enableSubscribe($a_abo_status);
     $is_tutor = $ilAccess->checkAccess('write', '', $a_course_ref_id, 'crs', $a_course_obj_id);
     if ($a_show_path and $is_tutor) {
         $a_item_list_gui->addCustomProperty($lng->txt('path'), ilContainer::_buildPath($a_item_data['ref_id'], $a_course_ref_id), false, true);
     }
 }
Example #21
0
 protected function forwardToTimingsView()
 {
     global $tree;
     if (!($crs_ref = $tree->checkForParentType($this->ref_id, 'crs'))) {
         return false;
     }
     include_once './Modules/Course/classes/class.ilObjCourse.php';
     if (!$this->ctrl->getCmd() and ilObjCourse::_lookupViewMode(ilObject::_lookupObjId($crs_ref)) == ilContainer::VIEW_TIMING) {
         if (!isset($_SESSION['crs_timings'])) {
             $_SESSION['crs_timings'] = true;
         }
         if ($_SESSION['crs_timings'] == true) {
             include_once './Modules/Course/classes/class.ilCourseContentGUI.php';
             $course_content_obj = new ilCourseContentGUI($this);
             $this->ctrl->setCmdClass(get_class($course_content_obj));
             $this->ctrl->setCmd('editUserTimings');
             $this->ctrl->forwardCommand($course_content_obj);
             return true;
         }
     }
     $_SESSION['crs_timings'] = false;
     return false;
 }
 /**
  * Get all objects with enabled access codes
  * @param string $a_code
  * @return 
  */
 protected static function lookupObjectsByCode($a_code)
 {
     include_once './Modules/Group/classes/class.ilObjGroup.php';
     include_once './Modules/Course/classes/class.ilObjCourse.php';
     return array_merge(ilObjGroup::lookupObjectsByCode($a_code), ilObjCourse::lookupObjectsByCode($a_code));
 }
 /**
  * Check if (current) user has access to the participant list
  * @param type $a_obj
  * @param type $a_usr_id
  */
 public static function hasParticipantListAccess($a_obj_id, $a_usr_id = null)
 {
     if (!$a_usr_id) {
         $a_usr_id = $GLOBALS['ilUser']->getId();
     }
     // if write access granted => return true
     $refs = ilObject::_getAllReferences($a_obj_id);
     $ref_id = end($refs);
     if ($GLOBALS['ilAccess']->checkAccess('write', '', $ref_id)) {
         return true;
     }
     $part = self::getInstanceByObjId($a_obj_id);
     if ($part->isAssigned($a_usr_id)) {
         if ($part->getType() == 'crs') {
             // Check for show_members
             include_once './Modules/Course/classes/class.ilObjCourse.php';
             if (!ilObjCourse::lookupShowMembersEnabled($a_obj_id)) {
                 return false;
             }
         }
         return true;
     }
     // User is not assigned to course/group => no read access
     return false;
 }
Example #24
0
 /**
  * deletes a user
  * @access	public
  * @param	integer		user_id
  */
 function delete()
 {
     global $rbacadmin, $ilDB;
     // deassign from ldap groups
     include_once 'Services/LDAP/classes/class.ilLDAPRoleGroupMapping.php';
     $mapping = ilLDAPRoleGroupMapping::_getInstance();
     $mapping->deleteUser($this->getId());
     // remove mailbox / update sent mails
     include_once "Services/Mail/classes/class.ilMailbox.php";
     $mailbox = new ilMailbox($this->getId());
     $mailbox->delete();
     $mailbox->updateMailsOfDeletedUser($this->getLogin());
     // delete feed blocks on personal desktop
     include_once "./Services/Block/classes/class.ilCustomBlock.php";
     $costum_block = new ilCustomBlock();
     $costum_block->setContextObjId($this->getId());
     $costum_block->setContextObjType("user");
     $c_blocks = $costum_block->queryBlocksForContext();
     include_once "./Services/Feeds/classes/class.ilPDExternalFeedBlock.php";
     foreach ($c_blocks as $c_block) {
         if ($c_block["type"] == "pdfeed") {
             $fb = new ilPDExternalFeedBlock($c_block["id"]);
             $fb->delete();
         }
     }
     // delete block settings
     include_once "./Services/Block/classes/class.ilBlockSetting.php";
     ilBlockSetting::_deleteSettingsOfUser($this->getId());
     // delete user_account
     $ilDB->manipulateF("DELETE FROM usr_data WHERE usr_id = %s", array("integer"), array($this->getId()));
     // delete user_prefs
     ilObjUser::_deleteAllPref($this->getId());
     // delete user_session
     include_once "./Services/Authentication/classes/class.ilSession.php";
     ilSession::_destroyByUserId($this->getId());
     // remove user from rbac
     $rbacadmin->removeUser($this->getId());
     // remove bookmarks
     // TODO: move this to class.ilBookmarkFolder
     $q = "DELETE FROM bookmark_tree WHERE tree = " . $ilDB->quote($this->getId(), "integer");
     $ilDB->manipulate($q);
     $q = "DELETE FROM bookmark_data WHERE user_id = " . $ilDB->quote($this->getId(), "integer");
     $ilDB->manipulate($q);
     // DELETE FORUM ENTRIES (not complete in the moment)
     include_once './Modules/Forum/classes/class.ilObjForum.php';
     ilObjForum::_deleteUser($this->getId());
     // Delete link check notify entries
     include_once './Services/LinkChecker/classes/class.ilLinkCheckNotify.php';
     ilLinkCheckNotify::_deleteUser($this->getId());
     // Delete crs entries
     include_once './Modules/Course/classes/class.ilObjCourse.php';
     ilObjCourse::_deleteUser($this->getId());
     // Delete user tracking
     include_once './Services/Tracking/classes/class.ilObjUserTracking.php';
     ilObjUserTracking::_deleteUser($this->getId());
     include_once 'Modules/Session/classes/class.ilEventParticipants.php';
     ilEventParticipants::_deleteByUser($this->getId());
     // Delete Tracking data SCORM 2004 RTE
     include_once 'Modules/Scorm2004/classes/ilSCORM13Package.php';
     ilSCORM13Package::_removeTrackingDataForUser($this->getId());
     // Delete Tracking data SCORM 1.2 RTE
     include_once 'Modules/ScormAicc/classes/class.ilObjSCORMLearningModule.php';
     ilObjSCORMLearningModule::_removeTrackingDataForUser($this->getId());
     // remove all notifications
     include_once "./Services/Notification/classes/class.ilNotification.php";
     ilNotification::removeForUser($this->getId());
     // remove portfolios
     include_once "./Modules/Portfolio/classes/class.ilObjPortfolio.php";
     ilObjPortfolio::deleteUserPortfolios($this->getId());
     // remove workspace
     include_once "./Services/PersonalWorkspace/classes/class.ilWorkspaceTree.php";
     $tree = new ilWorkspaceTree($this->getId());
     $tree->cascadingDelete();
     // remove disk quota entries
     include_once "./Services/DiskQuota/classes/class.ilDiskQuotaHandler.php";
     ilDiskQuotaHandler::deleteByOwner($this->getId());
     // Delete user defined field entries
     $this->deleteUserDefinedFieldEntries();
     // Delete clipboard entries
     $this->clipboardDeleteAll();
     // Reset owner
     $this->resetOwner();
     // Trigger deleteUser Event
     global $ilAppEventHandler;
     $ilAppEventHandler->raise('Services/User', 'deleteUser', array('usr_id' => $this->getId()));
     // delete object data
     parent::delete();
     return true;
 }