class UpdateQuestionTest(CourseTestMixin, TestCase): def setUp(self): self.setup_course() self.quiz = QuizFactory(course=self.course) self.question = QuestionFactory(quiz=self.quiz) def test_update_question(self): url = reverse('update-question', kwargs={'pk': self.question.pk}) self.client.login(username=self.faculty.username, password='******') response = self.client.get(url) self.assertEqual(response.status_code, 200) self.assertEqual(response.status_code, 200) response = self.client.post( url, { 'text': 'Alpha', 'explanation': 'Ch-ch-changes', 'quiz': self.quiz.pk, 'answer_label_1': 'Thor', 'answer_label_2': 'Loki', 'answer_label_3': 'Odin', 'correct': 2 }) self.question.refresh_from_db() self.assertEqual(self.question.text, 'Alpha') self.assertEqual(self.question.explanation, 'Ch-ch-changes') self.assertEqual(self.question.marker_set.count(), 3) self.assertEqual(self.question.marker_set.all()[0].label, 'Thor') self.assertEqual(self.question.marker_set.all()[1].label, 'Loki') self.assertEqual(self.question.marker_set.all()[2].label, 'Odin') self.assertFalse(self.question.marker_set.all()[0].correct) self.assertTrue(self.question.marker_set.all()[1].correct) self.assertFalse(self.question.marker_set.all()[2].correct)
def setUp(self): self.setup_course() self.quiz = QuizFactory(course=self.course) self.question1 = QuestionFactory(quiz=self.quiz) self.question2 = QuestionFactory(quiz=self.quiz) self.view = LTIAssignmentView() self.view.request = RequestFactory().get('/', {}) self.view.request.user = self.student self.view.kwargs = {}
def setUp(self): self.setup_course() self.quiz = QuizFactory(course=self.course) self.question1 = QuestionFactory(quiz=self.quiz) self.question2 = QuestionFactory(quiz=self.quiz) self.submission = QuizSubmissionFactory(quiz=self.quiz, user=self.student) self.view = LTISpeedGraderView() self.view.request = RequestFactory().get('/', {}) self.view.request.user = self.student self.view.kwargs = {}
def test_ordered_questions(self): quiz = QuizFactory(course=self.course, scoring_scheme=0) QuestionFactory(quiz=quiz) QuestionFactory(quiz=quiz) q1 = quiz.question_set.first() # ordinality of q2 is -1 q2 = quiz.question_set.last() q1.ordinality = 1 q1.save() first = quiz.ordered_questions().first() self.assertEqual(quiz.question_set.first().ordinality, 1) self.assertEqual(first, q2)
def test_total_points(self): quiz = QuizFactory(course=self.course, scoring_scheme=0) QuestionFactory(quiz=quiz) QuestionFactory(quiz=quiz) self.assertEqual(quiz.total_points(), 10) quiz.scoring_scheme = 1 quiz.save() self.assertEqual(quiz.total_points(), 6) quiz.scoring_scheme = 2 quiz.save() self.assertEqual(quiz.total_points(), 6)
def test_get_data_submitted_twice(self): self.view.kwargs['pk'] = self.quiz.id self.quiz2 = QuizFactory(course=self.course) self.question1 = QuestionFactory(quiz=self.quiz2) self.question2 = QuestionFactory(quiz=self.quiz2) submission = QuizSubmissionFactory(quiz=self.quiz, user=self.student) QuizSubmissionFactory(quiz=self.quiz2, user=self.student) self.view.kwargs['submission_id'] = submission.id response = self.view.get(self.view.request) self.assertFalse(response.context_data['is_faculty']) self.assertEqual(response.context_data['quiz'], self.quiz) self.assertEqual(response.context_data['submission'], submission)
def test_init(self): form = QuestionForm([], {}) self.assertEqual(form.initial, {}) question = QuestionFactory() form = QuestionForm([], {'instance': question}) self.assertEqual(form.initial, {})
def test_clone(self): q = QuizFactory(course=self.course, title='cloned quiz') q.question = QuestionFactory(quiz=q) c = q.clone() self.assertNotEqual(q.pk, c.pk) self.assertEqual(q.title, 'cloned quiz') self.assertEqual(c.title, 'cloned quiz (clone)') self.assertEqual(q.scoring_scheme, c.scoring_scheme) self.assertEqual(q.question_set.count(), c.question_set.count()) self.assertNotEqual(q.question_set.first().pk, c.question_set.first().pk) quiz_q = q.question_set.first() clone_q = c.question_set.first() self.assertEqual(quiz_q.marker_set.count(), clone_q.marker_set.count()) self.assertNotEqual(quiz_q.marker_set.first().pk, clone_q.marker_set.first().pk)
def setUp(self): self.setup_course() self.quiz = QuizFactory(course=self.course) self.question1 = QuestionFactory(quiz=self.quiz) self.submission = QuizSubmissionFactory(quiz=self.quiz, user=self.student)
def setUp(self): self.setup_course() self.quiz = QuizFactory(course=self.course) self.question1 = QuestionFactory(quiz=self.quiz) self.submissions = []
def setUp(self): self.setup_course() self.quiz = QuizFactory(course=self.course) self.question = QuestionFactory(quiz=self.quiz)
def test_lowest_question_points(self): quiz = QuizFactory(course=self.course, scoring_scheme=0) QuestionFactory(quiz=quiz) q1 = quiz.question_set.first() self.assertEqual(q1.lowest_question_points(), 0)