summaryrefslogtreecommitdiff
path: root/yaksh
diff options
context:
space:
mode:
authormaheshgudi2016-07-05 17:50:31 +0530
committermaheshgudi2016-07-05 17:50:31 +0530
commit9c61c84194e6b52913dfc284765a7b7bd77201ad (patch)
tree384f452958efad8cbc1cdc1a518f6fc2c09087e9 /yaksh
parent1276c2840c3c7f7521c98574dea302160611f79d (diff)
downloadonline_test-9c61c84194e6b52913dfc284765a7b7bd77201ad.tar.gz
online_test-9c61c84194e6b52913dfc284765a7b7bd77201ad.tar.bz2
online_test-9c61c84194e6b52913dfc284765a7b7bd77201ad.zip
will not create trial paper object if the quiz has expired or is inactive
Diffstat (limited to 'yaksh')
-rw-r--r--yaksh/models.py8
-rw-r--r--yaksh/tests.py6
-rw-r--r--yaksh/views.py4
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))