protected function getCoursesOfUser($a_user_id)
 {
     global $tree;
     // see ilPDSelectedItemsBlockGUI
     include_once 'Modules/Course/classes/class.ilObjCourseAccess.php';
     include_once 'Services/Membership/classes/class.ilParticipants.php';
     $items = ilParticipants::_getMembershipByType($a_user_id, 'crs');
     $references = $lp_obj_refs = array();
     foreach ($items as $obj_id) {
         $ref_id = ilObject::_getAllReferences($obj_id);
         if (is_array($ref_id) && count($ref_id)) {
             $ref_id = array_pop($ref_id);
             if (!$tree->isDeleted($ref_id)) {
                 $visible = false;
                 $active = ilObjCourseAccess::_isActivated($obj_id, $visible, false);
                 if ($active && $visible) {
                     $references[$ref_id] = array('ref_id' => $ref_id, 'obj_id' => $obj_id, 'title' => ilObject::_lookupTitle($obj_id));
                     $lp_obj_refs[$obj_id] = $ref_id;
                 }
             }
         }
     }
     // get lp data for valid courses
     if (sizeof($lp_obj_refs)) {
         // lp must be active, personal and not anonymized
         include_once "Services/Tracking/classes/class.ilObjUserTracking.php";
         if (ilObjUserTracking::_enabledLearningProgress() && ilObjUserTracking::_enabledUserRelatedData() && ilObjUserTracking::_hasLearningProgressLearner()) {
             // see ilLPProgressTableGUI
             include_once "Services/Tracking/classes/class.ilTrQuery.php";
             include_once "Services/Tracking/classes/class.ilLPStatusFactory.php";
             $lp_data = ilTrQuery::getObjectsStatusForUser($a_user_id, $lp_obj_refs);
             foreach ($lp_data as $item) {
                 $ref_id = $item["ref_ids"];
                 $references[$ref_id]["lp_status"] = $item["status"];
                 // add objectives
                 if ($item["u_mode"] == ilLPObjSettings::LP_MODE_OBJECTIVES) {
                     // we need the collection for the correct order
                     include_once "Services/Tracking/classes/collection/class.ilLPCollectionOfObjectives.php";
                     $coll_objtv = new ilLPCollectionOfObjectives($item["obj_id"], $item["u_mode"]);
                     $coll_objtv = $coll_objtv->getItems();
                     if ($coll_objtv) {
                         // #13373
                         $lo_results = $this->parseLOUserResults($item["obj_id"], $a_user_id);
                         $tmp = array();
                         include_once "Modules/Course/classes/class.ilCourseObjective.php";
                         foreach ($coll_objtv as $objective_id) {
                             $tmp[$objective_id] = array("id" => $objective_id, "title" => ilCourseObjective::lookupObjectiveTitle($objective_id));
                             if (array_key_exists($objective_id, $lo_results)) {
                                 $lo_result = $lo_results[$objective_id];
                                 $tmp[$objective_id]["result_perc"] = $lo_result["result_perc"];
                                 $tmp[$objective_id]["limit_perc"] = $lo_result["limit_perc"];
                                 $tmp[$objective_id]["status"] = $lo_result["status"];
                                 $tmp[$objective_id]["type"] = $lo_result["type"];
                             }
                         }
                         // order
                         foreach ($coll_objtv as $objtv_id) {
                             $references[$ref_id]["objectives"][] = $tmp[$objtv_id];
                         }
                     }
                 }
             }
         }
     }
     $references = ilUtil::sortArray($references, "title", "ASC");
     return $references;
 }
Esempio n. 2
0
 /**
  * Is activated. Method is in Access class, since it is needed by Access/ListGUI.
  *
  * @param int id of user
  * @return boolean
  */
 function _isActivated($a_obj_id)
 {
     include_once "./Modules/Course/classes/class.ilObjCourseAccess.php";
     return ilObjCourseAccess::_isActivated($a_obj_id);
 }
 protected function getCoursesOfUser($a_user_id, $a_add_path = false)
 {
     global $tree;
     // see ilPDSelectedItemsBlockGUI
     include_once 'Modules/Course/classes/class.ilObjCourseAccess.php';
     include_once 'Services/Membership/classes/class.ilParticipants.php';
     $items = ilParticipants::_getMembershipByType($a_user_id, 'crs');
     $repo_title = $tree->getNodeData(ROOT_FOLDER_ID);
     $repo_title = $repo_title["title"];
     if ($repo_title == "ILIAS") {
         $repo_title = $this->lng->txt("repository");
     }
     $references = $lp_obj_refs = array();
     foreach ($items as $obj_id) {
         $ref_id = ilObject::_getAllReferences($obj_id);
         if (is_array($ref_id) && count($ref_id)) {
             $ref_id = array_pop($ref_id);
             if (!$tree->isDeleted($ref_id)) {
                 $visible = false;
                 $active = ilObjCourseAccess::_isActivated($obj_id, $visible, false);
                 if ($active && $visible) {
                     $references[$ref_id] = array('ref_id' => $ref_id, 'obj_id' => $obj_id, 'title' => ilObject::_lookupTitle($obj_id));
                     if ($a_add_path) {
                         $path = array();
                         foreach ($tree->getPathFull($ref_id) as $item) {
                             $path[] = $item["title"];
                         }
                         // top level comes first
                         if (sizeof($path) == 2) {
                             $path[0] = 0;
                         } else {
                             $path[0] = 1;
                         }
                         $references[$ref_id]["path_sort"] = implode("__", $path);
                         array_shift($path);
                         array_pop($path);
                         if (!sizeof($path)) {
                             array_unshift($path, $repo_title);
                         }
                         $references[$ref_id]["path"] = implode(" › ", $path);
                     }
                     $lp_obj_refs[$obj_id] = $ref_id;
                 }
             }
         }
     }
     // get lp data for valid courses
     if (sizeof($lp_obj_refs)) {
         // listing the objectives should NOT depend on any LP status / setting
         include_once 'Modules/Course/classes/class.ilObjCourse.php';
         foreach ($lp_obj_refs as $obj_id => $ref_id) {
             // only if set in DB (default mode is not relevant
             if (ilObjCourse::_lookupViewMode($obj_id) == IL_CRS_VIEW_OBJECTIVE) {
                 $references[$ref_id]["objectives"] = $this->parseObjectives($obj_id, $a_user_id);
             }
         }
         // LP must be active, personal and not anonymized
         include_once "Services/Tracking/classes/class.ilObjUserTracking.php";
         if (ilObjUserTracking::_enabledLearningProgress() && ilObjUserTracking::_enabledUserRelatedData() && ilObjUserTracking::_hasLearningProgressLearner()) {
             // see ilLPProgressTableGUI
             include_once "Services/Tracking/classes/class.ilTrQuery.php";
             include_once "Services/Tracking/classes/class.ilLPStatusFactory.php";
             $lp_data = ilTrQuery::getObjectsStatusForUser($a_user_id, $lp_obj_refs);
             foreach ($lp_data as $item) {
                 $ref_id = $item["ref_ids"];
                 $references[$ref_id]["lp_status"] = $item["status"];
             }
         }
     }
     return $references;
 }