diff options
Diffstat (limited to 'yaksh')
-rw-r--r-- | yaksh/templates/manage.html | 2 | ||||
-rw-r--r-- | yaksh/views.py | 14 |
2 files changed, 10 insertions, 6 deletions
diff --git a/yaksh/templates/manage.html b/yaksh/templates/manage.html index 2baf492..9934f41 100644 --- a/yaksh/templates/manage.html +++ b/yaksh/templates/manage.html @@ -85,7 +85,7 @@ {% csrf_token %} {% for paper in trial_paper %} <tr> - <td> <input type = "checkbox" name="delete_quiz" value = {{paper.question_paper.quiz.id}}></input></td> + <td> <input type = "checkbox" name="delete_quiz" value = {{paper.id}}></input></td> <td> <a href="{{URL_ROOT}}/exam/manage/gradeuser/{{paper.question_paper.quiz.id}}">{{paper.question_paper.quiz.description}}</td> </tr> {% endfor %} 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) |