summaryrefslogtreecommitdiff
path: root/yaksh/views.py
diff options
context:
space:
mode:
authormaheshgudi2016-09-07 18:19:38 +0530
committermaheshgudi2016-09-07 18:19:38 +0530
commitccea043bde737883063adfaf28eb16c95218d58b (patch)
treed0e881fae8391740ab5c7480444eb36855bea1a4 /yaksh/views.py
parent7d243a58856c09d7d547c1a239ecb9af56f3d6df (diff)
downloadonline_test-ccea043bde737883063adfaf28eb16c95218d58b.tar.gz
online_test-ccea043bde737883063adfaf28eb16c95218d58b.tar.bz2
online_test-ccea043bde737883063adfaf28eb16c95218d58b.zip
only answerpapers are deleted and not the entire trial quiz
Diffstat (limited to 'yaksh/views.py')
-rw-r--r--yaksh/views.py14
1 files changed, 9 insertions, 5 deletions
diff --git a/yaksh/views.py b/yaksh/views.py
index f32b8f8..7c4e9af 100644
--- a/yaksh/views.py
+++ b/yaksh/views.py
@@ -318,12 +318,16 @@ rights/permissions and log in."""
)
if request.method == "POST":
delete_quiz = request.POST.getlist('delete_quiz')
- for quiz_id in delete_quiz:
- quiz = Quiz.objects.get(id=quiz_id)
- if quiz.course.is_trial == True:
- quiz.course.delete()
+ for answerpaper_id in delete_quiz:
+ answerpaper = AnswerPaper.objects.get(id=answerpaper_id)
+ if answerpaper.question_paper.quiz.course.is_trial == True:
+ answerpaper.question_paper.quiz.course.delete()
else:
- quiz.delete()
+ qpaper = answerpaper.question_paper
+ if qpaper.answerpaper_set.count() == 1:
+ answerpaper.question_paper.quiz.delete()
+ else:
+ answerpaper.delete()
users_per_paper = []
for paper in question_papers:
answer_papers = AnswerPaper.objects.filter(question_paper=paper)