/** * From a moodle course_modinfo object, it creates an intuitel LO * @author elever * @see \intuitel\LOFactory::createLOFromNative() * @param \course_modinfo $rawData : moodle course_modinfo object * @return CourseLO $course : intuitelLO course object */ function createLOFromNative($rawData) { $lmscourse = $rawData->get_course(); $courseLoid = Intuitel::getIDFactory()->getLoIdfromId('course', $lmscourse->id); // course object is created, constructor sets the compulsory attributes: LOId, loName, hasPrecedingSib, hasParent; and the optional: hasFollowingSib $course = new CourseLO($courseLoid, $lmscourse->fullname, null, null); // optional attributes $courseLang = $this->getLang($rawData); $course->setLang($courseLang); $childrenLoId = $this->getChildren($rawData); $course->sethasChildren($childrenLoId); return $course; }
/** * get_activity_tree :: course_modinfo -> integer -> context -> array * @param \course_modinfo $modinfo * @param integer $section_number * @param \context $context * @return array */ function get_activity_tree(\course_modinfo $modinfo, $section_number, \context $context) { $completion_info = new \completion_info($modinfo->get_course()); return F\map(F\filter($modinfo->get_section_info_all(), function (\section_info $section_info) { return $section_info->visible; }), function (\section_info $section_info) use($completion_info, $section_number, $context) { $mods = F\map(F\filter($section_info->modinfo->cms, function (\cm_info $cm_info) use($section_info) { global $CFG; return ($cm_info->uservisible || $CFG->enableavailability && !empty($cm_info->availableinfo)) && (int) $cm_info->sectionnum === (int) $section_info->section; }), function (\cm_info $cm_info) use($completion_info, $context) { global $CFG; $canComplete = $CFG->enablecompletion && isloggedin() && !isguestuser() && (int) $completion_info->is_enabled($cm_info) === COMPLETION_TRACKING_MANUAL; $hasCompleted = false; if ($canComplete) { $completion_data = $completion_info->get_data($cm_info, true); $hasCompleted = F\contains([COMPLETION_COMPLETE, COMPLETION_COMPLETE_PASS], (int) $completion_data->completionstate); } return (object) ['id' => (int) $cm_info->id, 'name' => $cm_info->name, 'modname' => $cm_info->modname, 'current' => is_current_mod($cm_info, $context), 'available' => $cm_info->available, 'canComplete' => $canComplete, 'hasCompleted' => $hasCompleted]; }); return (object) ['id' => (int) $section_info->id, 'section' => (int) $section_info->section, 'name' => \get_section_name($section_info->modinfo->courseid, $section_info->section), 'current' => is_current_section($section_info, $section_number, $context), 'activities' => array_values($mods)]; }); }
/** * Implementation of IteratorAggregate::getIterator(), allows to cycle through properties * and use {@link convert_to_array()} * * @return ArrayIterator */ public function getIterator() { $ret = array(); foreach (get_object_vars($this) as $key => $value) { if (substr($key, 0, 1) == '_') { if (method_exists($this, 'get'.$key)) { $ret[substr($key, 1)] = $this->{'get'.$key}(); } else { $ret[substr($key, 1)] = $this->$key; } } } $ret['sequence'] = $this->get_sequence(); $ret['course'] = $this->get_course(); $ret = array_merge($ret, course_get_format($this->modinfo->get_course())->get_format_options($this->_section)); return new ArrayIterator($ret); }
/** * @return object Moodle course object that was used to construct this data */ public function get_course() { return $this->modinfo->get_course(); }
/** * Retrieves the forced language of the course of null if not forced language. * @param course_modinfo $course_info : course_modinfo object of the course * @return string|NULL $lang: forced language of the course or null if not language is forced */ function block_intuitel_get_course_lang($course_info) { $course = $course_info->get_course(); if ($course->lang != null) { $lang = block_intuitel_get_parent_lang($course->lang); } else { $lang = null; } return $lang; }