示例#1
0
    def get_section(self, section, use_sis_id=False, **kwargs):
        """
        Get details about a specific section.

        :calls: `GET /api/v1/sections/:id \
        <https://canvas.instructure.com/doc/api/sections.html#method.sections.show>`_

        :param section: The object or ID of the section to get.
        :type section: :class:`canvasapi.section.Section` or int
        :param use_sis_id: Whether or not section_id is an sis ID.
            Defaults to `False`.
        :type use_sis_id: bool

        :rtype: :class:`canvasapi.section.Section`
        """
        if use_sis_id:
            section_id = section
            uri_str = 'sections/sis_section_id:{}'
        else:
            section_id = obj_or_id(section, "section", (Section, ))
            uri_str = 'sections/{}'

        response = self.__requester.request('GET',
                                            uri_str.format(section_id),
                                            _kwargs=combine_kwargs(**kwargs))
        return Section(self.__requester, response.json())
示例#2
0
    def get_section(self, section_id):
        """
        Get details about a specific section.

        :calls: `GET /api/v1/sections/:id \
        <https://canvas.instructure.com/doc/api/sections.html#method.sections.show>`_

        :rtype: :class:`canvasapi.section.Section`
        """
        from canvasapi.section import Section
        response = self.__requester.request('GET',
                                            'sections/%s' % (section_id))
        return Section(self.__requester, response.json())
示例#3
0
def request_submissions(section: Section) -> List[Submission]:
    """
    Fetch Submissions API data for a range of assignments in a section and return a list of submissions as Submission API objects

    Parameters
    ----------
    section: Section
        a Canvas Section object

    Returns
    -------
    List[Submission]
        a list of Submission API objects
    """
    return section.get_multiple_submissions(student_ids="all")
示例#4
0
    def create_course_section(self, **kwargs):
        """
        Create a new section for this course.

        :calls: `POST /api/v1/courses/:course_id/sections \
        <https://canvas.instructure.com/doc/api/sections.html#method.sections.create>`_

        :rtype: :class:`canvasapi.course.Section`
        """

        from canvasapi.section import Section
        response = self._requester.request('POST',
                                           'courses/%s/sections' % (self.id),
                                           **combine_kwargs(**kwargs))

        return Section(self._requester, response.json())
示例#5
0
    def get_section(self, section_id):
        """
        Retrieve a section.

        :calls: `GET /api/v1/courses/:course_id/sections/:id \
        <https://canvas.instructure.com/doc/api/sections.html#method.sections.index>`_

        :param section_id: The ID of the section to retrieve.
        :type section_id: int
        :rtype: :class:`canvasapi.section.Section`
        """
        from canvasapi.section import Section

        response = self._requester.request(
            'GET', 'courses/%s/sections/%s' % (self.id, section_id))
        return Section(self._requester, response.json())
示例#6
0
def request_enrollments_for_section(section: Section) -> List[Enrollment]:
    """
    Fetch Enrollments API data for a section

    Parameters
    ----------
    canvas: Canvas
        a Canvas SDK object
    user: User
        a Canvas User object

    Returns
    -------
    List[Enrollment]
        a list of Enrollment API objects
    """
    return section.get_enrollments()