Skip to content

Commit

Permalink
Display personal deadline extensions on a student’s points page
Browse files Browse the repository at this point in the history
  • Loading branch information
Mikael-Lenander committed Jul 18, 2023
1 parent 041919f commit 53c24d5
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 2 deletions.
16 changes: 16 additions & 0 deletions course/templatetags/course.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from typing import Any, Dict, List, Union
from copy import copy

from django import template
from django.db import models
Expand All @@ -22,6 +23,10 @@ def _prepare_topmenu(context):
return context['topmenu']


def _deadline_extended_exercise_open(entry, now):
personal_deadline = entry.get('personal_deadline')
return personal_deadline is not None and entry['opening_time'] <= now <= personal_deadline

@register.inclusion_tag("course/_course_dropdown_menu.html", takes_context=True)
def course_menu(context):
menu = _prepare_topmenu(context)
Expand Down Expand Up @@ -87,6 +92,17 @@ def exercises_open(entry, now):
return entry['opening_time'] <= now <= entry['closing_time']


@register.filter
def deadline_extended_exercise_open(entry, now):
return _deadline_extended_exercise_open(entry, now)


@register.filter
def deadline_extended_exercises_open(entry, now):
entries = copy(entry['flatted'])
return any(_deadline_extended_exercise_open(entry, now) for entry in entries)


@register.filter
def exercises_submittable(entry, now):
if entry['late_allowed']:
Expand Down
13 changes: 13 additions & 0 deletions exercise/templates/exercise/_user_results.html
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,11 @@ <h3 class="panel-title">
{% translate "OPEN_FOR_READING" %}
</span>
{% endif %}
{% if module|deadline_extended_exercises_open:now %}
<span class="badge pull-right">
{% translate "SOME_EXERCISES_WITH_EXTENDED_DEADLINES" %}
</span>
{% endif %}
{% if module.requirements|length > 0 %}
<span class="badge pull-right">
{% translate "REQUIRES" %}:
Expand Down Expand Up @@ -113,6 +118,14 @@ <h3 class="panel-title">
<td>
{% if exercise_accessible or is_course_staff %}
<a href="{{ entry.link }}" class="{% if entry|is_in_maintenance %}maintenance{% endif %}">{{ entry.name|parse_localization }}</a>
{% if entry|deadline_extended_exercise_open:now %}
<span
data-toggle="tooltip"
title="{% translate 'EXTENDED_DEADLINE' %} {{ entry.personal_deadline }}"
>
<span class="glyphicon glyphicon-time"></span>
</span>
{% endif %}
{% else %}
{{ entry.name|parse_localization }}
{% endif %}
Expand Down
7 changes: 6 additions & 1 deletion locale/en/LC_MESSAGES/django.po
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2023-06-14 14:12+0300\n"
"POT-Creation-Date: 2023-07-18 16:43+0300\n"
"PO-Revision-Date: 2021-05-27 14:47+0300\n"
"Last-Translator: Jimmy Ihalainen <[email protected]>\n"
"Language-Team: English<>\n"
Expand Down Expand Up @@ -3824,6 +3824,7 @@ msgid "POINTS_REQUIRED_TO_PASS"
msgstr "Points required to pass"

#: exercise/templates/exercise/_exercise_info.html
#: exercise/templates/exercise/_user_results.html
#: exercise/templates/exercise/exercise_plain.html
msgid "EXTENDED_DEADLINE"
msgstr "Extended deadline"
Expand Down Expand Up @@ -4026,6 +4027,10 @@ msgstr "Exercises open on"
msgid "OPEN_FOR_READING"
msgstr "Open for reading"

#: exercise/templates/exercise/_user_results.html
msgid "SOME_EXERCISES_WITH_EXTENDED_DEADLINES"
msgstr "Some assignments have extended deadlines"

#: exercise/templates/exercise/_user_results.html
#: exercise/templates/exercise/_user_toc.html
#: lti_tool/templates/lti_tool/lti_course.html
Expand Down
7 changes: 6 additions & 1 deletion locale/fi/LC_MESSAGES/django.po
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ msgid ""
msgstr ""
"Project-Id-Version: \n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2023-06-14 14:12+0300\n"
"POT-Creation-Date: 2023-07-18 16:43+0300\n"
"PO-Revision-Date: 2019-08-14 12:16+0200\n"
"Last-Translator: Jimmy Ihalainen <[email protected]>\n"
"Language-Team: Finnish <>\n"
Expand Down Expand Up @@ -3831,6 +3831,7 @@ msgid "POINTS_REQUIRED_TO_PASS"
msgstr "Pistevaatimus"

#: exercise/templates/exercise/_exercise_info.html
#: exercise/templates/exercise/_user_results.html
#: exercise/templates/exercise/exercise_plain.html
msgid "EXTENDED_DEADLINE"
msgstr "Pidennetty määräaika"
Expand Down Expand Up @@ -4036,6 +4037,10 @@ msgstr "Tehtävät avautuvat"
msgid "OPEN_FOR_READING"
msgstr "Lukumateriaali avoinna"

#: exercise/templates/exercise/_user_results.html
msgid "SOME_EXERCISES_WITH_EXTENDED_DEADLINES"
msgstr "Joillain tehtävillä pidennetty määräaika"

#: exercise/templates/exercise/_user_results.html
#: exercise/templates/exercise/_user_toc.html
#: lti_tool/templates/lti_tool/lti_course.html
Expand Down

0 comments on commit 53c24d5

Please sign in to comment.