summaryrefslogtreecommitdiff
path: root/yaksh
diff options
context:
space:
mode:
authoradityacp2017-10-05 16:25:15 +0530
committeradityacp2017-10-06 12:44:34 +0530
commit3038ab21bc93b3dfebda82a10fc179dadb488bf3 (patch)
tree4e439d6725108ab7ffab1b9ef4284b1e41171eaa /yaksh
parentf30b65e85cba5d3f25b11787530afbee957ce599 (diff)
downloadonline_test-3038ab21bc93b3dfebda82a10fc179dadb488bf3.tar.gz
online_test-3038ab21bc93b3dfebda82a10fc179dadb488bf3.tar.bz2
online_test-3038ab21bc93b3dfebda82a10fc179dadb488bf3.zip
Add test to check shuffle questions
Diffstat (limited to 'yaksh')
-rw-r--r--yaksh/test_models.py34
1 files changed, 33 insertions, 1 deletions
diff --git a/yaksh/test_models.py b/yaksh/test_models.py
index 2c83024..6828b89 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,23 @@ 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()
+ que_list = [self.question1, self.question2, self.question3]
+ 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 +681,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 +875,21 @@ class AnswerPaperTestCases(unittest.TestCase):
self.assertEqual(latest_answer.id, self.answer1.id)
self.assertEqual(latest_answer.answer, "answer1")
+ def test_shuffle_questions(self):
+ success = False
+ user1_question_set = []
+ user2_question_set = []
+ while not success:
+ ques_set_1 = list(self.user1_answerpaper.questions.all())
+ ques_set_2 = list(self.user2_answerpaper.questions.all())
+ if ques_set_1 == ques_set_2:
+ continue
+ else:
+ user1_question_set = ques_set_1
+ user2_question_set = ques_set_2
+ success = True
+ self.assertFalse(user1_question_set == user2_question_set)
+
###############################################################################
class CourseTestCases(unittest.TestCase):