Skip to content

Commit

Permalink
Improve unofficial submission points badge tooltip
Browse files Browse the repository at this point in the history
  • Loading branch information
ihalaij1 authored and murhum1 committed Feb 23, 2024
1 parent 1b1f97f commit b31e686
Show file tree
Hide file tree
Showing 9 changed files with 82 additions and 11 deletions.
1 change: 1 addition & 0 deletions exercise/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,7 @@ class SubmissionAdmin(admin.ModelAdmin):
course_wrapper,
submitters_wrapper,
'status',
'unofficial_submission_type',
'grade',
'submission_time',
)
Expand Down
4 changes: 4 additions & 0 deletions exercise/cache/points.py
Original file line number Diff line number Diff line change
Expand Up @@ -360,6 +360,7 @@ class SubmissionEntryBase(SubmissionProto, EqById):
graded: bool
status: str
unofficial: bool
unofficial_submission_type: Optional[str]
date: datetime.datetime
url: str
hash: Optional[str]
Expand Down Expand Up @@ -586,6 +587,7 @@ class ExercisePoints(LearningObjectPoints):
_best_submission: Optional[SubmissionEntry]
graded: bool
unofficial: bool
unofficial_submission_type: Optional[str]
forced_points: bool
notified: bool
unseen: bool
Expand Down Expand Up @@ -684,6 +686,7 @@ def _generate_data( # noqa: MC0001
self.graded = False
self.unofficial = False # TODO: this should be True,
# but we need to ensure nothing breaks when it's changed
self.unofficial_submission_type = None
self.forced_points = False
self.notified = False
self.unseen = False
Expand Down Expand Up @@ -735,6 +738,7 @@ def _generate_data( # noqa: MC0001
graded = submission.is_graded,
status = submission.status,
unofficial = unofficial,
unofficial_submission_type = submission.unofficial_submission_type,
date = submission.submission_time,
url = submission.get_url('submission-plain'),
feedback_revealed = True,
Expand Down
18 changes: 18 additions & 0 deletions exercise/migrations/0049_submission_unofficial_submission_type.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Generated by Django 4.2.4 on 2024-02-06 14:29

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('exercise', '0048_alter_revealrule_trigger'),
]

operations = [
migrations.AddField(
model_name='submission',
name='unofficial_submission_type',
field=models.CharField(blank=True, choices=[('deadline_passed', 'DEADLINE_PASSED'), ('limit_exceeded', 'LIMIT_EXCEEDED')], default=None, max_length=64, null=True, verbose_name='LABEL_UNOFFICIAL_SUBMISSION_TYPE'),
),
]
13 changes: 13 additions & 0 deletions exercise/submission_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -364,6 +364,10 @@ class Submission(SubmissionProto, models.Model):
('UNOFFICIAL', 'unofficial', _('STATUS_UNOFFICIAL')),
# unofficial: graded after the deadline or after exceeding the submission limit
])
UNOFFICAL_SUBMISSION_TYPE = Enum([
('DEADLINE_PASSED', 'deadline_passed', _('DEADLINE_PASSED')),
('LIMIT_EXCEEDED', 'limit_exceeded', _('LIMIT_EXCEEDED'))
])
submission_time = models.DateTimeField(
verbose_name=_('LABEL_SUBMISSION_TIME'),
auto_now_add=True,
Expand Down Expand Up @@ -403,6 +407,13 @@ class Submission(SubmissionProto, models.Model):
max_length=32,
choices=STATUS.choices, default=STATUS.INITIALIZED,
)
unofficial_submission_type = models.CharField(
verbose_name=_('LABEL_UNOFFICIAL_SUBMISSION_TYPE'),
max_length=64,
choices=UNOFFICAL_SUBMISSION_TYPE.choices,
default=None,
blank=True, null=True,
)
grade = models.IntegerField(
verbose_name=_('LABEL_GRADE'),
default=0,
Expand Down Expand Up @@ -606,8 +617,10 @@ def set_points(self, points, max_points, no_penalties=False):
adjusted_grade -= (adjusted_grade * self.late_penalty_applied)
elif timing == exercise.TIMING.UNOFFICIAL:
self.status = self.STATUS.UNOFFICIAL
self.unofficial_submission_type = self.UNOFFICAL_SUBMISSION_TYPE.DEADLINE_PASSED
if self.exercise.no_submissions_left(self.submitters.all()):
self.status = self.STATUS.UNOFFICIAL
self.unofficial_submission_type = self.UNOFFICAL_SUBMISSION_TYPE.LIMIT_EXCEEDED

self.grade = round(adjusted_grade)

Expand Down
10 changes: 8 additions & 2 deletions exercise/templates/exercise/_points_badge.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,13 @@
{% if submitted %}
<span class="badge{% if graded and official %} badge-{% if full_score %}success{% elif passed %}warning{% else %}danger{% endif %}{% endif %} {{ classes }}">
{% if not official %}
{% translate "UNOFFICIAL_DESCRIPTION" %}
{% if unofficial_submission_type == 'limit_exceeded' %}
{% translate "LIMIT_EXCEEDED" %}
{% elif unofficial_submission_type == 'deadline_passed' %}
{% translate "DEADLINE_PASSED" %}
{% else %}
{% translate "UNOFFICIAL_DESCRIPTION" %}
{% endif %}
{% elif passed %}
{% translate "ACCEPTED" %}
{% elif graded %}
Expand All @@ -34,7 +40,7 @@
{% endif %}
<span class="badge{% if submitted and official %} {% if feedback_revealed %}{% if full_score %}badge-success{% elif passed %}badge-warning{% else %}badge-danger{% endif %}{% endif %}{% if unconfirmed %} unconfirmed-points{% endif %}{% endif %}{% if classes %} {{ classes }}{% endif %}"
data-toggle="tooltip" data-placement="bottom"
title="{% if not feedback_revealed %}{{ feedback_hidden_description }}{% elif not official %}{% translate 'UNOFFICIAL_DESCRIPTION' %}{% elif passed %}{% if required > 0 %}{% translate 'PASSED' %}{% endif %}{% elif missing_points %}{% blocktranslate trimmed with points=required %}POINTS_REQUIRED_TO_PASS -- {{ points }}{% endblocktranslate %}{% elif submitted %}{% translate 'REQUIRED_EXERCISES_NOT_PASSED' %}{% endif %}">
title="{% if not feedback_revealed %}{{ feedback_hidden_description }}{% elif not official %}{% if unofficial_submission_type == 'limit_exceeded' %}{% translate 'LIMIT_EXCEEDED' %}{% elif unofficial_submission_type == 'deadline_passed' %}{% translate 'DEADLINE_PASSED' %}{% else %}{% translate 'UNOFFICIAL_DESCRIPTION' %}{% endif %}{% elif passed %}{% if required > 0 %}{% translate 'PASSED' %}{% endif %}{% elif missing_points %}{% blocktranslate trimmed with points=required %}POINTS_REQUIRED_TO_PASS -- {{ points }}{% endblocktranslate %}{% elif submitted %}{% translate 'REQUIRED_EXERCISES_NOT_PASSED' %}{% endif %}">
{{ formatted_points }} / {{ max }}
</span>
{% endif %}
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
class="badge{% if not s.unofficial %} {% if s.points >= exercise.max_points %}badge-success{% elif s.points >= exercise.points_to_pass %}badge-warning{% else %}badge-danger{% endif %}{% endif %}"
data-toggle="tooltip"
data-placement="bottom"
title="{% if s.unofficial %}{% translate 'UNOFFICIAL_DESCRIPTION' %}{% elif s.points >= exercise.points_to_pass %}{% if exercise.points_to_pass > 0 %}{% translate 'PASSED' %}{% endif %}{% else %}{% blocktranslate trimmed with points=exercise.points_to_pass %}POINTS_REQUIRED_TO_PASS -- {{ points }}{% endblocktranslate %}{% endif %}"
title="{% if s.unofficial %}{% if s.unofficial_submission_type == 'limit_exceeded' %}{% translate 'LIMIT_EXCEEDED' %}{% elif s.unofficial_submission_type == 'deadline_passed' %}{% translate 'DEADLINE_PASSED' %}{% else %}{% translate 'UNOFFICIAL_DESCRIPTION' %}{% endif %}{% elif s.points >= exercise.points_to_pass %}{% if exercise.points_to_pass > 0 %}{% translate 'PASSED' %}{% endif %}{% else %}{% blocktranslate trimmed with points=exercise.points_to_pass %}POINTS_REQUIRED_TO_PASS -- {{ points }}{% endblocktranslate %}{% endif %}"
>
{{ s.points }} / {{ exercise.max_points }}
</span>
Expand Down
1 change: 1 addition & 0 deletions exercise/templatetags/exercise.py
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,7 @@ def _points_data(
'graded': getattr(obj, 'graded', True),
'unconfirmed': getattr(obj, 'unconfirmed', False),
'official': not getattr(obj, 'unofficial', False),
'unofficial_submission_type': getattr(obj, 'unofficial_submission_type', None),
'confirmable_points': getattr(obj, 'confirmable_points', False),
'feedback_revealed': getattr(obj, 'feedback_revealed', True),
}
Expand Down
22 changes: 18 additions & 4 deletions locale/en/LC_MESSAGES/django.po
Original file line number Diff line number Diff line change
Expand Up @@ -2030,6 +2030,10 @@ msgstr "Students will not be able to see model answers after this time."
msgid "COURSE_REMOVES_SUBMISSION_POSSIBILITY_STUDENTS"
msgstr "Students will not be able to submit answers after this time."

#: edit_course/course_forms.py
msgid "ERROR_URL_ALREADY_TAKEN"
msgstr "The URL is already taken."

#: edit_course/course_forms.py
msgid "COURSE_NEW_URL_IDENTIFIER_COURSE_INSTANCE"
msgstr "New URL identifier for the course instance"
Expand Down Expand Up @@ -2209,10 +2213,6 @@ msgstr ""
"option only applies if you first select a course instance from the dropdown "
"above."

#: edit_course/course_forms.py
msgid "ERROR_URL_ALREADY_TAKEN"
msgstr "The URL is already taken."

#: edit_course/course_forms.py
msgid "LABEL_SLUG"
msgstr "Slug"
Expand Down Expand Up @@ -3722,6 +3722,16 @@ msgstr "Rejected"
msgid "STATUS_UNOFFICIAL"
msgstr "No effect on grading"

#: exercise/submission_models.py exercise/templates/exercise/_points_badge.html
#: exercise/templates/exercise/staff/_submissions_table_compact.html
msgid "DEADLINE_PASSED"
msgstr "Submitted after deadline"

#: exercise/submission_models.py exercise/templates/exercise/_points_badge.html
#: exercise/templates/exercise/staff/_submissions_table_compact.html
msgid "LIMIT_EXCEEDED"
msgstr "Submission limit exceeded"

#: exercise/submission_models.py
msgid "LABEL_HASH"
msgstr "hash"
Expand All @@ -3734,6 +3744,10 @@ msgstr "grader"
msgid "LABEL_FEEDBACK"
msgstr "Feedback"

#: exercise/submission_models.py
msgid "LABEL_UNOFFICIAL_SUBMISSION_TYPE"
msgstr "Unofficial submission type"

#: exercise/submission_models.py
#: exercise/templates/exercise/staff/_submission_data_modal.html
msgid "LABEL_GRADING_TIME"
Expand Down
22 changes: 18 additions & 4 deletions locale/fi/LC_MESSAGES/django.po
Original file line number Diff line number Diff line change
Expand Up @@ -2043,6 +2043,10 @@ msgstr "Tämän jälkeen opiskelijat eivät näe esimerkkiratkaisuja."
msgid "COURSE_REMOVES_SUBMISSION_POSSIBILITY_STUDENTS"
msgstr "Arkistoinnin jälkeen tehtävien palauttaminen ei ole enää mahdollista."

#: edit_course/course_forms.py
msgid "ERROR_URL_ALREADY_TAKEN"
msgstr "URL on jo käytössä."

#: edit_course/course_forms.py
msgid "COURSE_NEW_URL_IDENTIFIER_COURSE_INSTANCE"
msgstr "Uusi URL-osoitteessa käytettävä tunniste kurssikerralle"
Expand Down Expand Up @@ -2223,10 +2227,6 @@ msgstr ""
"opintotietojärjestelmän kautta. Tätä valintaa sovelletaan vain, jos valitset "
"ensin yllä olevasta valikosta kurssikerran."

#: edit_course/course_forms.py
msgid "ERROR_URL_ALREADY_TAKEN"
msgstr "URL on jo käytössä."

#: edit_course/course_forms.py
msgid "LABEL_SLUG"
msgstr "Tunniste"
Expand Down Expand Up @@ -3731,6 +3731,16 @@ msgstr "Hylätty"
msgid "STATUS_UNOFFICIAL"
msgstr "Ei vaikuta arvosteluun"

#: exercise/submission_models.py exercise/templates/exercise/_points_badge.html
#: exercise/templates/exercise/staff/_submissions_table_compact.html
msgid "DEADLINE_PASSED"
msgstr "Palautettu määräajan jälkeen"

#: exercise/submission_models.py exercise/templates/exercise/_points_badge.html
#: exercise/templates/exercise/staff/_submissions_table_compact.html
msgid "LIMIT_EXCEEDED"
msgstr "Palautuskertojen enimmäismäärä ylitetty"

#: exercise/submission_models.py
msgid "LABEL_HASH"
msgstr "tunniste (hash)"
Expand All @@ -3743,6 +3753,10 @@ msgstr "arvostelija"
msgid "LABEL_FEEDBACK"
msgstr "Palaute"

#: exercise/submission_models.py
msgid "LABEL_UNOFFICIAL_SUBMISSION_TYPE"
msgstr "Epävirallisen palautuksen tyyppi"

#: exercise/submission_models.py
#: exercise/templates/exercise/staff/_submission_data_modal.html
msgid "LABEL_GRADING_TIME"
Expand Down

0 comments on commit b31e686

Please sign in to comment.