From add9e3f36254f578364c99d66c2eb9364e5aa3a5 Mon Sep 17 00:00:00 2001 From: FOSSEE Project Date: Sun, 29 Jun 2014 16:20:36 +0530 Subject: changing moderator's landing page to show list of all quizzes --- testapp/exam/views.py | 16 +++++++---- testapp/templates/manage.html | 63 ++++++++++++++++++++++++++++++------------- 2 files changed, 56 insertions(+), 23 deletions(-) (limited to 'testapp') diff --git a/testapp/exam/views.py b/testapp/exam/views.py index c4c03df..c58ce89 100644 --- a/testapp/exam/views.py +++ b/testapp/exam/views.py @@ -569,15 +569,21 @@ def manual_questionpaper(request, questionpaper_id=None): def prof_manage(request): """Take credentials of the user with professor/moderator - rights/permissions and log in.""" +rights/permissions and log in.""" user = request.user - if user.is_authenticated()\ - and user.groups.filter(name='moderator').count() > 0: - context = {'user': user} + if user.is_authenticated() and is_moderator(user): + question_papers = QuestionPaper.objects.all() + users_per_paper = [] + for paper in question_papers: + answer_papers = AnswerPaper.objects.filter(question_paper=paper) + users_passed = AnswerPaper.objects.filter(question_paper=paper, passed=True).count() + users_failed = AnswerPaper.objects.filter(question_paper=paper, 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} return my_render_to_response('manage.html', context) return my_redirect('/exam/login/') - def user_login(request): """Take the credentials of the user and log the user in.""" diff --git a/testapp/templates/manage.html b/testapp/templates/manage.html index 0f122b0..1db8a78 100644 --- a/testapp/templates/manage.html +++ b/testapp/templates/manage.html @@ -1,6 +1,3 @@ - - @@ -9,12 +6,13 @@ {% block meta %} - - - + + + {% endblock %} - + + {% block css %} {% endblock %} @@ -26,16 +24,15 @@
@@ -43,12 +40,42 @@
- {% block manage %} - {% endblock %} + {% block manage %} +

List of quizzes! Click on the given links to have a look at answer papers for a quiz.

+
+ + + + + + {% for paper, answer_papers, users_passed, users_failed in users_per_paper %} + + + + + + + {% endfor %} +
QuizTaken ByNo. of users PassedNo. of users Failed
+ {{ paper.quiz.description }} + + {{ answer_papers|length }} user(s) + + {{ users_passed }} + + {{ users_failed }} +
+
+
+

Moderator's Dashboard!

+
Click on the button given below to add a new quiz.
+ +
+{% endblock %}
-- cgit