Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions canvasapi/quiz.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@ def create_question(self, **kwargs):
response_json = response.json()
response_json.update({"course_id": self.course_id})

self.edit(quiz={"published": getattr(self, "published", False)})

return QuizQuestion(self._requester, response_json)

def create_question_group(self, quiz_groups, **kwargs):
Expand Down
21 changes: 20 additions & 1 deletion tests/test_quiz.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ def test_create_question_group_incorrect_dict(self, m):

# create_question()
def test_create_question(self, m):
register_uris({"quiz": ["create_question"]}, m)
register_uris({"quiz": ["create_question", "edit"]}, m)

question_dict = {
"question_name": "Pick Correct Answer",
Expand All @@ -165,6 +165,25 @@ def test_create_question(self, m):
self.assertTrue(hasattr(question, "question_name"))
self.assertEqual(question.question_name, question_dict["question_name"])


def test_create_question_autosaves(self, m):
register_uris({"quiz": ["create_question", "edit"]}, m)

question_dict = {
"question_name": "Pick Correct Answer",
"question_type": "multiple_choice_question",
"question_text": "What is the right answer?",
"points_possible": 10,
"correct_comments": "That's correct!",
"incorrect_comments": "That's wrong!",
}

question = self.quiz.create_question(question=question_dict)

self.assertIsInstance(question, QuizQuestion)
self.assertEqual(question.question_name, question_dict["question_name"])


# get_question()
def test_get_question(self, m):
register_uris({"quiz": ["get_question"]}, m)
Expand Down