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; }
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; }