def create_session(self, poll_session, **kwargs): """ Create a new poll session for this poll :calls: `POST /api/v1/polls/:poll_id/poll_sessions \ <https://canvas.instructure.com/doc/api/poll_sessions.html#method.polling/poll_sessions.create>`_ :param poll_session: List of arguments. course_id (required): id of the course for the session, course_section_id (optional): id of the course section for this session, has_public_results (optional): whether the results are viewable by students. :type poll_session: list :rtype: :class:`canvasapi.poll_session.PollSession` """ if (isinstance(poll_session, list) and isinstance(poll_session[0], dict) and "course_id" in poll_session[0]): kwargs["poll_session"] = poll_session else: raise RequiredFieldMissing( "Dictionary with key 'course_id' is required.") response = self._requester.request( "POST", "polls/{}/poll_sessions".format(self.id), _kwargs=combine_kwargs(**kwargs), ) return PollSession(self._requester, response.json()["poll_sessions"][0])
def get_session(self, poll_session, **kwargs): """ Returns the poll session with the given id. :calls: `GET /api/v1/polls/:poll_id/poll_sessions/:id \ <https://canvas.instructure.com/doc/api/poll_sessions.html#method.polling/poll_sessions.show>`_ :param poll_session: List of arguments. Takes a poll session id (int) or poll session \ object. :rtype: :class:`canvasapi.poll_session.PollSession` """ poll_session_id = obj_or_id(poll_session, "poll_session", (PollSession,)) response = self._requester.request( 'GET', 'polls/{}/poll_sessions/{}'.format(self.id, poll_session_id), _kwargs=combine_kwargs(**kwargs) ) return PollSession(self._requester, response.json()['poll_sessions'][0])