From b9afb77607c9b05171a8d1abfd3c39201974f141 Mon Sep 17 00:00:00 2001 From: hardythe1 Date: Mon, 30 Jun 2014 14:52:37 +0530 Subject: changes for user dashboard --- testapp/exam/views.py | 64 +++++++++++++++++++++++--------- testapp/templates/exam/quizzes_user.html | 57 ++++++++++++++++++++++++++-- 2 files changed, 100 insertions(+), 21 deletions(-) diff --git a/testapp/exam/views.py b/testapp/exam/views.py index c4c03df..44831b3 100644 --- a/testapp/exam/views.py +++ b/testapp/exam/views.py @@ -131,30 +131,58 @@ def user_register(request): context_instance=ci) -def quizlist_user(request): - """Show All Quizzes that is available to logged-in user.""" - user = request.user - avail_quiz = list(QuestionPaper.objects.filter(quiz__active=True)) - user_answerpapers = AnswerPaper.objects.filter(user=user) - user_quiz = [] - - if user_answerpapers.count() == 0: - context = {'quizzes': avail_quiz} - return my_render_to_response("exam/quizzes_user.html", context) - - for paper in user_answerpapers: - for quiz in avail_quiz: - if paper.question_paper.id == quiz.id and \ - paper.end_time != paper.start_time: - avail_quiz.remove(quiz) - - context = {'quizzes': avail_quiz, 'user': user} +def quizlist_user(request): + """Show All Quizzes that is available to logged-in user.""" + user = request.user + avail_quizzes = list(QuestionPaper.objects.filter(quiz__active=True)) + user_answerpapers = AnswerPaper.objects.filter(user=user) + quizzes_taken = [] + pre_requisites = [] + context = {} + + + if 'cannot_attempt' in request.GET: + context['cannot_attempt'] = True + + if user_answerpapers.count() == 0: + context['quizzes'] = avail_quizzes + context['user'] = user + context['quizzes_taken'] = None + return my_render_to_response("exam/quizzes_user.html", context) + + for answer_paper in user_answerpapers: + for quiz in avail_quizzes: + if answer_paper.question_paper.id == quiz.id and \ + answer_paper.end_time != answer_paper.start_time: + avail_quizzes.remove(quiz) + quizzes_taken.append(answer_paper) + + context['quizzes'] = avail_quizzes + context['user'] = user + context['quizzes_taken'] = quizzes_taken return my_render_to_response("exam/quizzes_user.html", context) def intro(request, questionpaper_id): """Show introduction page before quiz starts""" user = request.user + ci = RequestContext(request) + quest_paper = QuestionPaper.objects.get(id=questionpaper_id) + if quest_paper.quiz.prerequisite: + try: + answer_paper = AnswerPaper.objects.get( + id=quest_paper.quiz.prerequisite.id) + if answer_paper.passed: + context = {'user': user, 'paper_id': questionpaper_id} + return my_render_to_response('exam/intro.html', context, + context_instance=ci) + else: + context = {'user': user, 'cannot_attempt':True} + return my_redirect("/exam/quizzes/?cannot_attempt=True") + + except: + context = {'user': user, 'cannot_attempt':True} + return my_redirect("/exam/quizzes/?cannot_attempt=True") context = {'user': user, 'paper_id': questionpaper_id} ci = RequestContext(request) return my_render_to_response('exam/intro.html', context, diff --git a/testapp/templates/exam/quizzes_user.html b/testapp/templates/exam/quizzes_user.html index b55d3e5..a1204bd 100644 --- a/testapp/templates/exam/quizzes_user.html +++ b/testapp/templates/exam/quizzes_user.html @@ -1,18 +1,69 @@ {% extends "user.html" %} -{% block subtitle %}Available Quizzes{% endblock %} +{% block subtitle %}Hello {{ user.first_name }}, welcome to your dashboard !{% endblock %} {% block css %} {% endblock %} +{% block script %} + + +{% endblock %} + + {% block manage %} + {% if cannot_attempt %} +

You have not passed the prerequisite & hence you cannot take the quiz.

+ {% endif %} +

List of quizzes availbale for you

{% if not quizzes %} -

No active quizzes for you

+
No active quizzes for you
{% endif %} + + + {% for paper in quizzes %} - {{ paper.quiz.description }}
+ + + + {% endfor %} +
QuizPre requisite quiz
+ {{ paper.quiz.description }}
+
+ {% if paper.quiz.prerequisite %} + You have to pass {{ paper.quiz.prerequisite.description }} for taking {{ paper.quiz.description }} + {% else %} + No pre requisites for {{ paper.quiz.description }} + {% endif %} +
+
+

List of quizzes taken by you so far

+ {% if quizzes_taken %} + + + + {% for paper in quizzes_taken %} + + + + + {% endfor %} +
QuizResult
+ {{ paper.question_paper.quiz.description }} + + {% if paper.passed %} +

Pass

+ {% else %} +

Fail

+ {% endif %} +
+ {% else %} +

You have not taken any quiz yet !!

+ {% endif %} + + {% endblock %} -- cgit From 87c791a8600033e197d53346a8e2be873bfaa884 Mon Sep 17 00:00:00 2001 From: hardythe1 Date: Mon, 30 Jun 2014 15:06:56 +0530 Subject: adding marks obtained & percentage --- testapp/templates/exam/quizzes_user.html | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/testapp/templates/exam/quizzes_user.html b/testapp/templates/exam/quizzes_user.html index a1204bd..c284b87 100644 --- a/testapp/templates/exam/quizzes_user.html +++ b/testapp/templates/exam/quizzes_user.html @@ -45,6 +45,9 @@ + + + {% for paper in quizzes_taken %} + + + {% endfor %}
Quiz ResultMraks ObtainedTotal MarksPercentage
@@ -57,6 +60,15 @@

Fail

{% endif %}
+ {{ paper.marks_obtained }} + + {{ paper.question_paper.total_marks }} + + {{ paper.percent }} +
-- cgit From ad4a695e16dc5de2bba4851bbc3329bcdaab76cf Mon Sep 17 00:00:00 2001 From: hardythe1 Date: Mon, 30 Jun 2014 15:09:45 +0530 Subject: adding table designing --- testapp/templates/exam/quizzes_user.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/testapp/templates/exam/quizzes_user.html b/testapp/templates/exam/quizzes_user.html index c284b87..9a49df7 100644 --- a/testapp/templates/exam/quizzes_user.html +++ b/testapp/templates/exam/quizzes_user.html @@ -42,7 +42,7 @@

List of quizzes taken by you so far

{% if quizzes_taken %} - +
-- cgit From 7a6fc986fbc4a857b619764defeda377dd9d3a68 Mon Sep 17 00:00:00 2001 From: hardythe1 Date: Wed, 2 Jul 2014 12:15:19 +0530 Subject: changes to start the quiz if prerequisite is passed --- testapp/exam/views.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/testapp/exam/views.py b/testapp/exam/views.py index 44831b3..8b251a0 100644 --- a/testapp/exam/views.py +++ b/testapp/exam/views.py @@ -171,7 +171,8 @@ def intro(request, questionpaper_id): if quest_paper.quiz.prerequisite: try: answer_paper = AnswerPaper.objects.get( - id=quest_paper.quiz.prerequisite.id) + quest_paper.quiz.id=quest_paper.quiz.prerequisite.id, + user=user) if answer_paper.passed: context = {'user': user, 'paper_id': questionpaper_id} return my_render_to_response('exam/intro.html', context, -- cgit From c8af24bf0adf393fb2e61bff06b54d00633e16d1 Mon Sep 17 00:00:00 2001 From: hardythe1 Date: Wed, 2 Jul 2014 12:26:00 +0530 Subject: changes to start the quiz if prerequisite is passed --- testapp/exam/views.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/testapp/exam/views.py b/testapp/exam/views.py index 8b251a0..3e11ed5 100644 --- a/testapp/exam/views.py +++ b/testapp/exam/views.py @@ -171,7 +171,7 @@ def intro(request, questionpaper_id): if quest_paper.quiz.prerequisite: try: answer_paper = AnswerPaper.objects.get( - quest_paper.quiz.id=quest_paper.quiz.prerequisite.id, + quest_paper.quiz=quest_paper.quiz.prerequisite, user=user) if answer_paper.passed: context = {'user': user, 'paper_id': questionpaper_id} -- cgit From 6e0a770f36a88c82f948628255d9dd8a8ead8580 Mon Sep 17 00:00:00 2001 From: hardythe1 Date: Wed, 2 Jul 2014 13:04:00 +0530 Subject: changes to start the quiz if prerequisite is passed --- testapp/exam/views.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/testapp/exam/views.py b/testapp/exam/views.py index 3e11ed5..8b84920 100644 --- a/testapp/exam/views.py +++ b/testapp/exam/views.py @@ -168,16 +168,18 @@ def intro(request, questionpaper_id): user = request.user ci = RequestContext(request) quest_paper = QuestionPaper.objects.get(id=questionpaper_id) + print quest_paper.quiz.prerequisite if quest_paper.quiz.prerequisite: try: + pre_quest = QuestionPaper.objects.get(quiz=quest_paper.quiz.prerequisite) answer_paper = AnswerPaper.objects.get( - quest_paper.quiz=quest_paper.quiz.prerequisite, + question_paper=pre_quest, user=user) if answer_paper.passed: context = {'user': user, 'paper_id': questionpaper_id} return my_render_to_response('exam/intro.html', context, context_instance=ci) - else: + else: else: context = {'user': user, 'cannot_attempt':True} return my_redirect("/exam/quizzes/?cannot_attempt=True") -- cgit From d56eaad3340a7580276b0e4644b48f224cb695c8 Mon Sep 17 00:00:00 2001 From: hardythe1 Date: Wed, 2 Jul 2014 13:06:21 +0530 Subject: correcting a small syntax error' --- testapp/exam/views.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/testapp/exam/views.py b/testapp/exam/views.py index 8b84920..ad5c263 100644 --- a/testapp/exam/views.py +++ b/testapp/exam/views.py @@ -179,7 +179,7 @@ def intro(request, questionpaper_id): context = {'user': user, 'paper_id': questionpaper_id} return my_render_to_response('exam/intro.html', context, context_instance=ci) - else: else: + else: context = {'user': user, 'cannot_attempt':True} return my_redirect("/exam/quizzes/?cannot_attempt=True") -- cgit From 3e9626308098bf412ca4f228f7667526ad52bbdd Mon Sep 17 00:00:00 2001 From: hardythe1 Date: Wed, 2 Jul 2014 13:12:19 +0530 Subject: removing links --- testapp/templates/exam/quizzes_user.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/testapp/templates/exam/quizzes_user.html b/testapp/templates/exam/quizzes_user.html index 9a49df7..914b6b4 100644 --- a/testapp/templates/exam/quizzes_user.html +++ b/testapp/templates/exam/quizzes_user.html @@ -31,7 +31,7 @@
Quiz Result Mraks Obtained {% if paper.quiz.prerequisite %} - You have to pass {{ paper.quiz.prerequisite.description }} for taking {{ paper.quiz.description }} + You have to pass {{ paper.quiz.prerequisite.description }} for taking {{ paper.quiz.description }} {% else %} No pre requisites for {{ paper.quiz.description }} {% endif %} -- cgit From 2e1a56c7d485b17dbeadf7458332c2e33a84f00e Mon Sep 17 00:00:00 2001 From: hardythe1 Date: Wed, 2 Jul 2014 13:13:18 +0530 Subject: removing links --- testapp/exam/views.py | 1 - 1 file changed, 1 deletion(-) diff --git a/testapp/exam/views.py b/testapp/exam/views.py index ad5c263..42a4f76 100644 --- a/testapp/exam/views.py +++ b/testapp/exam/views.py @@ -168,7 +168,6 @@ def intro(request, questionpaper_id): user = request.user ci = RequestContext(request) quest_paper = QuestionPaper.objects.get(id=questionpaper_id) - print quest_paper.quiz.prerequisite if quest_paper.quiz.prerequisite: try: pre_quest = QuestionPaper.objects.get(quiz=quest_paper.quiz.prerequisite) -- cgit