How to use the canvasapi.paginated_list.PaginatedList function in canvasapi

To help you get started, we’ve selected a few canvasapi examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github ucfopen / canvasapi / tests / test_quiz.py View on Github external
def test_get_submissions(self, m):
        register_uris({"quiz": ["get_all_quiz_submissions"]}, m)
        submissions = self.quiz.get_submissions()

        self.assertIsInstance(submissions, PaginatedList)

        submission_list = [sub for sub in submissions]

        self.assertEqual(len(submission_list), 2)

        self.assertIsInstance(submission_list[0], QuizSubmission)
        self.assertEqual(submission_list[0].id, 1)
        self.assertTrue(hasattr(submission_list[0], "attempt"))
        self.assertEqual(submission_list[0].attempt, 3)

        self.assertIsInstance(submission_list[1], QuizSubmission)
        self.assertEqual(submission_list[1].id, 2)
        self.assertTrue(hasattr(submission_list[1], "score"))
        self.assertEqual(submission_list[1].score, 5)
github ucfopen / canvasapi / canvasapi / outcome.py View on Github external
def get_subgroups(self, **kwargs):
        """
        List subgroups.

        :calls: `GET /api/v1/global/outcome_groups/:id/subgroups \
            `_
            or `GET /api/v1/accounts/:account_id/outcome_groups/:id/subgroups \
            `_
            or `GET /api/v1/courses/:course_id/outcome_groups/:id/subgroups \
            `_

        :returns: Paginated List of OutcomeGroups linked to the current group.
        :rtype: :class:`canvasapi.paginated_list.PaginatedList` of
            :class:`canvasapi.outcome.OutcomeGroup`
        """
        return PaginatedList(
            OutcomeGroup,
            self._requester,
            'GET',
            '{}/outcome_groups/{}/subgroups'.format(self.context_ref(), self.id),
            {'context_type': self.context_type, 'context_id': self.context_id},
            _kwargs=combine_kwargs(**kwargs)
        )
github ucfopen / canvasapi / canvasapi / page.py View on Github external
def get_revisions(self, **kwargs):
        """
        List the revisions of a page.

        :calls: `GET /api/v1/courses/:course_id/pages/:url/revisions \
        `_

        :rtype: :class:`canvasapi.paginated_list.PaginatedList` of
            :class:`canvasapi.pagerevision.PageRevision`
        """
        return PaginatedList(
            PageRevision,
            self._requester,
            'GET',
            '{}s/{}/pages/{}/revisions'.format(self.parent_type, self.parent_id, self.url),
            _kwargs=combine_kwargs(**kwargs)
        )
github ucfopen / canvasapi / canvasapi / course.py View on Github external
def get_discussion_topics(self, **kwargs):
        """
        Returns the paginated list of discussion topics for this course or group.

        :calls: `GET /api/v1/courses/:course_id/discussion_topics \
        `_

        :rtype: :class:`canvasapi.paginated_list.PaginatedList` of
            :class:`canvasapi.discussion_topic.DiscussionTopic`
        """
        return PaginatedList(
            DiscussionTopic,
            self._requester,
            "GET",
            "courses/{}/discussion_topics".format(self.id),
            {"course_id": self.id},
            _kwargs=combine_kwargs(**kwargs),
        )
github ucfopen / canvasapi / canvasapi / course.py View on Github external
Note: All current overridden values must be supplied if they are to be retained.

        :calls: `PUT /api/v1/courses/:course_id/assignments/overrides \
        `_

        :param assignment_overrides: Attributes for the updated assignment overrides.
        :type assignment_overrides: list

        :rtype: :class:`canvasapi.paginated_list.PaginatedList` of
            :class:`canvasapi.assignment.AssignmentOverride`
        """
        from canvasapi.assignment import AssignmentOverride

        kwargs["assignment_overrides"] = assignment_overrides

        return PaginatedList(
            AssignmentOverride,
            self._requester,
            "PUT",
            "courses/{}/assignments/overrides".format(self.id),
            {"course_id": self.id},
            _kwargs=combine_kwargs(**kwargs),
        )
github ucfopen / canvasapi / canvasapi / canvas.py View on Github external
def get_announcements(self, **kwargs):
        """
        List announcements.

        :calls: `GET /api/v1/announcements \
        `_

        :rtype: :class:`canvasapi.paginated_list.PaginatedList` of
                :class:`canvasapi.discussion_topic.DiscussionTopic`
        """
        from canvasapi.discussion_topic import DiscussionTopic

        return PaginatedList(
            DiscussionTopic,
            self.__requester,
            "GET",
            "announcements",
            _kwargs=combine_kwargs(**kwargs),
        )
github ucfopen / canvasapi / canvasapi / quiz.py View on Github external
def get_questions(self, **kwargs):
        """
        List all questions for a quiz.

        :calls: `GET /api/v1/courses/:course_id/quizzes/:quiz_id/questions \
        `_

        :rtype: :class:`canvasapi.paginated_list.PaginatedList` of
            :class:`canvasapi.quiz.QuizQuestion`
        """
        return PaginatedList(
            QuizQuestion,
            self._requester,
            "GET",
            "courses/{}/quizzes/{}/questions".format(self.course_id, self.id),
            {"course_id": self.course_id},
            _kwargs=combine_kwargs(**kwargs),
        )
github ucfopen / canvasapi / canvasapi / group.py View on Github external
def get_files(self, **kwargs):
        """
        Returns the paginated list of files for the group.

        :calls: `GET /api/v1/groups/:group_id/files \
        `_

        :rtype: :class:`canvasapi.paginated_list.PaginatedList` of
            :class:`canvasapi.file.File`
        """
        from canvasapi.file import File

        return PaginatedList(
            File,
            self._requester,
            "GET",
            "groups/{}/files".format(self.id),
            _kwargs=combine_kwargs(**kwargs),
        )
github ucfopen / canvasapi / canvasapi / account.py View on Github external
def get_external_tools(self, **kwargs):
        """
        :calls: `GET /api/v1/accounts/:account_id/external_tools \
        `_

        :rtype: :class:`canvasapi.paginated_list.PaginatedList` of
            :class:`canvasapi.external_tool.ExternalTool`
        """
        from canvasapi.external_tool import ExternalTool

        return PaginatedList(
            ExternalTool,
            self._requester,
            "GET",
            "accounts/{}/external_tools".format(self.id),
            {"account_id": self.id},
            _kwargs=combine_kwargs(**kwargs),
        )
github ucfopen / canvasapi / canvasapi / course.py View on Github external
def get_features(self, **kwargs):
        """
        Lists all features of a course.

        :calls: `GET /api/v1/courses/:course_id/features \
        `_

        :rtype: :class:`canvasapi.paginated_list.PaginatedList` of
            :class:`canvasapi.feature.Feature`
        """
        return PaginatedList(
            Feature,
            self._requester,
            "GET",
            "courses/{}/features".format(self.id),
            {"course_id": self.id},
            _kwargs=combine_kwargs(**kwargs),
        )