diff options
author | Prabhu Ramachandran | 2017-10-07 10:54:39 +0530 |
---|---|---|
committer | GitHub | 2017-10-07 10:54:39 +0530 |
commit | 39ec0271244826b2693f01f6daaa99525404e15a (patch) | |
tree | 04cf534ac2cdc90f386e051588bf443fc61219ff /yaksh/test_models.py | |
parent | a626f3792d03ccd96a1c49c7096076950d020c5a (diff) | |
parent | 2eb511847777e4e941ed5fc40783086d5e0bdfcc (diff) | |
download | online_test-39ec0271244826b2693f01f6daaa99525404e15a.tar.gz online_test-39ec0271244826b2693f01f6daaa99525404e15a.tar.bz2 online_test-39ec0271244826b2693f01f6daaa99525404e15a.zip |
Merge pull request #343 from adityacp/fix_shuffle_questions
Fix shuffle questions
Diffstat (limited to 'yaksh/test_models.py')
-rw-r--r-- | yaksh/test_models.py | 25 |
1 files changed, 24 insertions, 1 deletions
diff --git a/yaksh/test_models.py b/yaksh/test_models.py index 2c83024..03af521 100644 --- a/yaksh/test_models.py +++ b/yaksh/test_models.py @@ -502,6 +502,7 @@ class AnswerPaperTestCases(unittest.TestCase): def setUpClass(self): self.ip = '101.0.0.1' self.user = User.objects.get(username='demo_user') + self.user2 = User.objects.get(username='demo_user2') self.profile = self.user.profile self.quiz = Quiz.objects.get(description='demo quiz 1') self.question_paper = QuestionPaper(quiz=self.quiz, total_marks=3) @@ -590,6 +591,24 @@ class AnswerPaperTestCases(unittest.TestCase): ) self.mcc_based_testcase.save() + # Setup quiz where questions are shuffled + # Create Quiz and Question Paper + self.quiz2 = Quiz.objects.get(description="demo quiz 2") + self.question_paper2 = QuestionPaper( + quiz=self.quiz2, total_marks=3, shuffle_questions=True) + self.question_paper2.save() + summary_list = ['Q%d' % (i) for i in range(1, 21)] + que_list = Question.objects.filter(summary__in=summary_list) + self.question_paper2.fixed_questions.add(*que_list) + + # Create AnswerPaper for user1 and user2 + self.user1_answerpaper = self.question_paper2.make_answerpaper( + self.user, self.ip, 1 + ) + self.user2_answerpaper = self.question_paper2.make_answerpaper( + self.user2, self.ip, 1 + ) + def test_validate_and_regrade_mcc_correct_answer(self): # Given mcc_answer = [str(self.mcc_based_testcase.id)] @@ -663,7 +682,6 @@ class AnswerPaperTestCases(unittest.TestCase): self.assertEqual(self.answer.marks, 0) self.assertFalse(self.answer.correct) - def test_mcq_incorrect_answer(self): # Given mcq_answer = 'b' @@ -858,6 +876,11 @@ class AnswerPaperTestCases(unittest.TestCase): self.assertEqual(latest_answer.id, self.answer1.id) self.assertEqual(latest_answer.answer, "answer1") + def test_shuffle_questions(self): + ques_set_1 = self.user1_answerpaper.get_all_ordered_questions() + ques_set_2 = self.user2_answerpaper.get_all_ordered_questions() + self.assertFalse(ques_set_1 == ques_set_2) + ############################################################################### class CourseTestCases(unittest.TestCase): |