summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoradityacp2020-04-17 16:54:35 +0530
committeradityacp2020-04-17 16:54:35 +0530
commit348f2bc4f727b27abd9878334e886527479d260c (patch)
treeb1652b2c981540a73d0bd87ebca13db4cea22ef0
parent4802a89acef7567c6a8861daab60924fe862367f (diff)
downloadonline_test-348f2bc4f727b27abd9878334e886527479d260c.tar.gz
online_test-348f2bc4f727b27abd9878334e886527479d260c.tar.bz2
online_test-348f2bc4f727b27abd9878334e886527479d260c.zip
Merge monitor, grade user and regrade intosingle dashboard
-rw-r--r--online_test/__init__.py6
-rw-r--r--online_test/celery.py19
-rw-r--r--online_test/settings.py12
-rw-r--r--yaksh/middleware/get_notifications.py21
-rw-r--r--yaksh/tasks.py83
-rw-r--r--yaksh/templates/manage.html30
-rw-r--r--yaksh/templates/yaksh/grade_user.html109
-rw-r--r--yaksh/templates/yaksh/monitor.html366
-rw-r--r--yaksh/templates/yaksh/regrade.html175
-rw-r--r--yaksh/templates/yaksh/user_data.html5
-rw-r--r--yaksh/templates/yaksh/view_notifications.html60
-rw-r--r--yaksh/urls.py26
-rw-r--r--yaksh/views.py119
13 files changed, 562 insertions, 469 deletions
diff --git a/online_test/__init__.py b/online_test/__init__.py
index ef91994..07d5e33 100644
--- a/online_test/__init__.py
+++ b/online_test/__init__.py
@@ -1 +1,7 @@
+from __future__ import absolute_import, unicode_literals
+
+from .celery import app as celery_app
+
+__all__ = ('celery_app',)
+
__version__ = '0.14.0'
diff --git a/online_test/celery.py b/online_test/celery.py
new file mode 100644
index 0000000..582f8a1
--- /dev/null
+++ b/online_test/celery.py
@@ -0,0 +1,19 @@
+from __future__ import absolute_import, unicode_literals
+
+import os
+from django.conf import settings
+from celery import Celery
+
+# set the default Django settings module for the 'celery' program.
+os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'online_test.settings')
+
+app = Celery('online_test')
+
+# Using a string here means the worker doesn't have to serialize
+# the configuration object to child processes.
+# - namespace='CELERY' means all celery-related configuration keys
+# should have a `CELERY_` prefix.
+app.config_from_object('django.conf:settings', namespace='CELERY')
+
+# Load task modules from all registered Django app configs.
+app.autodiscover_tasks(lambda: settings.INSTALLED_APPS)
diff --git a/online_test/settings.py b/online_test/settings.py
index 7b9a231..aa373c4 100644
--- a/online_test/settings.py
+++ b/online_test/settings.py
@@ -45,6 +45,8 @@ INSTALLED_APPS = (
'taggit',
'social_django',
'grades',
+ 'django_celery_beat',
+ 'notifications_plugin',
)
MIDDLEWARE = (
@@ -53,6 +55,7 @@ MIDDLEWARE = (
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'yaksh.middleware.one_session_per_user.OneSessionPerUserMiddleware',
+ 'yaksh.middleware.get_notifications.NotificationMiddleware',
'yaksh.middleware.user_time_zone.TimezoneMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
@@ -164,6 +167,7 @@ TEMPLATES = [
'social_django.context_processors.backends',
'social_django.context_processors.login_redirect',
'django.contrib.messages.context_processors.messages',
+ 'django.template.context_processors.request',
],
'debug': True, # make this False in production
}
@@ -208,3 +212,11 @@ AUTH_PASSWORD_VALIDATORS = [
]
TAGGIT_CASE_INSENSITIVE = True
+
+# Celery parameters
+CELERY_BEAT_SCHEDULER = 'django_celery_beat.schedulers.DatabaseScheduler'
+CELERY_TASK_SERIALIZER = 'json'
+CELERY_RESULT_SERIALIZER = 'json'
+CELERY_ACCEPT_CONTENT = ['json']
+CELERY_TIMEZONE = 'Asia/Kolkata'
+CELERY_BROKER_URL = 'redis://localhost'
diff --git a/yaksh/middleware/get_notifications.py b/yaksh/middleware/get_notifications.py
new file mode 100644
index 0000000..d211ad3
--- /dev/null
+++ b/yaksh/middleware/get_notifications.py
@@ -0,0 +1,21 @@
+from notifications_plugin.models import Notification
+
+class NotificationMiddleware(object):
+ """ Middleware to get user's notifications """
+ def __init__(self, get_response):
+ self.get_response = get_response
+
+ def __call__(self, request):
+ # Code to be executed for each request before
+ # the view (and later middleware) are called.
+ user = request.user
+ if user.is_authenticated:
+ notifications = Notification.objects.get_unread_receiver_notifications(
+ user.id
+ ).count()
+ request.custom_notifications = notifications
+ response = self.get_response(request)
+
+ # Code to be executed for each request/response after
+ # the view is called.
+ return response
diff --git a/yaksh/tasks.py b/yaksh/tasks.py
new file mode 100644
index 0000000..c68faa9
--- /dev/null
+++ b/yaksh/tasks.py
@@ -0,0 +1,83 @@
+# Python Imports
+from __future__ import absolute_import, unicode_literals
+from textwrap import dedent
+
+# Django and celery imports
+from celery import shared_task
+from celery.utils.log import get_task_logger
+from django.urls import reverse
+from django.shortcuts import get_object_or_404
+
+# Local imports
+from .models import Course, QuestionPaper, Quiz, AnswerPaper, CourseStatus
+from notifications_plugin.models import NotificationMessage, Notification
+
+
+@shared_task
+def regrade_papers(data):
+ question_id = data.get("question_id")
+ questionpaper_id = data.get("questionpaper_id")
+ answerpaper_id = data.get("answerpaper_id")
+ course_id = data.get("course_id")
+ user_id = data.get("user_id")
+ quiz_id = data.get("quiz_id")
+ quiz_name = data.get("quiz_name")
+ course_name = data.get("course_name")
+
+ logger = get_task_logger(__name__)
+
+ try:
+ if answerpaper_id is not None and question_id is None:
+ # Regrade specific user for all questions
+ answerpaper = AnswerPaper.objects.get(id=answerpaper_id)
+ for question in answerpaper.questions.all():
+ answerpaper.regrade(question.id)
+ course_status = CourseStatus.objects.filter(
+ user=answerpaper.user, course=answerpaper.course)
+ if course_status.exists():
+ course_status.first().set_grade()
+ url = reverse("yaksh:grade_user",
+ args=[quiz_id, answerpaper.user_id, course_id])
+
+ elif answerpaper_id is not None and question_id is not None:
+ # Regrade specific user for a specific question
+ answerpaper = AnswerPaper.objects.get(pk=answerpaper_id)
+ answerpaper.regrade(question_id)
+ course_status = CourseStatus.objects.filter(user=answerpaper.user,
+ course=answerpaper.course)
+ if course_status.exists():
+ course_status.first().set_grade()
+ url = reverse("yaksh:grade_user",
+ args=[quiz_id, answerpaper.user_id, course_id])
+
+ elif questionpaper_id is not None and question_id is not None:
+ # Regrade all users for a specific question
+ answerpapers = AnswerPaper.objects.filter(
+ questions=question_id,
+ question_paper_id=questionpaper_id, course_id=course_id)
+ for answerpaper in answerpapers:
+ answerpaper.regrade(question_id)
+ course_status = CourseStatus.objects.filter(
+ user=answerpaper.user, course=answerpaper.course)
+ if course_status.exists():
+ course_status.first().set_grade()
+ url = reverse("yaksh:grade_user", args=[quiz_id, course_id])
+
+ message = dedent("""
+ Quiz re-evaluation is complete Click <a href="{0}">here</a> to view
+ """.format(url)
+ )
+ nm = NotificationMessage.objects.add_single_message(
+ user_id, "{0} re-evaluation status".format(quiz_name),
+ message, "success"
+ )
+ except Exception as e:
+ nm = NotificationMessage.objects.add_single_message(
+ user_id, "{0} re-evaluation status".format(quiz_name),
+ "Unable to regrade {0}. Try again later".format(quiz_name),
+ "warning"
+ )
+ logger.error(e)
+ notification = Notification.objects.add_single_notification(
+ user_id, nm.id
+ )
diff --git a/yaksh/templates/manage.html b/yaksh/templates/manage.html
index 8e74494..1b3527d 100644
--- a/yaksh/templates/manage.html
+++ b/yaksh/templates/manage.html
@@ -12,13 +12,33 @@
<div class="collapse navbar-collapse" id="navbarColor01">
<ul class="navbar-nav mr-auto">
- <li class="nav-item"><a class="nav-link" href="{% url 'yaksh:show_questions' %}">Questions</a></li>
- <li class="nav-item"><a class="nav-link" href="{% url 'yaksh:courses' %}">Courses</a></li>
- <li class="nav-item"><a class="nav-link" href="{% url 'yaksh:monitor' %}">Monitor</a></li>
- <li class="nav-item"><a class="nav-link" href="{% url 'yaksh:grade_user' %}">Grade User</a></li>
- <li class="nav-item"><a class="nav-link" href="{% url 'yaksh:grader' %}"> Regrade </a></li>
+ <li class="nav-item">
+ <a class="nav-link" href="{% url 'yaksh:show_questions' %}">
+ Questions
+ </a>
+ </li>
+ <li class="nav-item">
+ <a class="nav-link" href="{% url 'yaksh:courses' %}">
+ Courses
+ </a>
+ </li>
+ <li class="nav-item">
+ <a class="nav-link" href="{% url 'yaksh:grade_user' %}">
+ Grader
+ </a>
+ </li>
</ul>
<ul class="navbar-nav ml-auto">
+ <li class="nav-item">
+ <a class="nav-link" href="{% url 'yaksh:view_notifications' %}">
+ <i class="fa fa-bell" style="size: 18px"></i>&nbsp;Notifications
+ {% if request.custom_notifications > 0 %}
+ <span class="badge badge-success badge-pill">
+ {{request.custom_notifications}}
+ </span>
+ {% endif %}
+ </a>
+ </li>
<li class="nav-item dropdown my-lg-0" style="font-size: 1.2rem">
<a class="dropdown-toggle nav-link" id="user_dropdown" data-toggle="dropdown" href="#">{{user.get_full_name|title}}
</a>
diff --git a/yaksh/templates/yaksh/grade_user.html b/yaksh/templates/yaksh/grade_user.html
index 7206525..223ff36 100644
--- a/yaksh/templates/yaksh/grade_user.html
+++ b/yaksh/templates/yaksh/grade_user.html
@@ -2,9 +2,9 @@
{% load custom_filters %}
{% load static %}
-{% block title %} Grade User {% endblock %}
+{% block title %} Grader {% endblock %}
-{% block pagetitle %} Grade User {% endblock pagetitle %}
+{% block pagetitle %} Grader {% endblock pagetitle %}
{% block script %}
<script type="text/javascript" src="{% static 'yaksh/js/jquery.tablesorter.min.js' %}">
@@ -34,7 +34,7 @@ $(document).ready(function()
</h5>
</div>
<div class="col-md">
- <a class="card-link btn btn-info" data-toggle="collapse" href="#collapse{{course.id}}">
+ <a class="card-link btn btn-outline-success" data-toggle="collapse" href="#collapse{{course.id}}">
Details
<i class="fa fa-toggle-down" id="toggle_course_{{course.id}}"></i>
</a>
@@ -53,7 +53,12 @@ $(document).ready(function()
{{quiz.description}}
</div>
<div class="col-md-2">
- <a href="{% url 'yaksh:grade_user' quiz.id course.id%}" class="btn btn-primary">
+ <a href="{% url 'yaksh:monitor' quiz.id course.id%}" class="btn btn-primary">
+ Monitor
+ </a>
+ </div>
+ <div class="col-md-2">
+ <a href="{% url 'yaksh:grade_user' quiz.id course.id%}" class="btn btn-info">
Grade
</a>
</div>
@@ -117,6 +122,46 @@ $(document).ready(function()
</a>
<br><br>
{% endif %}
+ {% if status == 'grade' and users %}
+ <div id="accordian-questions" class="card">
+ <div class="card-header">
+ <a class="card-link" data-toggle="collapse" href="#questions">
+ Regrade all papers by Questions&nbsp;<i class="fa fa-angle-down"></i>
+ </a>
+ </div>
+ <div id="questions" class="collapse hide" data-parent="#accordion-questions">
+ {% with quiz.questionpaper_set.get as qp %}
+ <div class="card-body">
+ <table class="table table-responsive-sm">
+ <thead>
+ <tr>
+ <th>Questions</th>
+ <th>Type</th>
+ <th>Marks</th>
+ <th>Regrade</th>
+ </tr>
+ </thead>
+ <tbody>
+ {% for question in qp.get_question_bank %}
+ <tr>
+ <td>{{ question.summary }}</td>
+ <td>{{ question.get_type_display }}</td>
+ <td>{{ question.points }}</td>
+ <td>
+ <a href="{% url 'yaksh:regrade_by_quiz' course_id quiz.questionpaper_set.get.id question.id %}" class="btn btn-outline-success">
+ <i class="fa fa-repeat"></i>&nbsp;Regrade
+ </a>
+ </td>
+ </tr>
+ {% endfor %}
+ </tbody>
+ </table>
+ </div>
+ {% endwith %}
+ </div>
+ </div>
+ <br>
+ {% endif %}
{% if messages %}
{% for message in messages %}
@@ -219,7 +264,16 @@ $(document).ready(function()
{% if paper.answers.count %}
<div class="card">
<div class="card-header">
- Submission Details
+ <div class="row">
+ <div class="col-md-6">
+ Submission Details
+ </div>
+ <div class="col-md-4">
+ <a href="{% url 'yaksh:regrade_by_user' course_id quiz.questionpaper_set.get.id paper.id %}" class="btn btn-outline-success">
+ <i class="fa fa-repeat"></i>&nbsp;Regrade Whole Paper
+ </a>
+ </div>
+ </div>
</div>
<div class="card-body">
<table class="tablesorter table table-striped table-bordered table-responsive-sm" id='marks_table'>
@@ -228,6 +282,7 @@ $(document).ready(function()
<th>Questions</th>
<th>Type</th>
<th>Marks Obtained</th>
+ <th>Regrade by question</th>
</tr>
</thead>
<tbody>
@@ -241,6 +296,11 @@ $(document).ready(function()
</td>
<td>{{ question.type }}</td>
<td>{{ answer.answer.marks }}</td>
+ <td>
+ <a href="{% url 'yaksh:regrade_by_question' course_id quiz.questionpaper_set.get.id paper.id question.id %}" class="btn btn-outline-success">
+ <i class="fa fa-repeat"></i>&nbsp;Regrade
+ </a>
+ </td>
</tr>
{% endwith %}
{% endfor %}
@@ -255,7 +315,8 @@ $(document).ready(function()
<div class="card-header text-white bg-info">
<strong>
Details: {{forloop.counter}}. {{ question.summary }}
- <span class="marks pull-right"> Mark(s): {{ question.points }} </span>
+ <span class="marks pull-right"> Mark(s): {{ question.points }}
+ </span>
</strong>
</div>
<div class="card-body">
@@ -501,4 +562,40 @@ $(document).ready(function()
</div>
</div>
</div>
+{% if details %}
+ <div class="modal">
+ <div class="modal-dialog" role="document">
+ <div class="modal-content">
+ <div class="modal-header">
+ <h5 class="modal-title">Regrade</h5>
+ <button type="button" class="close" data-dismiss="modal" aria-label="Close">
+ <span aria-hidden="true">&times;</span>
+ </button>
+ </div>
+ <div class="modal-body">
+ <table class="table table-responsive-sm">
+ <tbody>
+ {% for detail in details %}
+ {% if detail.0 %}
+ <tr class="table-success">
+ <td> Graded Successfully </td>
+ {% else%}
+ <tr class="table-danger">
+ <td> Did not Grade </td>
+ {% endif %}
+ <td> {{ detail.1|linebreaks }} </td>
+ </tr>
+ {% endfor %}
+ </tbody>
+ </table>
+ </div>
+ <div class="modal-footer">
+ <button type="button" class="btn btn-secondary" data-dismiss="modal">
+ Close
+ </button>
+ </div>
+ </div>
+ </div>
+ </div>
+{% endif %}
{% endblock%}
diff --git a/yaksh/templates/yaksh/monitor.html b/yaksh/templates/yaksh/monitor.html
index cf6888c..ef7b033 100644
--- a/yaksh/templates/yaksh/monitor.html
+++ b/yaksh/templates/yaksh/monitor.html
@@ -12,228 +12,176 @@
</script>
<script type="text/javascript">
$(document).ready(function()
- {
- $("#result-table").tablesorter({sortList: [[5,1]]});
- var papers_length = "{{papers|length}}";
- for (var i=0; i < papers_length; i++){
- var time_left = $("#time_left"+[i]);
+ {
+ $("#result-table").tablesorter({});
+ var papers_length = "{{papers|length}}";
+ for (var i=0; i < papers_length; i++){
+ var paper_status = $("#status"+[i]);
+ var hh, mm, ss;
+ var time_left = $("#time_left"+[i]);
+ if (paper_status.text() == "completed"){
+ hh = "-";
+ mm = "-";
+ ss = "-";
+ }
+ else{
var time = time_left.text();
- var hh = Math.floor(time / 3600);
- var mm = Math.floor((time - (hh * 3600)) / 60);
- var ss = time - (hh * 3600) - (mm * 60);
- time_left.text(hh + ":" + mm + ":" + ss)
- }
-});
+ hh = Math.floor(time / 3600);
+ mm = Math.floor((time - (hh * 3600)) / 60);
+ ss = time - (hh * 3600) - (mm * 60);
+ }
+ time_left.text(hh + ":" + mm + ":" + ss);
+ }
+ });
</script>
{% endif %}
{% endblock %}
{% block content %}
<div class="container">
- {# ############################################################### #}
- {# This is rendered when we are just viewing exam/monitor #}
- {% if objects %}
- {% include "yaksh/paginator.html" %}
- <div id="accordion">
- {% for course in objects %}
- <div class="card">
- <div class="card-header">
- <div class="row">
- <div class="col-md-9">
- <h5 data-toggle="tooltip" title="{{course.name}}">
- {{ course.name }}
- </h5>
- </div>
- <div class="col-md">
- <a class="card-link btn btn-info" data-toggle="collapse" href="#collapse{{course.id}}">
- Details
- <i class="fa fa-toggle-down" id="toggle_course_{{course.id}}"></i>
- </a>
- </div>
- </div>
- </div>
- <div id="collapse{{course.id}}" class="collapse hide" data-parent="#accordion">
- <div class="card-body">
- {% with course.get_quizzes as quizzes %}
- {% if quizzes %}
- <ul class="list-group">
- {% for quiz in quizzes %}
- <li class="list-group-item">
- <div class="row">
- <div class="col-md-8">
- {{quiz.description}}
- </div>
- <div class="col-md-2">
- <a href="{% url 'yaksh:monitor' quiz.id course.id%}" class="btn btn-primary">
- Monitor
- </a>
- </div>
- </div>
- </li>
- {% endfor %}
- </ul>
- {% else %}
- <center>
- <p class="badge badge-danger badge-pill">
- No Quizzes
- </p>
- </center>
- {% endif %}
- {% endwith %}
- </div>
- </div>
- </div>
- <br>
- {% endfor %}
- </div>
- {% include "yaksh/paginator.html" %}
-
- {% elif msg == 'Monitor' and not objects %}
- <br>
- <div class="alert alert-info">
- <center><h3>No courses to monitor</h3></center>
- </div>
- {% endif %}
- {# ############################################################### #}
- {# This is rendered when we are just viewing exam/monitor/quiz_num #}
- {% if msg != "Monitor" %}
- {% if quiz %}
- {% if papers %}
- <div class="card">
- <div class="table-responsive">
- <table id="course-detail" class="table">
- <tr>
- <td><b>Course Name:&nbsp</b></td>
- <td>{{course.name}}</td>
- </tr>
- <tr>
- <td><b>Quiz Name:&nbsp</b></td>
- <td>{{quiz.description}}</td>
- </tr>
- <tr>
- <td><b>Number of papers: &nbsp</b></td>
- <td>{{papers|length}}</td>
- </tr>
- <tr>
- <td><b>Papers Completed: &nbsp</b></td>
- <td>
- {% completed papers as completed_papers %}
- <b>{{completed_papers}}</b>
- </td>
- </tr>
- <tr>
- <td><b>Papers in progress: &nbsp</b></td>
- <td>
- {% inprogress papers as inprogress_papers %}
- <b>{{ inprogress_papers }}</b>
- </td>
- </tr>
- </table>
- </div>
+ {% if quiz %}
+ {% if papers %}
+ <div class="card">
+ <div class="table-responsive">
+ <table id="course-detail" class="table">
+ <tr>
+ <td><b>Course Name:&nbsp</b></td>
+ <td>{{course.name}}</td>
+ </tr>
+ <tr>
+ <td><b>Quiz Name:&nbsp</b></td>
+ <td>{{quiz.description}}</td>
+ </tr>
+ <tr>
+ <td><b>Number of papers: &nbsp</b></td>
+ <td>{{papers|length}}</td>
+ </tr>
+ <tr>
+ <td><b>Papers Completed: &nbsp</b></td>
+ <td>
+ {% completed papers as completed_papers %}
+ <b>{{completed_papers}}</b>
+ </td>
+ </tr>
+ <tr>
+ <td><b>Papers in progress: &nbsp</b></td>
+ <td>
+ {% inprogress papers as inprogress_papers %}
+ <b>{{ inprogress_papers }}</b>
+ </td>
+ </tr>
+ </table>
</div>
- <br>
- <div class="row">
- <div class="col-md-4">
- <a href="{% url 'yaksh:show_statistics' papers.0.question_paper.id course.id %}" class="btn btn-primary">
- <i class="fa fa-line-chart"></i>&nbsp;Question Statistics
- </a>
- </div>
- <div class="col-md-4">
- <button type="button" class="btn btn-info" data-toggle="modal" data-target="#csvModal">
- <i class="fa fa-download"></i>&nbsp;Download CSV
- </button>
- </div>
+ </div>
+ <br>
+ <div class="row">
+ <div class="col-md-4">
+ <a href="{% url 'yaksh:show_statistics' papers.0.question_paper.id course.id %}" class="btn btn-primary">
+ <i class="fa fa-line-chart"></i>&nbsp;Question Statistics
+ </a>
+ </div>
+ <div class="col-md-4">
+ <button type="button" class="btn btn-info" data-toggle="modal" data-target="#csvModal">
+ <i class="fa fa-download"></i>&nbsp;Download CSV
+ </button>
+ </div>
+ <div class="col-md-4">
+ <div class="badge badge-info">
+ Auto-Refreshes every 30 seconds
</div>
- <br>
- <table id="result-table" class="tablesorter table table-striped table-responsive-sm">
- <thead>
- <tr>
- <th> Name&nbsp;<i class="fa fa-sort"></i> </th>
- <th> Username&nbsp;<i class="fa fa-sort"></i> </th>
- <th> Roll No&nbsp;<i class="fa fa-sort"></i> </th>
- <th> Institute&nbsp;<i class="fa fa-sort"></i> </th>
- <th> Marks&nbsp;<i class="fa fa-sort"></i> </th>
- <th> Attempts&nbsp;<i class="fa fa-sort"></i> </th>
- <th> Time&nbsp;<i class="fa fa-sort"></i> </th>
- <th> Status&nbsp;<i class="fa fa-sort"></i> </th>
- </tr>
- </thead>
- <tbody>
- {% for paper in latest_attempts %}
- <tr>
- <td> <a href="{% url 'yaksh:user_data' paper.user.id paper.question_paper.id course.id %}">
- {{ paper.user.get_full_name.title }}</a> </td>
- <td> {{ paper.user.username }} </td>
- <td> {{ paper.user.profile.roll_number }} </td>
- <td> {{ paper.user.profile.institute }} </td>
- <td> {{ paper.marks_obtained }} </td>
- <td> {{ paper.answers.count }} </td>
- <td id="time_left{{forloop.counter0}}"> {{ paper.time_left }} </td>
- <td>{{ paper.status }}</td>
- </tr>
- {% endfor %}
- </tbody>
- </table>
- <!-- CSV Modal -->
- <div class="modal fade" id="csvModal" role="dialog">
- <div class="modal-dialog">
+ </div>
+ </div>
+ <br>
+ <table id="result-table" class="tablesorter table table-striped table-responsive-sm">
+ <thead>
+ <tr>
+ <th> Sr No. </th>
+ <th> Name&nbsp;<i class="fa fa-sort"></i> </th>
+ <th> Username&nbsp;<i class="fa fa-sort"></i> </th>
+ <th> Roll No&nbsp;<i class="fa fa-sort"></i> </th>
+ <th> Institute&nbsp;<i class="fa fa-sort"></i> </th>
+ <th> Marks&nbsp;<i class="fa fa-sort"></i> </th>
+ <th> Attempts&nbsp;<i class="fa fa-sort"></i> </th>
+ <th> Time&nbsp;<i class="fa fa-sort"></i> </th>
+ <th> Status&nbsp;<i class="fa fa-sort"></i> </th>
+ </tr>
+ </thead>
+ <tbody>
+ {% for paper in latest_attempts %}
+ <tr>
+ <td>{{forloop.counter}}</td>
+ <td> <a href="{% url 'yaksh:user_data' paper.user.id paper.question_paper.id course.id %}">
+ {{ paper.user.get_full_name.title }}</a> </td>
+ <td> {{ paper.user.username }} </td>
+ <td> {{ paper.user.profile.roll_number }} </td>
+ <td> {{ paper.user.profile.institute }} </td>
+ <td> {{ paper.marks_obtained }} </td>
+ <td> {{ paper.answers.count }} </td>
+ <td id="time_left{{forloop.counter0}}"> {{ paper.time_left }} </td>
+ <td id="status{{forloop.counter0}}">{{ paper.status }}</td>
+ </tr>
+ {% endfor %}
+ </tbody>
+ </table>
+ <!-- CSV Modal -->
+ <div class="modal fade" id="csvModal" role="dialog">
+ <div class="modal-dialog">
- <!-- Modal content-->
- <div class="modal-content">
- <div class="modal-header">
- <h3 class="modal-title">Download CSV for {{quiz.description}} </h3>
- <button type="button" class="close" data-dismiss="modal">
- <i class="fa fa-close"></i>
- </button>
+ <!-- Modal content-->
+ <div class="modal-content">
+ <div class="modal-header">
+ <h3 class="modal-title">Download CSV for {{quiz.description}} </h3>
+ <button type="button" class="close" data-dismiss="modal">
+ <i class="fa fa-close"></i>
+ </button>
+ </div>
+ <form action="{% url 'yaksh:download_quiz_csv' course.id quiz.id %}" method="post">
+ {% csrf_token %}
+ <div class="modal-body">
+ <b>Uncheck unwanted columns</b>
+ <br>
+ {% for field in csv_fields %}
+ <div class="form-check form-check-inline">
+ <label class="form-check-label">
+ <input class="form-check-input" name="csv_fields" type="checkbox" value="{{ field }}" checked> {{ field }}
+ </label>
</div>
- <form action="{% url 'yaksh:download_quiz_csv' course.id quiz.id %}" method="post">
- {% csrf_token %}
- <div class="modal-body">
- <b>Uncheck unwanted columns</b>
- <br>
- {% for field in csv_fields %}
- <div class="form-check form-check-inline">
- <label class="form-check-label">
- <input class="form-check-input" name="csv_fields" type="checkbox" value="{{ field }}" checked> {{ field }}
- </label>
- </div>
- <br>
+ <br>
+ {% endfor %}
+ <b>Select Attempt Number: Default latest attempt</b>
+ <select class="form-control" name = "attempt_number">
+ {%for attempt_number in attempt_numbers %}
+ {% if forloop.last %}
+ <option value="{{ attempt_number }}" selected>{{ attempt_number }} (Latest)</option>
+ {% else %}
+ <option value = "{{ attempt_number }}"> {{ attempt_number }}</option>
+ {% endif %}
{% endfor %}
- <b>Select Attempt Number: Default latest attempt</b>
- <select class="form-control" name = "attempt_number">
- {%for attempt_number in attempt_numbers %}
- {% if forloop.last %}
- <option value="{{ attempt_number }}" selected>{{ attempt_number }} (Latest)</option>
- {% else %}
- <option value = "{{ attempt_number }}"> {{ attempt_number }}</option>
- {% endif %}
- {% endfor %}
- </select>
- </div>
- <div class="modal-footer">
- <button type="submit" class="btn btn-success">
- <span class="fa fa-save"></span>&nbsp;Download
- </button>
- <button type="button" class="btn btn-secondary" data-dismiss="modal">
- Close
- </button>
- </div>
- </form>
- </div>
- </div>
+ </select>
+ </div>
+ <div class="modal-footer">
+ <button type="submit" class="btn btn-success">
+ <span class="fa fa-save"></span>&nbsp;Download
+ </button>
+ <button type="button" class="btn btn-secondary" data-dismiss="modal">
+ Close
+ </button>
+ </div>
+ </form>
</div>
- {% else %}
- <div class="col-md-12">
- <div class="alert alert-warning">
- <center>
- <h4>No Users Found for {{ quiz.description }}</h4>
- </center>
- </div>
</div>
- {% endif %} {# if papers #}
- {% else %}
- <h4>No Quiz Found</h4>
- {% endif %}
- {% endif %}
+ </div>
+ {% else %}
+ <div class="col-md-12">
+ <div class="alert alert-warning">
+ <center>
+ <h4>No Users Found for {{ quiz.description }}</h4>
+ </center>
+ </div>
+ </div>
+ {% endif %} {# if papers #}
+ {% else %}
+ <h4>No Quiz Found</h4>
+ {% endif %}
</div>
{% endblock %}
diff --git a/yaksh/templates/yaksh/regrade.html b/yaksh/templates/yaksh/regrade.html
deleted file mode 100644
index c70e470..0000000
--- a/yaksh/templates/yaksh/regrade.html
+++ /dev/null
@@ -1,175 +0,0 @@
-{% extends "manage.html" %}
-
-{% block pagetitle %} Grader {% endblock pagetitle %}
-
-{% block content %}
-<div class="yakshwell container">
-<div class="row">
- <div class="col-md-3 yakshlabel collapse" id="sidebar">
- <div class="nav nav-pills flex-column" role="tablist" aria-orientation="vertical">
- <a href="#intro" data-toggle="pill" class="nav-link active" role="tab" aria-controls="intro" aria-selected="true" id="introtab"> Intro </a>
- <a href="#questions" data-toggle="pill" class="nav-link" role="tab" aria-controls="questions" aria-selected="false" id="questionstab"> Question-wise regrade </a>
- <a href="#quizzes" data-toggle="pill" class="nav-link" role="tab" aria-controls="quizzes" aria-selected="false" id="quizzestab"> Quiz-wise regrade </a>
- <a href="#users" data-toggle="pill" class="nav-link" role="tab" aria-controls="users" aria-selected="false" id="userstab"> User-wise regrade </a>
- </div>
- </div><!--end of siddebar-->
- <a href="#sidebar" data-toggle="collapse" id="sidebaricon"><i class="fa fa-navicon fa-lg"></i></a>
- <main class="tab-content col" id="sidebarbody">
-
-
- <div id="intro" class="tab-pane fade show active" role="tabpanel" aria-labelledby="introtab">
- <h3 class="yakshred"> Regrade </h3>
- <dl>
- <dt class="yakshgreen"> Question wise regrade </dt>
- <dd> You can regrade a question for all answerpapers for a given quiz. </dd>
- <dt class="yakshgreen"> Quiz wise regrade <dt>
- <dd> You can regrade an answerpaper for a quiz or a question for the same. </dd>
- <dt class="yakshgreen"> User wise regrade </dt>
- <dd> You can regrade an answerpaper for an user or a question for the same. </dd>
- </dl>
- </div>
- <div id="questions" class="tab-pane fade" role="tabpanel" aria-labelledby="questionstab">
- <div class="card">
- {% for course in courses %}
-
- <div class="card-body">
- <h4><span class="">
- <a href="#questions_quizzes{{ course.id }}" data-toggle="collapse" class="btn btn-outline-success">Course: {{ course }}</a>
- </span></h4>
- <div id="questions_quizzes{{ course.id }}" class="collapse card">
- <div class="card-body">
- {% for quiz in course.get_quizzes %}
- <p><a href="#questions_questions{{ course.id }}{{ quiz.id }}" data-toggle="collapse" class="btn btn-outline-info">Quiz: {{ quiz }}</a></p>
- <div id="questions_questions{{ course.id }}{{ quiz.id }}" class="collapse card">
- {% with questionpaper=quiz.questionpaper_set.get %}
- <p class="text-center yakshred h5 bg-light"> Questions: </p>
- <ol class="list-group yakshwell">
- {% for question in questionpaper.fixed_questions.all %}
- <li class="list-group-item">{{ question.summary }}
- <a href="{{ URL_ROOT }}/exam/manage/regrade/questionpaper/{{ course.id }}/{{ question.id }}/{{ questionpaper.id }}/"
- class="btn btn-success pull-right"><span class="fa fa-repeat"></span> Regrade </a>
- </li>
- {% endfor %}
- {% for random_set in questionpaper.random_questions.all %}
- {% for question in random_set.questions.all %}
- <li class="list-group-item"> {{ question.summary }}
- <a href="{{ URL_ROOT }}/exam/manage/regrade/questionpaper/{{ course.id}}/{{ question.id }}/{{ questionpaper.id }}/"
- class="btn btn-success pull-right"><span class="fa fa-repeat"></span> Regrade </a>
- </li>
- {% endfor %}
- {% endfor %}
- </ol>
- {% endwith %}<br /><br />
- </div>
- {% endfor %}
- </div>
- </div>
- </div>
-
- {% endfor %}
- </div><!--card-->
- </div>
-
- <div id="quizzes" class="tab-pane fade" role="tabpanel" aria-labelledby="quizzestab">
- <div class="card">
- {% for course in courses %}
-
- <div class="card-body">
- <h4><span class="">
- <span class=""><a href="#quizzes_quizzes{{ course.id }}" data-toggle="collapse" class="btn btn-outline-success">Course: {{ course }}</a></span>
- </span></h4>
- <div id="quizzes_quizzes{{ course.id }}" class="collapse card">
- <div class="card-body">
- {% for quiz in course.get_quizzes %}
- <p><a href="#quizzes_papers{{ course.id }}{{ quiz.id }}" data-toggle="collapse" class="btn btn-outline-info">Quiz: {{ quiz }}</a></p>
- <div id="quizzes_papers{{ course.id }}{{ quiz.id }}" class="collapse">
- <ol class="list-group yakshwell">
- {% for answerpaper in quiz.questionpaper_set.get.answerpaper_set.all %}
- <li class="list-group-item bg-light">
- Username: {{ answerpaper.user.username }}; Name: {{ answerpaper.user.get_full_name }}; Attempt Number: {{ answerpaper.attempt_number}}
- <a href="{{ URL_ROOT }}/exam/manage/regrade/paper/{{ course.id }}/{{ answerpaper.id }}/"
- class="btn btn-success btn-sm pull-right"><span class="fa fa-repeat"></span> Regrade whole paper </a>
- </li>
- <ol class="list-group yakshwell">
- {% for question in answerpaper.questions.all %}
- <li class="list-group-item"> {{ question.summary }}
- <a href="{{ URL_ROOT }}/exam/manage/regrade/answerpaper/{{ course.id }}/{{ question.id }}/{{ answerpaper.id }}/"
- class="btn btn-success btn-sm pull-right"><span class="fa fa-repeat"></span> Regrade </a>
- </li>
- {% endfor %}
- </ol>
- {% endfor %}
- </ol>
- </div>
- {% endfor %}
- </div>
- </div>
- </div>
-
- {% endfor %}
- </div><!--card-->
- </div>
-
- <div id="users" class="tab-pane fade" role="tabpanel" aria-labelledby="userstab">
- <div class="card">
- <div class="card-body">
- {% for course in courses %}
-
- <h4><span class="">
- <a href="#users_users{{ course.id }}" data-toggle="collapse" class="btn btn-outline-success">Course: {{ course }}</a>
- </span></h4>
- <div id="users_users{{ course.id }}" class="collapse card">
- <div class="card-bodys">
- {% for user in course.students.all %}
- <p><a href="#users_papers{{ course.id }}{{ user.id }}" data-toggle="collapse" class="btn btn-outline-info"> Answer Papers for {{ user.get_full_name }}</a></p>
- <div id="users_papers{{ course.id }}{{ user.id }}" class="collapse card">
- <ol class="list-group yakshwell">
- {% for answerpaper in user.answerpaper_set.all %}
- <li class="list-group-item bg-light"> Quiz: {{answerpaper.question_paper.quiz.description }}; Attempt Number: {{ answerpaper.attempt_number }}
- <a href="{{ URL_ROOT }}/exam/manage/regrade/paper/{{ course.id }}/{{ answerpaper.id }}/"
- class="btn btn-success pull-right" ><span class="fa fa-repeat"></span> Regrade whole paper </a>
- </li>
- <ol class="list-group yakshwell">
- {% for question in answerpaper.questions.all %}
- <li class="list-group-item"> {{ question.summary }}
- <a href="{{ URL_ROOT }}/exam/manage/regrade/answerpaper/{{ course.id }}/{{ question.id }}/{{ answerpaper.id }}/"
- class="btn btn-success pull-right"><span class="fa fa-repeat"></span> Regrade </a>
- </li>
- {% endfor %}
- </ol>
- {% endfor %}
- </ol>
- </div>
- {% endfor %}
- </div>
- </div>
-
- {% endfor %}
-</div>
- </div><!--well-->
- </div>
-
- </main><!--span10-->
-</div><!--row-->
-
-{% if details %}
-<div>
- <table class="table table-responsive-sm">
- <tbody>
- {% for detail in details %}
- {% if detail.0 %}
- <tr class="table-success">
- <td> Graded Successfully </td>
- {% else%}
- <tr class="table-danger">
- <td> Did not Grade </td>
- {% endif %}
- <td> {{ detail.1|linebreaks }} </td>
- </tr>
- {% endfor %}
- </tbody>
- </table>
- </div>
- {% endif %}
-</div>
-{% endblock %}
diff --git a/yaksh/templates/yaksh/user_data.html b/yaksh/templates/yaksh/user_data.html
index 6547851..6252fb3 100644
--- a/yaksh/templates/yaksh/user_data.html
+++ b/yaksh/templates/yaksh/user_data.html
@@ -33,11 +33,6 @@
</div>
</div>
{% endwith %}
- <br>
- <a href="{% url 'yaksh:grade_user' data.papers.0.question_paper.quiz.id data.user.id course_id %}" class="btn btn-info">
- Grade User
- </a>
- <br>
{% for paper in data.papers %}
<br>
<h3><b><u>Attempt Number:</u></b>&nbsp;<span class="badge badge-pill badge-info">
diff --git a/yaksh/templates/yaksh/view_notifications.html b/yaksh/templates/yaksh/view_notifications.html
new file mode 100644
index 0000000..72f90f8
--- /dev/null
+++ b/yaksh/templates/yaksh/view_notifications.html
@@ -0,0 +1,60 @@
+{% extends template %}
+{% block title %} Notifications {% endblock %}
+{% block pagetitle %} Notifications {% endblock %}
+
+{% block main %}
+ <div class="container">
+ {% if messages %}
+ {% for message in messages %}
+ <div class="alert alert-dismissible alert-{{ message.tags }}">
+ <button type="button" class="close" data-dismiss="alert">
+ <i class="fa fa-close"></i>
+ </button>
+ <strong>{{ message }}</strong>
+ </div>
+ {% endfor %}
+ {% endif %}
+ {% if notifications %}
+ <form method="post" action="{% url 'yaksh:mark_notification' %}">
+ {% csrf_token %}
+ <button href="{% url 'yaksh:mark_notification' %}" class="btn btn-outline-success">
+ <i class="fa fa-check"></i>&nbsp;Mark all as read
+ </button>
+ <br><br>
+ <div class="row">
+ {% for notification in notifications %}
+ <div class="col-md-4">
+ <div class="toast show" role="alert" aria-live="assertive" aria-atomic="true">
+ {% with notification.message as message %}
+ <input type="hidden" name="uid" value="{{message.uid}}">
+ <div class="toast-header bg-{{message.message_type}}">
+ <strong class="mr-auto text-white">
+ {{message.summary}}
+ </strong>
+ <small class="text-white">
+ {{notification.timestamp|timesince:current_date_time}}
+ </small>
+ <a href="{% url 'yaksh:mark_notification' message.uid %}" class="ml-2 mb-1 close" data-dismiss="toast" aria-label="Close">
+ <span class="fa fa-check" aria-hidden="true" title="Mark as read"></span>
+ </a>
+ </div>
+ <div class="toast-body">
+ <p><b>From: </b>{{message.creator.get_full_name}}</p>
+ <p><b>Description:</b></p>
+ {{message.description|safe}}
+ </div>
+ {% endwith %}
+ </div>
+ <br>
+ </div>
+ {% endfor %}
+ </div>
+ </form>
+ {% else %}
+ <br>
+ <div class="alert alert-info">
+ <center>No Notifications Found</center>
+ </div>
+ {% endif %}
+ </div>
+{% endblock %} \ No newline at end of file
diff --git a/yaksh/urls.py b/yaksh/urls.py
index bdc3330..52c196b 100644
--- a/yaksh/urls.py
+++ b/yaksh/urls.py
@@ -1,4 +1,5 @@
from django.conf.urls import url
+from django.urls import path
from yaksh import views
urlpatterns = [
@@ -144,17 +145,14 @@ urlpatterns = [
name="download_questions"),
url(r'^manage/upload_questions/$', views.show_all_questions,
name="upload_questions"),
- url(r'^manage/grader/$', views.grader, name='grader'),
- url(r'^manage/regrade/question/(?P<course_id>\d+)/(?P<question_id>\d+)/$',
- views.regrade, name='regrade'),
- url(r'^manage/regrade/questionpaper/(?P<course_id>\d+)/'
- '(?P<question_id>\d+)/(?P<questionpaper_id>\d+)/$',
- views.regrade, name='regrade'),
- url(r'^manage/regrade/answerpaper/(?P<course_id>\d+)/'
- '(?P<question_id>\d+)/(?P<answerpaper_id>\d+)/$',
- views.regrade, name='regrade'),
- url(r'^manage/regrade/paper/(?P<course_id>\d+)/(?P<answerpaper_id>\d+)/$',
- views.regrade, name='regrade'),
+ url(r'^manage/regrade/paper/question/(?P<course_id>\d+)/'
+ '(?P<questionpaper_id>\d+)/(?P<question_id>\d+)/$',
+ views.regrade, name='regrade_by_quiz'),
+ url(r'^manage/regrade/user/(?P<course_id>\d+)/(?P<questionpaper_id>\d+)/'
+ '(?P<answerpaper_id>\d+)/$', views.regrade, name='regrade_by_user'),
+ url(r'^manage/regrade/user/question/(?P<course_id>\d+)/'
+ '(?P<questionpaper_id>\d+)/(?P<answerpaper_id>\d+)/'
+ '(?P<question_id>\d+)/', views.regrade, name='regrade_by_question'),
url(r'^manage/(?P<mode>godmode|usermode)/(?P<quiz_id>\d+)/'
'(?P<course_id>\d+)/$', views.test_quiz, name="test_quiz"),
url(r'^manage/create_demo_course/$', views.create_demo_course,
@@ -205,4 +203,10 @@ urlpatterns = [
views.course_teachers, name="course_teachers"),
url(r'^manage/download/course/progress/(?P<course_id>\d+)',
views.download_course_progress, name="download_course_progress"),
+ path('view/notifications', views.view_notifications,
+ name="view_notifications"),
+ path('mark/notifications/<uuid:message_uid>',
+ views.mark_notification, name="mark_notification"),
+ path('mark/notifications', views.mark_notification,
+ name="mark_notification"),
]
diff --git a/yaksh/views.py b/yaksh/views.py
index 9efcbe9..10b0e08 100644
--- a/yaksh/views.py
+++ b/yaksh/views.py
@@ -52,6 +52,8 @@ from .file_utils import extract_files, is_csv
from .send_emails import (send_user_mail,
generate_activation_key, send_bulk_mail)
from .decorators import email_verified, has_profile
+from .tasks import regrade_papers
+from notifications_plugin.models import Notification
def my_redirect(url):
@@ -439,6 +441,7 @@ def prof_manage(request, msg=None):
courses = Course.objects.get_queryset().filter(
Q(creator=user) | Q(teachers=user),
is_trial=False).distinct().order_by("-active")
+
paginator = Paginator(courses, 20)
page = request.GET.get('page')
courses = paginator.get_page(page)
@@ -1268,18 +1271,6 @@ def monitor(request, quiz_id=None, course_id=None):
if not is_moderator(user):
raise Http404('You are not allowed to view this page!')
- if quiz_id is None:
- courses = Course.objects.filter(
- Q(creator=user) | Q(teachers=user),
- is_trial=False
- ).order_by("-active").distinct()
- paginator = Paginator(courses, 30)
- page = request.GET.get('page')
- courses = paginator.get_page(page)
- context = {
- "papers": [], "objects": courses, "msg": "Monitor"
- }
- return my_render_to_response(request, 'yaksh/monitor.html', context)
# quiz_id is not None.
try:
quiz = get_object_or_404(Quiz, id=quiz_id)
@@ -1716,7 +1707,7 @@ def download_quiz_csv(request, course_id, quiz_id):
@login_required
@email_verified
def grade_user(request, quiz_id=None, user_id=None, attempt_number=None,
- course_id=None):
+ course_id=None, extra_context=None):
"""Present an interface with which we can easily grade a user's papers
and update all their marks and also give comments for each paper.
"""
@@ -1775,6 +1766,7 @@ def grade_user(request, quiz_id=None, user_id=None, attempt_number=None,
context = {
"data": data,
"quiz_id": quiz_id,
+ "quiz": quiz,
"users": user_details,
"attempts": attempts,
"user_id": user_id,
@@ -1801,7 +1793,8 @@ def grade_user(request, quiz_id=None, user_id=None, attempt_number=None,
course_id=course.id, user_id=user.id)
if course_status.exists():
course_status.first().set_grade()
-
+ if extra_context:
+ context.update(extra_context)
return my_render_to_response(request, 'yaksh/grade_user.html', context)
@@ -2057,56 +2050,31 @@ def create_demo_course(request):
@login_required
@email_verified
-def grader(request, extra_context=None):
- user = request.user
- if not is_moderator(user):
- raise Http404('You are not allowed to view this page!')
- courses = Course.objects.filter(is_trial=False)
- user_courses = list(courses.filter(creator=user)) + \
- list(courses.filter(teachers=user))
- context = {'courses': user_courses}
- if extra_context:
- context.update(extra_context)
- return my_render_to_response(request, 'yaksh/regrade.html', context)
-
-
-@login_required
-@email_verified
-def regrade(request, course_id, question_id=None, answerpaper_id=None,
- questionpaper_id=None):
+def regrade(request, course_id, questionpaper_id, question_id=None,
+ answerpaper_id=None):
user = request.user
course = get_object_or_404(Course, pk=course_id)
if not is_moderator(user) or (course.is_creator(user) and
course.is_teacher(user)):
raise Http404('You are not allowed to view this page!')
+ questionpaper = get_object_or_404(QuestionPaper, pk=questionpaper_id)
details = []
- if answerpaper_id is not None and question_id is None:
- answerpaper = get_object_or_404(AnswerPaper, pk=answerpaper_id)
- for question in answerpaper.questions.all():
- details.append(answerpaper.regrade(question.id))
- course_status = CourseStatus.objects.filter(
- user=answerpaper.user, course=answerpaper.course)
- if course_status.exists():
- course_status.first().set_grade()
- if questionpaper_id is not None and question_id is not None:
- answerpapers = AnswerPaper.objects.filter(
- questions=question_id,
- question_paper_id=questionpaper_id, course_id=course_id)
- for answerpaper in answerpapers:
- details.append(answerpaper.regrade(question_id))
- course_status = CourseStatus.objects.filter(
- user=answerpaper.user, course=answerpaper.course)
- if course_status.exists():
- course_status.first().set_grade()
- if answerpaper_id is not None and question_id is not None:
- answerpaper = get_object_or_404(AnswerPaper, pk=answerpaper_id)
- details.append(answerpaper.regrade(question_id))
- course_status = CourseStatus.objects.filter(user=answerpaper.user,
- course=answerpaper.course)
- if course_status.exists():
- course_status.first().set_grade()
-
- return grader(request, extra_context={'details': details})
+ quiz = questionpaper.quiz
+ data = {"user_id": user.id, "course_id": course_id,
+ "questionpaper_id": questionpaper_id, "question_id": question_id,
+ "answerpaper_id": answerpaper_id, "quiz_id": quiz.id,
+ "quiz_name": quiz.description, "course_name": course.name
+ }
+ regrade_papers.delay(data)
+ msg = dedent("""
+ {0} is submitted for re-evaluation. You will receive a
+ notification for the re-evaluation status
+ """.format(quiz.description)
+ )
+ messages.info(request, msg)
+ return redirect(
+ reverse("yaksh:grade_user", args=[quiz.id, course_id])
+ )
@login_required
@@ -3191,3 +3159,38 @@ def download_course_progress(request, course_id):
for student in stud_details:
writer.writerow(student)
return response
+
+
+@login_required
+@email_verified
+def view_notifications(request):
+ user = request.user
+ notifcations = Notification.objects.get_unread_receiver_notifications(
+ user.id
+ )
+ if is_moderator(user):
+ template = "manage.html"
+ else:
+ template = "user.html"
+ context = {"template": template, "notifications": notifcations,
+ "current_date_time": timezone.now()}
+ return my_render_to_response(
+ request, 'yaksh/view_notifications.html', context
+ )
+
+
+@login_required
+@email_verified
+def mark_notification(request, message_uid=None):
+ user = request.user
+ if message_uid:
+ Notification.objects.mark_single_notification(
+ user.id, message_uid, True
+ )
+ else:
+ if request.method == 'POST':
+ msg_uuids = request.POST.getlist("uid")
+ Notification.objects.mark_bulk_msg_notifications(
+ user.id, msg_uuids, True)
+ messages.success(request, "Marked notifcation(s) as read")
+ return redirect(reverse("yaksh:view_notifications"))