Skip to content

Commit

Permalink
Add submissions info to monitoring page
Browse files Browse the repository at this point in the history
* Number of submission of every kind
  • Loading branch information
Mateusz Jacniacki committed Apr 7, 2024
1 parent 6077a74 commit 979449f
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 3 deletions.
22 changes: 22 additions & 0 deletions oioioi/statistics/templates/statistics/_submissions_info.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{% load i18n pagination_tags %}
{% if rounds_times %}
<div class="table-responsive-md">
<h4> {% trans "Submission types" %} </h4>
<table class="table table-sm table-bordered">
<thead>
<tr>
<th> {% trans "Kind" %} </th>
<th> {% trans "Count" %} </th>
</tr>
</thead>
<tbody>
{% for submission_info in submissions_info %}
<tr>
<td>{{ submission_info.kind }}</td>
<td>{{ submission_info.total }}</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
{% endif %}
3 changes: 3 additions & 0 deletions oioioi/statistics/templates/statistics/monitoring.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@
<div class="col col-sm">
{% include "statistics/_general_info.html" %}
</div>
<div class="col col-sm">
{% include "statistics/_submissions_info.html" %}
</div>
<div class="col col-sm">
{% include "statistics/_attachments_info.html" %}
</div>
Expand Down
12 changes: 9 additions & 3 deletions oioioi/statistics/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
from pprint import pprint

from django.core.exceptions import PermissionDenied
from django.db.models import Count
from django.http import Http404
from django.template.response import TemplateResponse
from django.urls import reverse
Expand All @@ -11,7 +12,8 @@
from oioioi.base.menu import menu_registry
from oioioi.base.permissions import enforce_condition
from oioioi.contests.menu import contest_admin_menu_registry
from oioioi.contests.models import ProblemInstance, ContestPermission, contest_permissions, ContestAttachment
from oioioi.contests.models import ProblemInstance, ContestPermission, contest_permissions, ContestAttachment, \
Submission
from oioioi.contests.utils import (
can_enter_contest,
contest_exists,
Expand Down Expand Up @@ -169,14 +171,17 @@ def monitoring_view(request):

attachments = ContestAttachment.objects.filter(contest_id=request.contest.id).order_by('id')
for attachment in attachments:
print(attachment.pub_date, cur_time)
pub_date_relative = str(attachment.pub_date - cur_time)[:-7] if attachment.pub_date > cur_time else _("Published")
pub_date_relative = None
if attachment.pub_date:
pub_date_relative = str(attachment.pub_date - cur_time)[:-7] if attachment.pub_date > cur_time else _("Published")
setattr(attachment, 'pub_date_relative', pub_date_relative)
unanswered_questions = (Message.objects.filter(kind='QUESTION', message=None, contest=request.contest).count())
oldest_unanswered_question = (Message.objects.filter(kind='QUESTION', message=None, contest=request.contest)
.order_by('pub_date').first())
oldest_unanswered_question_date = oldest_unanswered_question.date if oldest_unanswered_question else None

submissions_info = Submission.objects.filter(problem_instance__contest=request.contest).values('kind').annotate(total=Count('kind')).order_by()

return TemplateResponse(
request,
'statistics/monitoring.html',
Expand All @@ -190,5 +195,6 @@ def monitoring_view(request):
'attachments': attachments,
'unanswered_questions': unanswered_questions,
'oldest_unanswered_question': oldest_unanswered_question_date,
'submissions_info': submissions_info
},
)

0 comments on commit 979449f

Please sign in to comment.