diff options
author | adityacp | 2017-04-24 11:25:06 +0530 |
---|---|---|
committer | adityacp | 2017-04-24 11:25:06 +0530 |
commit | 0688e71c1b20d57234ac19473a88cd8419cd8928 (patch) | |
tree | 8c439f46bf96ce695296527072dfa94c7720a041 | |
parent | a44a75fef4bfd9a2a15f7bb8ce38d720fe2f411e (diff) | |
parent | 0208f8643a80fbee52ad8ff273bdc459f00d0e89 (diff) | |
download | online_test-0688e71c1b20d57234ac19473a88cd8419cd8928.tar.gz online_test-0688e71c1b20d57234ac19473a88cd8419cd8928.tar.bz2 online_test-0688e71c1b20d57234ac19473a88cd8419cd8928.zip |
Change views and grade user for assignments download
-rw-r--r-- | yaksh/templates/yaksh/course_detail.html | 4 | ||||
-rw-r--r-- | yaksh/templates/yaksh/courses.html | 2 | ||||
-rw-r--r-- | yaksh/templates/yaksh/grade_user.html | 17 | ||||
-rw-r--r-- | yaksh/templates/yaksh/moderator_dashboard.html | 4 | ||||
-rw-r--r-- | yaksh/templates/yaksh/monitor.html | 67 | ||||
-rw-r--r-- | yaksh/templates/yaksh/showquestions.html | 1 | ||||
-rw-r--r-- | yaksh/urls.py | 2 | ||||
-rw-r--r-- | yaksh/views.py | 40 |
8 files changed, 85 insertions, 52 deletions
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 %} <script language="JavaScript" type="text/javascript" src="{{ URL_ROOT }}/static/yaksh/js/course.js"></script> diff --git a/yaksh/templates/yaksh/courses.html b/yaksh/templates/yaksh/courses.html index 60e6bf4..e09a9cc 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 1ac4757..c93ec10 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 @@ <script src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_CHTML"></script> {% endblock script %} - {% if course_details %} <table id="course-details" class="table table-bordered"> <tr> - <th>Courses</th> + <th>Courses</th> <th> Quizzes </th> </tr> @@ -37,13 +38,17 @@ {% endif %} <div class="row"> -{%if users %} +{% if not course_details %} +{% if users %} <div id = "student" class="col-md-2"> {% for user in users %} <p><a href = "{{URL_ROOT}}/exam/manage/gradeuser/{{quiz_id}}/{{user.user__id}}"> {{user.user__first_name}} {{user.user__last_name}}</a></p> {% endfor %} </div> +{% else %} +<h4>No Users Found for {{ quiz.description }}</h4> +{% endif %} {% endif %} {% if has_quiz_assignments %} @@ -57,7 +62,7 @@ <p> <h3> <center> Showing paper for {{data.user.get_full_name.title}} </center></h3> -<p><b>Name:</b>{{ data.user.get_full_name.title }} +<p><b>Name:</b> {{ data.user.get_full_name.title }} {% if data.profile %} <p><b> Roll number:</b> {{ data.profile.roll_number }} @@ -72,7 +77,9 @@ <hr> {{ paper.total_marks }} -<h3> Quiz: {{ paper.question_paper.quiz.description }} </h3> +<h4> Course: {{ paper.question_paper.quiz.course.name }}</h4> +<h4> Quiz: {{ paper.question_paper.quiz.description }} </h4> + <p> Attempt Number: <b>{{paper.attempt_number}} </b> <select id = "attempt" onchange="window.location.href=this.value"> 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,6 +9,7 @@ <center><h4>List of quizzes! Click on the given links to have a look at answer papers for a quiz.</h4></center> <table class="table table-bordered"> + <th>Course</th> <th>Quiz</th> <th>Taken By</th> <th>No. of users Passed</th> @@ -16,6 +17,9 @@ {% for paper, answer_papers, users_passed, users_failed in users_per_paper %} <tr> <td> + {{ paper.quiz.course.name }} + </td> + <td> <a href="{{URL_ROOT}}/exam/manage/monitor/{{paper.id}}/">{{ paper.quiz.description }}</a> </td> <td> 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 %} <meta http-equiv="refresh" content="30"/> {% endblock meta %} {% block script %} +{% if papers %} <script src="{{ URL_ROOT }}/static/yaksh/js/jquery.tablesorter.min.js"></script> <script type="text/javascript"> -$(document).ready(function() +$(document).ready(function() { $("#result-table").tablesorter({sortList: [[5,1]]}); var papers_length = "{{papers|length}}"; @@ -23,41 +24,48 @@ $(document).ready(function() } }); </script> - +{% 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 %} - <center><h5> No quizzes available. </h5></center> - {% endif %} {# ############################################################### #} {# This is rendered when we are just viewing exam/monitor #} -{% if quizzes %} -<ul class="list-group"> -{% for q in quizzes %} -<li class="list-group-item"><a href="{{URL_ROOT}}/exam/manage/monitor/{{q.id}}/">{{ q.quiz.description }}</a></li> -{% endfor %} -</ul> + +{% if course_details %} + <table id="course-details" class="table table-bordered"> + <tr> + <th>Courses</th> + <th> Quizzes </th> + </tr> + + {% for course in course_details %} + <tr> + <td><ul class="list-group">{{course.name}} </td> + + {% if course.get_quizzes %} + <td> + {% for quiz in course.get_quizzes %} + <li class="list-group-item"><a href = "{{URL_ROOT}}/exam/manage/monitor/{{quiz.id}}"> + {{quiz.description}} + </a></li> + {% endfor %} + </td> + {% else %} + <td> No quiz</td> + {% endif %} + </ul></tr> + {% endfor %} + </table> {% endif %} {# ############################################################### #} {# This is rendered when we are just viewing exam/monitor/quiz_num #} +{% if msg != "Monitor" %} {% if quiz %} - {% if papers %} +<p>Course Name: {{ quiz.course.name }}</p> +<p>Quiz Name: {{ quiz.description }}</p> <p>Number of papers: {{ papers|length }} </p> {% completed papers as completed_papers %} {# template tag used to get the count of completed papers #} @@ -80,6 +88,7 @@ $(document).ready(function() <th> Marks obtained </th> <th> Attempts </th> <th> Time Remaining </th> + <th> Status </th> </tr> </thead> <tbody> @@ -93,13 +102,17 @@ $(document).ready(function() <td> {{ paper.marks_obtained }} </td> <td> {{ paper.answers.count }} </td> <td id="time_left{{forloop.counter0}}"> {{ paper.time_left }} </td> + <td>{{ paper.status }}</td> </div> </tr> {% endfor %} </tbody> </table> {% else %} -<p> No answer papers so far. </p> +<p> No answer papers found for {{ quiz.description }}</p> {% endif %} {# if papers #} +{% else %} +<h4>No Quiz Found</h4> +{% 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 %} diff --git a/yaksh/urls.py b/yaksh/urls.py index 5623eab..8ddfe67 100644 --- a/yaksh/urls.py +++ b/yaksh/urls.py @@ -42,7 +42,7 @@ urlpatterns = [ url(r'^manage/showquestionpapers/$', views.show_all_questionpapers), url(r'^manage/showquestionpapers/(?P<questionpaper_id>\d+)/$',\ views.show_all_questionpapers), - url(r'^manage/monitor/(?P<questionpaper_id>\d+)/$', views.monitor), + url(r'^manage/monitor/(?P<quiz_id>\d+)/$', views.monitor), url(r'^manage/user_data/(?P<user_id>\d+)/(?P<questionpaper_id>\d+)/$', views.user_data), url(r'^manage/user_data/(?P<user_id>\d+)/$', views.user_data), diff --git a/yaksh/views.py b/yaksh/views.py index 0db1812..44f06b1 100644 --- a/yaksh/views.py +++ b/yaksh/views.py @@ -289,9 +289,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 + ).distinct() trial_paper = AnswerPaper.objects.filter(user=user, question_paper__quiz__is_trial=True ) @@ -790,7 +792,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 @@ -798,22 +800,23 @@ 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. 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, - id=questionpaper_id).distinct() + quiz_id=quiz_id).distinct() except QuestionPaper.DoesNotExist: papers = [] q_paper = None @@ -828,8 +831,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) @@ -1116,10 +1119,15 @@ 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) + 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') + has_quiz_assignments = AssignmentUpload.objects.filter( question_paper_id=questionpaper_id ).exists() - context = {"users": user_details, "quiz_id": quiz_id, + context = {"users": user_details, "quiz_id": quiz_id, "quiz":quiz, "has_quiz_assignments": has_quiz_assignments } if user_id is not None: |