diff options
Diffstat (limited to 'yaksh')
-rw-r--r-- | yaksh/models.py | 8 | ||||
-rw-r--r-- | yaksh/tests.py | 6 | ||||
-rw-r--r-- | yaksh/views.py | 4 |
3 files changed, 12 insertions, 6 deletions
diff --git a/yaksh/models.py b/yaksh/models.py index f1b0d33..bfe204c 100644 --- a/yaksh/models.py +++ b/yaksh/models.py @@ -303,7 +303,7 @@ class QuizManager(models.Manager): """Creates a trial quiz for testing questions""" trial_quiz = self.create(course=trial_course, duration=1000, - description="trial_quiz", + description="trial_questions", is_trial=True, time_between_attempts=0 ) @@ -311,9 +311,11 @@ class QuizManager(models.Manager): def create_trial_from_quiz(self, original_quiz_id, user, godmode): """Creates a trial quiz from existing quiz""" - trial_quiz_name = "trial_orig_id_{0}".format(original_quiz_id) + trial_quiz_name = "Trial_orig_id_{0}_{1}".format(original_quiz_id, + "godmode" if godmode else "usermode" + ) - if self.filter(description=trial_quiz_name).exists() and not godmode: + if self.filter(description=trial_quiz_name).exists(): trial_quiz = self.get(description=trial_quiz_name) else: diff --git a/yaksh/tests.py b/yaksh/tests.py index bf3be04..d5dfb89 100644 --- a/yaksh/tests.py +++ b/yaksh/tests.py @@ -194,7 +194,7 @@ class QuizTestCases(unittest.TestCase): ) self.assertEqual(trial_quiz.course, self.trial_course) self.assertEqual(trial_quiz.duration, 1000) - self.assertEqual(trial_quiz.description, "trial_quiz") + self.assertEqual(trial_quiz.description, "trial_questions") self.assertTrue(trial_quiz.is_trial) self.assertEqual(trial_quiz.time_between_attempts, 0) @@ -204,7 +204,7 @@ class QuizTestCases(unittest.TestCase): self.creator, True ) - self.assertEqual(trial_quiz.description, "trial_orig_id_1") + self.assertEqual(trial_quiz.description, "Trial_orig_id_1_godmode") self.assertTrue(trial_quiz.is_trial) self.assertEqual(trial_quiz.duration, 1000) self.assertTrue(trial_quiz.active) @@ -219,7 +219,7 @@ class QuizTestCases(unittest.TestCase): self.creator, False ) - self.assertEqual(trial_quiz.description, "trial_orig_id_2") + self.assertEqual(trial_quiz.description, "Trial_orig_id_2_usermode") self.assertTrue(trial_quiz.is_trial) self.assertEqual(trial_quiz.duration, self.quiz2.duration) self.assertEqual(trial_quiz.active, self.quiz2.active) diff --git a/yaksh/views.py b/yaksh/views.py index 3db51a9..ae32bbf 100644 --- a/yaksh/views.py +++ b/yaksh/views.py @@ -1240,5 +1240,9 @@ def test_quiz(request, mode, quiz_id): """creates a trial quiz for the moderators""" godmode = True if mode == "godmode" else False current_user = request.user + quiz = Quiz.objects.get(id=quiz_id) + if (quiz.is_expired() or not quiz.active) and not godmode: + return my_redirect('/exam/manage') + trial_questionpaper = test_mode(current_user, godmode, None, quiz_id) return my_redirect("/exam/start/{0}".format(trial_questionpaper.id)) |