Skip to content

Commit

Permalink
Add assessed submitters ratio to submissions table
Browse files Browse the repository at this point in the history
Add counter of manually assessed submitters, showing the number of
submitters that have been assessed, remaining, and the percentage.

Fixes #1109
  • Loading branch information
EerikSaksi authored and ihalaij1 committed May 7, 2024
1 parent 59606cf commit 747de51
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 4 deletions.
33 changes: 30 additions & 3 deletions exercise/staff_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,13 +75,31 @@ def get_common_objects(self) -> None:
Prefetch('submitters', UserProfile.objects.prefetch_tags(self.instance)),
)
)

submitters = (
UserProfile.objects
.filter(submissions__exercise=self.exercise)
.annotate(
count_assessed=Count(
'submissions__id',
filter=(Q(submissions__grader__isnull=False)),
),
)
)

total_submitters = submitters.count()
graded_submitters = submitters.filter(count_assessed__gt=0).count()

for submission in qs:
format_submission(submission, self.pseudonymize)
self.all = self.request.GET.get('all', None)
self.all_url = self.exercise.get_submission_list_url() + "?all=yes"
self.submissions = qs if self.all else qs[:self.default_limit]
self.count = len(self.submissions)
self.note("all", "all_url", "submissions", "default_limit", "count")
self.percentage_graded = (
f"{graded_submitters} / {total_submitters} ({int(graded_submitters / total_submitters * 100)}%)"
)
self.note("all", "all_url", "submissions", "default_limit", "count", "percentage_graded")


class SubmissionsSummaryView(ExerciseBaseView):
Expand Down Expand Up @@ -353,6 +371,7 @@ def get(self, request: HttpRequest, *args: Any, **kwargs: Any) -> HttpResponse:
earliest_submission=Min('submissions__submission_time'),
)
.order_by('earliest_submission'))
total_submitters = submitters.count()
previous_user_id = request.GET.get('prev')
if previous_user_id:
# get the previous time
Expand All @@ -363,13 +382,17 @@ def get(self, request: HttpRequest, *args: Any, **kwargs: Any) -> HttpResponse:
submitters = submitters.filter(count_assessed=0)

# Find specifically the submitter who's submission was submitted right after this one
submitters_after = submitters.filter(earliest_submission__gt=previous_time)
submitter = submitters_after.first()
submitters = submitters.filter(earliest_submission__gt=previous_time)
submitter = submitters.first()

if not submitter:
submitters = submitters.filter(count_assessed=0)
submitter = submitters.first()

# the number of submitters that we have after filtering
submitters_after = submitters.count()
filtered_submitters = total_submitters - submitters_after + 1

if not submitter:
# There are no more unassessed submitters.
messages.success(request, _('ALL_SUBMITTERS_HAVE_BEEN_ASSESSED'))
Expand All @@ -380,6 +403,10 @@ def get(self, request: HttpRequest, *args: Any, **kwargs: Any) -> HttpResponse:
ids = cache.submission_ids(exercise_id=self.exercise.id, best=True, fallback_to_last=True)
if not ids:
raise Http404()
percentage = f"{int(filtered_submitters / total_submitters * 100)}%"
self.request.session['manually_assessed_counter'] = (
f"{filtered_submitters} / {total_submitters} ({percentage})"
)
url = reverse(
'submission-inspect',
kwargs={'submission_id': ids[0], **kwargs},
Expand Down
2 changes: 1 addition & 1 deletion exercise/templates/exercise/staff/_submissions_table.html
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
<table class="table table-bordered{% if all or count < default_limit %} filtered-table ordered-table{% endif %}">
<thead>
<tr>
<th>{% translate "SUBMITTERS" %}</th>
<th>{% translate "SUBMITTERS" %} {{percentage_graded}} {% translate "GRADED" %}</th>
<th>{% translate "TIME" %}</th>
<th>{% translate "STATUS" %}</th>
<th>{% translate "GRADE" %}</th>
Expand Down
1 change: 1 addition & 0 deletions exercise/templates/exercise/staff/inspect_submission.html
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@
{% with prev_id=submission.submitters.all.0.id %}
<a href="{{ exercise|url:'submission-next-unassessed' }}?prev={{ prev_id }}" class="pull-right">
{% translate "ASSESS_NEXT_SUBMITTER_MANUALLY" %}
{{ request.session.manually_assessed_counter }}
<span aria-hidden="true">&raquo;</span>
</a>
{% endwith %}
Expand Down
4 changes: 4 additions & 0 deletions locale/en/LC_MESSAGES/django.po
Original file line number Diff line number Diff line change
Expand Up @@ -5905,3 +5905,7 @@ msgstr "No system-wide accessibility statement found."
#: userprofile/views.py
msgid "NO_SUPPORT_PAGE"
msgstr "No support page. Please notify administration!"

#: exercise/templates/exercise/staff/_submissions_table.html
msgid "GRADED"
msgstr "graded"
4 changes: 4 additions & 0 deletions locale/fi/LC_MESSAGES/django.po
Original file line number Diff line number Diff line change
Expand Up @@ -5932,3 +5932,7 @@ msgstr "Järjestelmätason saavutettavuusselostetta ei löytynyt."
#: userprofile/views.py
msgid "NO_SUPPORT_PAGE"
msgstr "Ei tukisivua. Ota yhteys ylläpitäjään!"

#: exercise/templates/exercise/staff/_submissions_table.html
msgid "GRADED"
msgstr "arvosteltu"

0 comments on commit 747de51

Please sign in to comment.