Exemplo n.º 1
0
    def create_discussion_topic(self, **kwargs):
        """
        Creates a new discussion topic for the course or group.

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

        :rtype: :class:`canvasapi.discussion_topic.DiscussionTopic`
        """
        response = self._requester.request(
            'POST', 'courses/%s/discussion_topics' % (self.id),
            **combine_kwargs(**kwargs))

        response_json = response.json()
        response_json.update({'course_id': self.id})

        return DiscussionTopic(self._requester, response_json)
Exemplo n.º 2
0
    def create_discussion_topic(self, **kwargs):
        """
        Creates a new discussion topic for the course or group.

        :calls: `POST /api/v1/groups/:group_id/discussion_topics \
        <https://canvas.instructure.com/doc/api/discussion_topics.html#method.discussion_topics.create>`_

        :rtype: :class:`canvasapi.discussion_topic.DiscussionTopic`
        """
        response = self._requester.request(
            "POST",
            "groups/{}/discussion_topics".format(self.id),
            _kwargs=combine_kwargs(**kwargs),
        )

        response_json = response.json()
        response_json.update({"group_id": self.id})

        return DiscussionTopic(self._requester, response_json)
Exemplo n.º 3
0
    def get_discussion_topic(self, topic_id):
        """
        Return data on an individual discussion topic.

        :calls: `GET /api/v1/courses/:course_id/discussion_topics/:topic_id \
        <https://canvas.instructure.com/doc/api/discussion_topics.html#method.discussion_topics_api.show>`_

        :param topic_id: The ID of the discussion topic.
        :type topic_id: int

        :rtype: :class:`canvasapi.discussion_topic.DiscussionTopic`
        """
        response = self._requester.request(
            'GET', 'courses/%s/discussion_topics/%s' % (self.id, topic_id))

        response_json = response.json()
        response_json.update({'course_id': self.id})

        return DiscussionTopic(self._requester, response_json)
Exemplo n.º 4
0
    def get_discussion_topic(self, topic):
        """
        Return data on an individual discussion topic.

        :calls: `GET /api/v1/groups/:group_id/discussion_topics/:topic_id \
        <https://canvas.instructure.com/doc/api/discussion_topics.html#method.discussion_topics_api.show>`_

        :param topic: The object or ID of the discussion topic.
        :type topic: :class:`canvasapi.discussion_topic.DiscussionTopic` or int

        :rtype: :class:`canvasapi.discussion_topic.DiscussionTopic`
        """
        topic_id = obj_or_id(topic, "topic", (DiscussionTopic, ))

        response = self._requester.request(
            'GET', 'groups/{}/discussion_topics/{}'.format(self.id, topic_id))

        response_json = response.json()
        response_json.update({'group_id': self.id})

        return DiscussionTopic(self._requester, response_json)
Exemplo n.º 5
0
    def get_full_discussion_topic(self, topic_id):
        """
        Return a cached structure of the discussion topic.

        :calls: `GET /api/v1/courses/:course_id/discussion_topics/:topic_id/view \
        <https://canvas.instructure.com/doc/api/discussion_topics.html#method.discussion_topics_api.view>`_

        :param topic_id: The ID of the discussion topic.
        :type topic_id: int

        :rtype: :class:`canvasapi.discussion_topic.DiscussionTopic`
        """
        response = self._requester.request(
            'GET',
            'groups/%s/discussion_topics/%s/view' % (self.id, topic_id),
        )

        response_json = response.json()
        response_json.update({'group_id': self.id})

        return DiscussionTopic(self._requester, response_json)
Exemplo n.º 6
0
 def test_parent_type_no_id(self, m):
     discussion = DiscussionTopic(self.canvas._Canvas__requester, {'id': 1})
     with self.assertRaises(ValueError):
         discussion._parent_type