summaryrefslogtreecommitdiff
path: root/yaksh/test_models.py
diff options
context:
space:
mode:
Diffstat (limited to 'yaksh/test_models.py')
-rw-r--r--yaksh/test_models.py25
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):