diff options
author | adityacp | 2017-04-19 14:41:45 +0530 |
---|---|---|
committer | adityacp | 2017-04-19 14:41:45 +0530 |
commit | d2cbe09ff6d356e537ed1845b292b2138b6b8295 (patch) | |
tree | 5bee94e055851064e0f4105e7d7be7b1bfa77451 | |
parent | 9b8b99b69066f6a627a2a660d6ad2e63e31f446a (diff) | |
download | online_test-d2cbe09ff6d356e537ed1845b292b2138b6b8295.tar.gz online_test-d2cbe09ff6d356e537ed1845b292b2138b6b8295.tar.bz2 online_test-d2cbe09ff6d356e537ed1845b292b2138b6b8295.zip |
Change views to get distinct quizzes in dashboard
-rw-r--r-- | yaksh/views.py | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/yaksh/views.py b/yaksh/views.py index c5aeb1c..17274d8 100644 --- a/yaksh/views.py +++ b/yaksh/views.py @@ -288,7 +288,7 @@ def prof_manage(request, msg=None): Q(quiz__course__creator=user) | Q(quiz__course__teachers=user), quiz__is_trial=False - ) + ).distinct() trial_paper = AnswerPaper.objects.filter(user=user, question_paper__quiz__is_trial=True ) @@ -308,9 +308,9 @@ def prof_manage(request, msg=None): for paper in question_papers: answer_papers = AnswerPaper.objects.filter(question_paper=paper) users_passed = AnswerPaper.objects.filter(question_paper=paper, - passed=True).distinct().count() + passed=True).count() users_failed = AnswerPaper.objects.filter(question_paper=paper, - passed=False).distinct().count() + passed=False).count() temp = paper, answer_papers, users_passed, users_failed users_per_paper.append(temp) context = {'user': user, 'users_per_paper': users_per_paper, @@ -779,13 +779,13 @@ def monitor(request, quiz_id=None): context_instance=ci) # quiz_id is not None. try: + quiz = get_object_or_404(Quiz, id=quiz_id) + if not quiz.course.is_creator(user) and not quiz.course.is_teacher(user): + raise Http404('This course does not belong to you') q_paper = QuestionPaper.objects.filter(Q(quiz__course__creator=user) | Q(quiz__course__teachers=user), quiz__is_trial=False, quiz_id=quiz_id).distinct() - quiz = get_object_or_404(Quiz, id=quiz_id) - if not quiz.course.is_creator(user) and not quiz.course.is_teacher(user): - raise Http404('This course does not belong to you') except QuestionPaper.DoesNotExist: papers = [] q_paper = None |