コード例 #1
0
ファイル: canvas.py プロジェクト: Tobiaqs/canvasapi
    def set_course_nickname(self, course, nickname):
        """
        Set a nickname for the given course. This will replace the
        course's name in the output of subsequent API calls, as
        well as in selected places in the Canvas web user interface.

        :calls: `PUT /api/v1/users/self/course_nicknames/:course_id \
        <https://canvas.instructure.com/doc/api/users.html#method.course_nicknames.update>`_

        :param course: The ID of the course.
        :type course: :class:`canvasapi.course.Course` or int
        :param nickname: The nickname for the course.
        :type nickname: str

        :rtype: :class:`canvasapi.course.CourseNickname`
        """
        from canvasapi.course import CourseNickname

        course_id = obj_or_id(course, "course", (Course, ))

        response = self.__requester.request(
            'PUT',
            'users/self/course_nicknames/{}'.format(course_id),
            nickname=nickname)
        return CourseNickname(self.__requester, response.json())
コード例 #2
0
ファイル: canvas.py プロジェクト: allygator/canvasapi
    def get_course_nickname(self, course_id):
        """
        Return the nickname for the given course.

        :calls: `GET /api/v1/users/self/course_nicknames/:course_id \
        <https://canvas.instructure.com/doc/api/users.html#method.course_nicknames.show>`_

        :param course_id: The ID of the course.
        :type course_id: int
        :rtype: :class:`canvasapi.course.CourseNickname`
        """
        from canvasapi.course import CourseNickname

        response = self.__requester.request(
            'GET', 'users/self/course_nicknames/%s' % (course_id))
        return CourseNickname(self.__requester, response.json())
コード例 #3
0
ファイル: canvas.py プロジェクト: Tobiaqs/canvasapi
    def get_course_nickname(self, course):
        """
        Return the nickname for the given course.

        :calls: `GET /api/v1/users/self/course_nicknames/:course_id \
        <https://canvas.instructure.com/doc/api/users.html#method.course_nicknames.show>`_

        :param course: The object or ID of the course.
        :type course: :class:`canvasapi.course.Course` or int

        :rtype: :class:`canvasapi.course.CourseNickname`
        """
        from canvasapi.course import CourseNickname

        course_id = obj_or_id(course, "course", (Course, ))

        response = self.__requester.request(
            'GET', 'users/self/course_nicknames/{}'.format(course_id))
        return CourseNickname(self.__requester, response.json())