Given one course id, return one array with all the course_sections belonging to it
190312
public static function get_sections_from_courseid($courseid) {
        global $DB;

        // Get all sections belonging to requested course
        $sectionsarr = array();
        $sections = $DB->get_records('course_sections', array('course' => $courseid), 'section');
        foreach ($sections as $section) {
            $sectionsarr[] = $section->id;
        }
        return $sectionsarr;
    }
314226
public static function get_glossaries_by_courses($courseids = array()) {
        $params = self::validate_parameters(self::get_glossaries_by_courses_parameters(), array('courseids' => $courseids));

        $warnings = array();
        $courses = array();
        $courseids = $params['courseids'];

        if (empty($courseids)) {
            $courses = enrol_get_my_courses();
            $courseids = array_keys($courses);
        }

        // Array to store the glossaries to return.
        $glossaries = array();
        $modes = array();

        // Ensure there are courseids to loop through.
        if (!empty($courseids)) {
            list($courses, $warnings) = external_util::validate_courses($courseids, $courses);

            // Get the glossaries in these courses, this function checks users visibility permissions.
            $glossaries = get_all_instances_in_courses('glossary', $courses);
            foreach ($glossaries as $glossary) {
                $context = context_module::instance($glossary->coursemodule);
                $glossary->name = external_format_string($glossary->name, $context->id);
                list($glossary->intro, $glossary->introformat) = external_format_text($glossary->intro, $glossary->introformat,
                    $context->id, 'mod_glossary', 'intro', null);
                $glossary->introfiles = external_util::get_area_files($context->id, 'mod_glossary', 'intro', false, false);

                // Make sure we have a number of entries per page.
                if (!$glossary->entbypage) {
                    $glossary->entbypage = $CFG->glossary_entbypage;
                }

                // Add the list of browsing modes.
                if (!isset($modes[$glossary->displayformat])) {
                    $modes[$glossary->displayformat] = self::get_browse_modes_from_display_format($glossary->displayformat);
                }
                $glossary->browsemodes = $modes[$glossary->displayformat];
                $glossary->canaddentry = has_capability('mod/glossary:write', $context) ? 1 : 0;
            }
        }

        $result = array();
        $result['glossaries'] = $glossaries;
        $result['warnings'] = $warnings;
        return $result;
    }
341286
protected function load_courses() {
        global $DB;

        $courseids = [];
        foreach ($this->events as $event) {
            if ($course = $event->get_course()) {
                $id = $course->get('id');
                $courseids[$id] = true;
            }
        }

        if (empty($courseids)) {
            $this->courses = [];
            return;
        }

        list($idsql, $params) = $DB->get_in_or_equal(array_keys($courseids));
        $sql = "SELECT * FROM {course} WHERE id {$idsql}";

        $this->courses = $DB->get_records_sql($sql, $params);
    }
1204578
def show_page_courses(self, url, course_id):
        
        path = {}
        data = {}
        params = {}

        # REQUIRED - PATH - course_id
        """ID"""
        path["course_id"] = course_id

        # REQUIRED - PATH - url
        """ID"""
        path["url"] = url

        self.logger.debug("GET /api/v1/courses/{course_id}/pages/{url} with query params: {params} and form data: {data}".format(params=params, data=data, **path))
        return self.generic_request("GET", "/api/v1/courses/{course_id}/pages/{url}".format(**path), data=data, params=params, single_item=True)
900452
def _json_to_sectionref(data):
    
    section_term = None
    sections = []
    for section_data in data.get("Sections", []):
        if (section_term is None or
                section_data["Year"] != section_term.year or
                section_data["Quarter"] != section_term.quarter):
            section_term = get_term_by_year_and_quarter(
                section_data["Year"], section_data["Quarter"])
        section = SectionReference(
            term=section_term,
            curriculum_abbr=section_data["CurriculumAbbreviation"],
            course_number=section_data["CourseNumber"],
            section_id=section_data["SectionID"],
            url=section_data["Href"])
        sections.append(section)
    return sections
533421
def get_sections(self):
        
        try:
            obj_list = self.__dict__['sections']
            return [Section(i) for i in obj_list]
        except KeyError:
            self._lazy_load()
            obj_list = self.__dict__['sections']
            return [Section(i) for i in obj_list]
619092
def from_soup_tag(tag):
        ""
        sections = [Section.from_soup_tag(s) for s in tag.findAll('section')]
        return Course(
            tag['name'], tag['dept'], int(tag['num']), tag['credmin'],
            tag['credmax'], tag['gradetype'], [s for s in sections if s.is_valid]
        )
1197721
def _get_assessment_sections(self):
        """"""
        section_list = []
        for section_idstr in self._my_map['sections']:
            section_list.append(self._get_assessment_section(Id(section_idstr)))
        return AssessmentSectionList(section_list, runtime=self._runtime, proxy=self._proxy)
375324
def cross_list_section(self, id, new_course_id):
        
        path = {}
        data = {}
        params = {}

        # REQUIRED - PATH - id
        """ID"""
        path["id"] = id

        # REQUIRED - PATH - new_course_id
        """ID"""
        path["new_course_id"] = new_course_id

        self.logger.debug("POST /api/v1/sections/{id}/crosslist/{new_course_id} with query params: {params} and form data: {data}".format(params=params, data=data, **path))
        return self.generic_request("POST", "/api/v1/sections/{id}/crosslist/{new_course_id}".format(**path), data=data, params=params, single_item=True)
