</div>
<br />
+<form method="GET">
+ <label for="corrector_select">{% trans "Corrector"%}</label>
+ <select name="corrector" id="corrector_select">
+ <option value="">---</option>
+ {% for corrector in correctors_list %}
+ <option value="{{corrector.0}}" {% if corrector.0 == corrector_selected %}selected="selected"{% endif %}>{{corrector.1}}</option>
+ {% endfor %}
+ </select>
+ <label for="course_select">{% trans "Course"%}</label>
+ <select name="course" id="course_select">
+ <option value="">---</option>
+ {% for course in courses_list %}
+ <option value="{{course.0}}" {% if course.0 == course_selected %}selected="selected"{% endif %}>{{course.1}}</option>
+ {% endfor %}
+ </select>
+ <label for="session_select">{% trans "Session"%}</label>
+ <select name="session" id="session_select">
+ <option value="">---</option>
+ {% for session in sessions_list %}
+ <option value="{{session.0}}" {% if session.0 == session_selected %}selected="selected"{% endif %}>{{session.1}}</option>
+ {% endfor %}
+ </select>
+ <input type="submit" value="Filtrer"/>
+</form>
+
<div id="users">
<table class="listing" width="100%">
<thead>
<tr>
<th>{% trans "Corrector"%}</th>
+ <th>{% trans "Period"%}</th>
<th>{% trans "Course"%}</th>
+ <th>{% trans "Session"%}</th>
<th>{% trans "date start"%}</th>
<th>{% trans "date end"%}</th>
<th>{% trans "Pending"%}</th>
<th>{% trans "Marked"%}</th>
<th>{% trans "Value"%}</th>
- <th>{% trans "Level"%} (%)</th>
+ <th>{% trans "Level"%}</th>
</tr>
</thead>
<tbody id="spacing" class="script-list">
{% for quota in object_list %}
<tr>
<td><a href="{% url 'teleforma-profile-detail' quota.corrector.username %}">{{ quota.corrector.username }}</a></td>
+ <td>{{ quota.period.name }}</td>
<td>{{ quota.course.title }}</td>
+ <td>{{ quota.session }}</td>
<td>{{ quota.date_start }}</td>
<td>{{ quota.date_end }}</td>
<td>{{ quota.pending_script_count }}</td>
<td>{{ quota.marked_script_count }}</td>
<td>{{ quota.value }}</td>
- <td>{{ quota.level|floatformat }}</td>
+ <td {% if quota.level > 100 %}style="color:#FF5050"{% endif %}>{{ quota.level|floatformat }}%</td>
</tr>
{% endfor %}
</tbody>
#
# Authors: Guillaume Pellerin <yomguy@parisson.com>
-from teleforma.exam.views import MassScoreCreateView, ScoreCreateView, ScriptCreateView, ScriptView, ScriptsPendingView, ScriptsRejectedView, ScriptsScoreAllView, ScriptsScoreCourseView, ScriptsTreatedView, ScriptsView, get_correctors, get_mass_students
+from teleforma.exam.views import MassScoreCreateView, ScoreCreateView, ScriptCreateView, ScriptView, ScriptsPendingView, ScriptsRejectedView, ScriptsScoreAllView, ScriptsScoreCourseView, ScriptsTreatedView, ScriptsView, get_correctors, get_mass_students, QuotasView
from django.conf.urls import url
url(r'^scripts/get-correctors/$', get_correctors, name="teleforma-exam-get-correctors"),
url(r'^scripts/get-mass-students/$', get_mass_students, name="teleforma-exam-get-mass-students"),
+
+ url(r'^quotas/periods/(?P<period_id>.*)/list/$',
+ QuotasView.as_view(),
+ name="teleforma-exam-quotas"),
+
]
from django.contrib.auth.models import User
from django.db.models import Q
from django.http.response import HttpResponse
-from django.shortcuts import redirect
+from django.shortcuts import get_object_or_404, redirect
from django.urls import reverse_lazy
from django.utils.decorators import method_decorator
from django.utils.translation import ugettext
class QuotasView(ListView):
- model = Quota
template_name = 'exam/quotas.html'
- @method_decorator(access_required)
+ def setup(self, request, *args, **kwargs):
+ super().setup(request, *args, **kwargs)
+ self.professor = self.request.user.professor.get()
+ self.courses = self.professor.courses.all()
+ self.period = get_object_or_404(
+ Period, id=int(self.kwargs['period_id']))
+ self.nb_script = self.period.nb_script or settings.TELEFORMA_EXAM_MAX_SESSIONS
+ self.session = self.request.GET.get('session')
+ self.course = self.request.GET.get('course')
+ self.corrector = self.request.GET.get('corrector')
+
+ def get_base_queryset(self):
+ return Quota.objects.filter(period=self.period, course__in=self.courses)
+
+ def get_queryset(self):
+ query = self.get_base_queryset()
+ if self.session:
+ query = query.filter(session=self.session)
+ if self.course:
+ query = query.filter(course__id=self.course)
+ if self.corrector:
+ query = query.filter(corrector__id=self.corrector)
+ return query.order_by('course', 'session', 'corrector', 'date_start')
+
+ def get_context_data(self, **kwargs):
+ context = super().get_context_data(**kwargs)
+ correctors = User.objects.filter(
+ quotas__in=self.get_base_queryset()).order_by('last_name').distinct()
+ context['correctors_list'] = [
+ (str(corrector.id), corrector.get_full_name()) for corrector in correctors]
+ context['corrector_selected'] = self.corrector
+ session_choices = get_n_choices(self.nb_script + 1)
+ context['sessions_list'] = session_choices
+ context['session_selected'] = self.session
+ context['courses_list'] = [
+ (str(course.id), course.title) for course in self.courses]
+ context['course_selected'] = self.course
+ return context
+
+ @staff_required
def dispatch(self, *args, **kwargs):
- return super(QuotasView, self).dispatch(*args, **kwargs)
+ return super().dispatch(*args, **kwargs)
class ScriptsScoreAllView(ScriptsTreatedView):
</li>
{% endif %}
{% endif %}
+
+ {% if user.professor.count %}
+ <li><a href="#quotas#" class="green"> {% trans "Quotas" %}</a>
+ <ul>
+ {% for period in periods %}
+ <li><a href="{% url 'teleforma-exam-quotas' period.id %}" class="green">{{ period.name }}</a>
+ </li>
+ {% endfor %}
+ </ul>
+ </li>
+ {% endif %}
{% if user.professor.count or user.is_superuser %}
<li><a href="{% url 'teleforma-webclass-professor' %}" class="yellow">Webclass</a></li>
{% endif %}
+
+
{% if periods|length == 1 %}
<li><a href="{% url 'teleforma-exam-scripts-scores-all' periods.0.id %}"
class="green"> {% trans "Scores" %}</a></li>