From e3d289ca93047a1632a74ecfd5bc996433f3edb4 Mon Sep 17 00:00:00 2001 From: adityacp Date: Tue, 4 Apr 2017 16:16:56 +0530 Subject: Change in views and urls - Change monitor and grade_user function in views - Change url to get quiz id instead of question paper id --- yaksh/urls.py | 2 +- yaksh/views.py | 43 +++++++++++++++++++++++++------------------ 2 files changed, 26 insertions(+), 19 deletions(-) (limited to 'yaksh') diff --git a/yaksh/urls.py b/yaksh/urls.py index ad58985..9108b7b 100644 --- a/yaksh/urls.py +++ b/yaksh/urls.py @@ -40,7 +40,7 @@ urlpatterns = [ url(r'^manage/showquestionpapers/$', views.show_all_questionpapers), url(r'^manage/showquestionpapers/(?P\d+)/$',\ views.show_all_questionpapers), - url(r'^manage/monitor/(?P\d+)/$', views.monitor), + url(r'^manage/monitor/(?P\d+)/$', views.monitor), url(r'^manage/user_data/(?P\d+)/(?P\d+)/$', views.user_data), url(r'^manage/user_data/(?P\d+)/$', views.user_data), diff --git a/yaksh/views.py b/yaksh/views.py index 2adc2c3..c5aeb1c 100644 --- a/yaksh/views.py +++ b/yaksh/views.py @@ -284,9 +284,11 @@ def prof_manage(request, msg=None): user = request.user ci = RequestContext(request) if user.is_authenticated() and is_moderator(user): - question_papers = QuestionPaper.objects.filter(quiz__course__creator=user, - quiz__is_trial=False - ) + question_papers = QuestionPaper.objects.filter( + Q(quiz__course__creator=user) | + Q(quiz__course__teachers=user), + quiz__is_trial=False + ) trial_paper = AnswerPaper.objects.filter(user=user, question_paper__quiz__is_trial=True ) @@ -306,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).count() + passed=True).distinct().count() users_failed = AnswerPaper.objects.filter(question_paper=paper, - passed=False).count() + passed=False).distinct().count() temp = paper, answer_papers, users_passed, users_failed users_per_paper.append(temp) context = {'user': user, 'users_per_paper': users_per_paper, @@ -759,7 +761,7 @@ def show_statistics(request, questionpaper_id, attempt_number=None): @login_required -def monitor(request, questionpaper_id=None): +def monitor(request, quiz_id=None): """Monitor the progress of the papers taken so far.""" user = request.user @@ -767,14 +769,12 @@ def monitor(request, questionpaper_id=None): if not user.is_authenticated() or not is_moderator(user): raise Http404('You are not allowed to view this page!') - if questionpaper_id is None: - q_paper = QuestionPaper.objects.filter(Q(quiz__course__creator=user) | - Q(quiz__course__teachers=user), - quiz__is_trial=False - ).distinct() - context = {'papers': [], - 'quiz': None, - 'quizzes': q_paper} + if quiz_id is None: + course_details = Course.objects.filter(Q(creator=user) | + Q(teachers=user), + is_trial=False).distinct() + context = {'papers': [], "course_details": course_details, + "msg": "Monitor"} return my_render_to_response('yaksh/monitor.html', context, context_instance=ci) # quiz_id is not None. @@ -782,7 +782,10 @@ def monitor(request, questionpaper_id=None): q_paper = QuestionPaper.objects.filter(Q(quiz__course__creator=user) | Q(quiz__course__teachers=user), quiz__is_trial=False, - id=questionpaper_id).distinct() + 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 @@ -797,8 +800,8 @@ def monitor(request, questionpaper_id=None): last_attempt_num=Max('attempt_number')) latest_attempts.append(papers.get(user__in=auser, attempt_number=last_attempt['last_attempt_num'])) - context = {'papers': papers, 'quiz': q_paper, 'quizzes': None, - 'latest_attempts': latest_attempts,} + context = {'papers': papers, "quiz": quiz, "msg": "Quiz Results", + 'latest_attempts': latest_attempts} return my_render_to_response('yaksh/monitor.html', context, context_instance=ci) @@ -1082,7 +1085,11 @@ def grade_user(request, quiz_id=None, user_id=None, attempt_number=None): .values("id") user_details = AnswerPaper.objects\ .get_users_for_questionpaper(questionpaper_id) - context = {"users": user_details, "quiz_id": quiz_id} + quiz = get_object_or_404(Quiz, id=quiz_id) + if not quiz.course.is_creator(current_user) and not \ + quiz.course.is_teacher(current_user): + raise Http404('This course does not belong to you') + context = {"users": user_details, "quiz_id": quiz_id, "quiz": quiz} if user_id is not None: attempts = AnswerPaper.objects.get_user_all_attempts\ -- cgit From 9b8b99b69066f6a627a2a660d6ad2e63e31f446a Mon Sep 17 00:00:00 2001 From: adityacp Date: Tue, 4 Apr 2017 16:24:52 +0530 Subject: Change in templates - Display course name and quiz name in Grade user page and monitor page - Give html title to all templates - Display alloted course's quizzes in moderator dashboard --- yaksh/templates/yaksh/course_detail.html | 4 +- yaksh/templates/yaksh/courses.html | 2 +- yaksh/templates/yaksh/grade_user.html | 18 ++++--- yaksh/templates/yaksh/moderator_dashboard.html | 4 ++ yaksh/templates/yaksh/monitor.html | 67 +++++++++++++++----------- yaksh/templates/yaksh/showquestions.html | 1 + 6 files changed, 59 insertions(+), 37 deletions(-) (limited to 'yaksh') diff --git a/yaksh/templates/yaksh/course_detail.html b/yaksh/templates/yaksh/course_detail.html index 4b7efaf..81569fa 100644 --- a/yaksh/templates/yaksh/course_detail.html +++ b/yaksh/templates/yaksh/course_detail.html @@ -1,8 +1,8 @@ {% extends "manage.html" %} -{% block title %} Course {% endblock title %} +{% block title %} Course Details {% endblock title %} -{% block subtitle %} {{ course.name }} {% endblock %} +{% block pagetitle %} Course Details for {{ course.name|title }} {% endblock %} {% block script %} diff --git a/yaksh/templates/yaksh/courses.html b/yaksh/templates/yaksh/courses.html index 970d488..766b444 100644 --- a/yaksh/templates/yaksh/courses.html +++ b/yaksh/templates/yaksh/courses.html @@ -1,5 +1,5 @@ {% extends "manage.html" %} - +{% block title %} Courses {% endblock %} {% block pagetitle %} Courses {% endblock pagetitle %} {% block content %} {% if not courses %} diff --git a/yaksh/templates/yaksh/grade_user.html b/yaksh/templates/yaksh/grade_user.html index 1cb1f99..67f25a4 100644 --- a/yaksh/templates/yaksh/grade_user.html +++ b/yaksh/templates/yaksh/grade_user.html @@ -1,5 +1,7 @@ {% extends "manage.html" %} +{% block title %} Grade User {% endblock %} + {% block pagetitle %} Grade User {% endblock pagetitle %} {% block content %} @@ -8,11 +10,10 @@ {% endblock script %} - {% if course_details %} - + @@ -37,23 +38,25 @@ {% endif %}
-{%if users %} +{% if not course_details %} +{% if users %}
{% for user in users %}

{{user.user__first_name}} {{user.user__last_name}}

{% endfor %}
+{% else %} +

No Users Found for {{ quiz.description }}

+{% endif %} {% endif %} - -
{% if data %}

Showing paper for {{data.user.get_full_name.title}}

-

Name:{{ data.user.get_full_name.title }} +

Name: {{ data.user.get_full_name.title }} {% if data.profile %}

Roll number: {{ data.profile.roll_number }} @@ -68,7 +71,8 @@


{{ paper.total_marks }} -

Quiz: {{ paper.question_paper.quiz.description }}

+

Course: {{ paper.question_paper.quiz.course.name }}

+

Quiz: {{ paper.question_paper.quiz.description }}

Attempt Number: {{paper.attempt_number}} diff --git a/yaksh/templates/yaksh/moderator_dashboard.html b/yaksh/templates/yaksh/moderator_dashboard.html index 0468ed9..faccffe 100644 --- a/yaksh/templates/yaksh/moderator_dashboard.html +++ b/yaksh/templates/yaksh/moderator_dashboard.html @@ -9,12 +9,16 @@

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

CoursesCourses Quizzes
+ {% for paper, answer_papers, users_passed, users_failed in users_per_paper %} + diff --git a/yaksh/templates/yaksh/monitor.html b/yaksh/templates/yaksh/monitor.html index d2c89ce..9ce0dc4 100644 --- a/yaksh/templates/yaksh/monitor.html +++ b/yaksh/templates/yaksh/monitor.html @@ -1,15 +1,16 @@ {% extends "manage.html" %} {% load custom_filters %} - -{% block pagetitle %} Quiz results {% endblock pagetitle %} +{% block title %} Monitor {% endblock %} +{% block pagetitle %} {{ msg }} {% endblock pagetitle %} {% block meta %} {% endblock meta %} {% block script %} +{% if papers %} - +{% endif %} {% endblock %} - -{% block subtitle %} - {% if not quizzes and not quiz %} - Quiz Results - {% endif %} - {% if quizzes %} - Available Quizzes - {% endif %} - {% if quiz %} - {{ quiz.description }} Results - {% endif %} -{% endblock %} {% block content %} - {% if not quizzes and not quiz %} -
No quizzes available.
- {% endif %} {# ############################################################### #} {# This is rendered when we are just viewing exam/monitor #} -{% if quizzes %} - + +{% if course_details %} +
Course Quiz Taken By No. of users Passed No. of users Failed
+ {{ paper.quiz.course.name }} + {{ paper.quiz.description }}
+ + + + + + {% for course in course_details %} + + + + {% if course.get_quizzes %} + + {% else %} + + {% endif %} + + {% endfor %} +
Courses Quizzes
    {{course.name}}
+ {% for quiz in course.get_quizzes %} +
  • + {{quiz.description}} +
  • + {% endfor %} +
    No quiz
    {% endif %} {# ############################################################### #} {# This is rendered when we are just viewing exam/monitor/quiz_num #} +{% if msg != "Monitor" %} {% if quiz %} - {% if papers %} +

    Course Name: {{ quiz.course.name }}

    +

    Quiz Name: {{ quiz.description }}

    Number of papers: {{ papers|length }}

    {% completed papers as completed_papers %} {# template tag used to get the count of completed papers #} @@ -80,6 +88,7 @@ $(document).ready(function() Marks obtained Attempts Time Remaining + Status @@ -93,13 +102,17 @@ $(document).ready(function() {{ paper.marks_obtained }} {{ paper.answers.count }} {{ paper.time_left }} + {{ paper.status }} {% endfor %} {% else %} -

    No answer papers so far.

    +

    No answer papers found for {{ quiz.description }}

    {% endif %} {# if papers #} +{% else %} +

    No Quiz Found

    +{% endif %} {% endif %} {% endblock %} diff --git a/yaksh/templates/yaksh/showquestions.html b/yaksh/templates/yaksh/showquestions.html index 157b378..a136ddf 100644 --- a/yaksh/templates/yaksh/showquestions.html +++ b/yaksh/templates/yaksh/showquestions.html @@ -1,5 +1,6 @@ {% extends "manage.html" %} +{% block title %} Questions {% endblock %} {% block pagetitle %} List of Questions {% endblock pagetitle %} -- cgit From d2cbe09ff6d356e537ed1845b292b2138b6b8295 Mon Sep 17 00:00:00 2001 From: adityacp Date: Wed, 19 Apr 2017 14:41:45 +0530 Subject: Change views to get distinct quizzes in dashboard --- yaksh/views.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'yaksh') 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 -- cgit