diff options
Diffstat (limited to 'yaksh')
-rw-r--r-- | yaksh/models.py | 8 | ||||
-rw-r--r-- | yaksh/test_models.py | 20 |
2 files changed, 12 insertions, 16 deletions
diff --git a/yaksh/models.py b/yaksh/models.py index 1cc0634..78669e7 100644 --- a/yaksh/models.py +++ b/yaksh/models.py @@ -853,8 +853,11 @@ class QuestionPaper(models.Model): for question_set in self.random_questions.all(): questions += question_set.get_random_questions() if self.shuffle_questions: - return self.get_shuffled_questions(questions) - return questions + all_questions = self.get_shuffled_questions(questions) + print("in _get_questions_for_answerpaper", all_questions, "\n") + else: + all_questions = questions + return all_questions def make_answerpaper(self, user, ip, attempt_num): """Creates an answer paper for the user to attempt the quiz""" @@ -950,6 +953,7 @@ class QuestionPaper(models.Model): def get_shuffled_questions(self, questions): """Get shuffled questions if auto suffle is enabled""" random.shuffle(questions) + print("in get_shuffled_questions", questions, "\n") return questions def __str__(self): diff --git a/yaksh/test_models.py b/yaksh/test_models.py index 6828b89..e3ef86e 100644 --- a/yaksh/test_models.py +++ b/yaksh/test_models.py @@ -597,7 +597,8 @@ class AnswerPaperTestCases(unittest.TestCase): 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] + + que_list = Question.objects.filter(id__in=range(1, 21)) self.question_paper2.fixed_questions.add(*que_list) # Create AnswerPaper for user1 and user2 @@ -876,19 +877,10 @@ class AnswerPaperTestCases(unittest.TestCase): 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) + ques_set_1 = list(self.user1_answerpaper.questions.all()) + ques_set_2 = list(self.user2_answerpaper.questions.all()) + print("set1:-", ques_set_1, "\n", "set2:-", ques_set_2) + self.assertFalse(ques_set_1 == ques_set_2) ############################################################################### |