446606
def get_section_relations(Section):
    """"""
    all_rels = (Section._meta.get_all_related_objects() +
                Section._meta.get_all_related_many_to_many_objects())
    return filter_item_rels(all_rels)
915071
def list_courses(self):
        
        reply = get_page(self._session, OPENCOURSE_MEMBERSHIPS, json=True)
        course_list = reply['linked']['courses.v1']
        slugs = [element['slug'] for element in course_list]
        return slugs
1031025
public static function view_course($courseid, $sectionnumber = 0) {
        global $CFG;
        require_once($CFG->dirroot . "/course/lib.php");

        $params = self::validate_parameters(self::view_course_parameters(),
                                            array(
                                                'courseid' => $courseid,
                                                'sectionnumber' => $sectionnumber
                                            ));

        $warnings = array();

        $course = get_course($params['courseid']);
        $context = context_course::instance($course->id);
        self::validate_context($context);

        if (!empty($params['sectionnumber'])) {

            // Get section details and check it exists.
            $modinfo = get_fast_modinfo($course);
            $coursesection = $modinfo->get_section_info($params['sectionnumber'], MUST_EXIST);

            // Check user is allowed to see it.
            if (!$coursesection->uservisible) {
                require_capability('moodle/course:viewhiddensections', $context);
            }
        }

        course_view($context, $params['sectionnumber']);

        $result = array();
        $result['status'] = true;
        $result['warnings'] = $warnings;
        return $result;
    }
1035862
public static function get_pages_by_courses($courseids = array()) {

        $warnings = array();
        $returnedpages = array();

        $params = array(
            'courseids' => $courseids,
        );
        $params = self::validate_parameters(self::get_pages_by_courses_parameters(), $params);

        $mycourses = array();
        if (empty($params['courseids'])) {
            $mycourses = enrol_get_my_courses();
            $params['courseids'] = array_keys($mycourses);
        }

        // Ensure there are courseids to loop through.
        if (!empty($params['courseids'])) {

            list($courses, $warnings) = external_util::validate_courses($params['courseids'], $mycourses);

            // Get the pages in this course, this function checks users visibility permissions.
            // We can avoid then additional validate_context calls.
            $pages = get_all_instances_in_courses("page", $courses);
            foreach ($pages as $page) {
                $context = context_module::instance($page->coursemodule);
                // Entry to return.
                $page->name = external_format_string($page->name, $context->id);

                list($page->intro, $page->introformat) = external_format_text($page->intro,
                                                                $page->introformat, $context->id, 'mod_page', 'intro', null);
                $page->introfiles = external_util::get_area_files($context->id, 'mod_page', 'intro', false, false);

                $options = array('noclean' => true);
                list($page->content, $page->contentformat) = external_format_text($page->content, $page->contentformat,
                                                                $context->id, 'mod_page', 'content', $page->revision, $options);
                $page->contentfiles = external_util::get_area_files($context->id, 'mod_page', 'content');

                $returnedpages[] = $page;
            }
        }

        $result = array(
            'pages' => $returnedpages,
            'warnings' => $warnings
        );
        return $result;
    }
1180660
public static function get_course_blocks($courseid, $returncontents = false) {
        global $PAGE;

        $warnings = array();
        $params = self::validate_parameters(self::get_course_blocks_parameters(),
            ['courseid' => $courseid, 'returncontents' => $returncontents]);

        $course = get_course($params['courseid']);
        $context = context_course::instance($course->id);
        self::validate_context($context);

        // Specific layout for frontpage course.
        if ($course->id == SITEID) {
            $PAGE->set_pagelayout('frontpage');
            $PAGE->set_pagetype('site-index');
        } else {
            $PAGE->set_pagelayout('course');
            // Ensure course format is set (view course/view.php).
            $course->format = course_get_format($course)->get_format();
            $PAGE->set_pagetype('course-view-' . $course->format);
        }

        $allblocks = self::get_all_current_page_blocks(false, $params['returncontents']);

        return array(
            'blocks' => $allblocks,
            'warnings' => $warnings
        );
    }
1121262
public static function fetch_course_tree($courseid, $include_category_items=false) {
        $course_category = grade_category::fetch_course_category($courseid);
        $category_array = array('object'=>$course_category, 'type'=>'category', 'depth'=>1,
                                'children'=>$course_category->get_children($include_category_items));

        $course_category->sortorder = $course_category->get_sortorder();
        $sortorder = $course_category->get_sortorder();
        return grade_category::_fetch_course_tree_recursion($category_array, $sortorder);
    }
975902
def contents(self):
        

        params = self.request_params
        params.update({'wsfunction': 'core_course_get_contents',
                       'courseid': self.course_id})

        return requests.get(self.api_url, params=params, verify=False).json()
776761
def get_nts_sections(self, sections, sortby=None):
        """"""
        goids = self.get_goids_sections(sections)
        gosubdag = GoSubDag(goids, self.go2obj)
        return [(sec, gosubdag.get_nts(gos, sortby)) for sec, gos in sections]