diff options
author | Prabhu Ramachandran | 2016-09-08 16:23:29 +0530 |
---|---|---|
committer | GitHub | 2016-09-08 16:23:29 +0530 |
commit | dc4437c52ee1266af9a69d091952d9f6b19ca584 (patch) | |
tree | 579ff6bd295a31af114c6761ed4f6691d298a2b3 /yaksh | |
parent | dd7d6933d4312276aec47d401678f853961b5427 (diff) | |
parent | bc8095aaa0fe19da925e244967eb9ae77cf0f970 (diff) | |
download | online_test-dc4437c52ee1266af9a69d091952d9f6b19ca584.tar.gz online_test-dc4437c52ee1266af9a69d091952d9f6b19ca584.tar.bz2 online_test-dc4437c52ee1266af9a69d091952d9f6b19ca584.zip |
Merge pull request #133 from maheshgudi/test_modes
Test modes bug fixes
Diffstat (limited to 'yaksh')
-rw-r--r-- | yaksh/templates/manage.html | 8 | ||||
-rw-r--r-- | yaksh/views.py | 26 |
2 files changed, 20 insertions, 14 deletions
diff --git a/yaksh/templates/manage.html b/yaksh/templates/manage.html index 2fd0f7a..b628a44 100644 --- a/yaksh/templates/manage.html +++ b/yaksh/templates/manage.html @@ -78,15 +78,15 @@ <h5>Click on the button given below to add a new course.</h5> <button class="btn" type="button" onClick='location.replace("{{URL_ROOT}}/exam/manage/add_course");'>Add New Course</button> </center> - {% if trial_quiz %} + {% if trial_paper %} <h5/> You have trial papers. <table class="bordered-table zebra-striped"> <form action="" method="post"> {% csrf_token %} - {% for quiz in trial_quiz %} + {% for paper in trial_paper %} <tr> - <td> <input type = "checkbox" name="delete_quiz" value = {{quiz.id}}></input></td> - <td> <a href="{{URL_ROOT}}/exam/manage/gradeuser/{{quiz.id}}">{{quiz.description}}</td> + <td> <input type = "checkbox" name="delete_paper" 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 %} </table> diff --git a/yaksh/views.py b/yaksh/views.py index fa4dac6..9f7c7a9 100644 --- a/yaksh/views.py +++ b/yaksh/views.py @@ -320,15 +320,21 @@ rights/permissions and log in.""" question_papers = QuestionPaper.objects.filter(quiz__course__creator=user, quiz__is_trial=False ) - trial_quiz = Quiz.objects.filter(course__creator=user, is_trial=True) + trial_paper = AnswerPaper.objects.filter(user=user, + question_paper__quiz__is_trial=True + ) 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() + delete_paper = request.POST.getlist('delete_paper') + for answerpaper_id in delete_paper: + answerpaper = AnswerPaper.objects.get(id=answerpaper_id) + qpaper = answerpaper.question_paper + if qpaper.quiz.course.is_trial == True: + qpaper.quiz.course.delete() else: - quiz.delete() + if qpaper.answerpaper_set.count() == 1: + qpaper.quiz.delete() + else: + answerpaper.delete() users_per_paper = [] for paper in question_papers: answer_papers = AnswerPaper.objects.filter(question_paper=paper) @@ -339,7 +345,7 @@ rights/permissions and log in.""" temp = paper, answer_papers, users_passed, users_failed users_per_paper.append(temp) context = {'user': user, 'users_per_paper': users_per_paper, - 'trial_quiz': trial_quiz + 'trial_paper': trial_paper } return my_render_to_response('manage.html', context, context_instance=ci) return my_redirect('/exam/login/') @@ -796,7 +802,7 @@ def monitor(request, questionpaper_id=None): if questionpaper_id is None: q_paper = QuestionPaper.objects.filter(Q(quiz__course__creator=user) | Q(quiz__course__teachers=user), - quiz__course__is_trial=False + quiz__is_trial=False ).distinct() context = {'papers': [], 'quiz': None, @@ -807,7 +813,7 @@ def monitor(request, questionpaper_id=None): try: q_paper = QuestionPaper.objects.filter(Q(quiz__course__creator=user) | Q(quiz__course__teachers=user), - quiz__course__is_trial=False, + quiz__is_trial=False, id=questionpaper_id).distinct() except QuestionPaper.DoesNotExist: papers = [] |