summaryrefslogtreecommitdiff
path: root/yaksh/models.py
diff options
context:
space:
mode:
Diffstat (limited to 'yaksh/models.py')
-rw-r--r--yaksh/models.py20
1 files changed, 9 insertions, 11 deletions
diff --git a/yaksh/models.py b/yaksh/models.py
index 6542daa..32632dd 100644
--- a/yaksh/models.py
+++ b/yaksh/models.py
@@ -1695,17 +1695,15 @@ class QuestionPaperManager(models.Manager):
def create_trial_paper_to_test_quiz(self, trial_quiz, original_quiz_id):
"""Creates a trial question paper to test quiz."""
- if self.filter(quiz=trial_quiz).exists():
- trial_questionpaper = self.get(quiz=trial_quiz)
- else:
- trial_questionpaper, trial_questions = \
- self._create_trial_from_questionpaper(original_quiz_id)
- trial_questionpaper.quiz = trial_quiz
- trial_questionpaper.fixed_questions\
- .add(*trial_questions["fixed_questions"])
- trial_questionpaper.random_questions\
- .add(*trial_questions["random_questions"])
- trial_questionpaper.save()
+ trial_quiz.questionpaper_set.all().delete()
+ trial_questionpaper, trial_questions = \
+ self._create_trial_from_questionpaper(original_quiz_id)
+ trial_questionpaper.quiz = trial_quiz
+ trial_questionpaper.fixed_questions\
+ .add(*trial_questions["fixed_questions"])
+ trial_questionpaper.random_questions\
+ .add(*trial_questions["random_questions"])
+ trial_questionpaper.save()
return trial_questionpaper