File tree Expand file tree Collapse file tree
exercise/templates/exercise Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -87,6 +87,33 @@ def deadline_extended_exercises_open(entry):
8787 )
8888
8989
90+ # List exercises in a module by deadline extension, to display in tooltip details
91+ @register .filter
92+ def deadline_extended_exercises_by_deadline (entry ):
93+ deadlines_map = {}
94+ for e in entry .flatted :
95+ if isinstance (e , ExercisePoints ) and e .personal_deadline is not None :
96+ if e .personal_deadline not in deadlines_map :
97+ deadlines_map [e .personal_deadline ] = []
98+ deadlines_map [e .personal_deadline ].append (e )
99+ return list (deadlines_map .items ())
100+
101+
102+ # Get the personal deadline if all exercises in a module have the same personal deadline
103+ @register .filter
104+ def deadline_extended_exercises_same_deadline (entry ):
105+ deadlines = [
106+ e .personal_deadline
107+ for e in entry .flatted
108+ if isinstance (e , ExercisePoints )
109+ ]
110+ if not deadlines :
111+ return None
112+ if len (set (deadlines )) == 1 :
113+ return deadlines [0 ]
114+ return None
115+
116+
90117@register .filter
91118def exercises_submittable (entry , now ):
92119 if entry .late_allowed :
Original file line number Diff line number Diff line change 5959 </ span >
6060 {% endif %}
6161 {% if module|deadline_extended_exercises_open %}
62- < span class ="badge text-primary bg-white float-end text-wrap ">
63- {% translate "ASSIGNMENTS_WITH_PERSONAL_DEADLINE_DEVIATION" %}
64- </ span >
62+ <!-- If all exercises of a module have the same deadline, display it directly.
63+ Otherwise display a generic message that has a tooltip with details -->
64+ {% if module|deadline_extended_exercises_same_deadline %}
65+ < span class ="badge text-primary bg-white float-end text-wrap ">
66+ {% translate "PERSONAL_EXTENDED_DEADLINE" %} {{ module|deadline_extended_exercises_same_deadline }}
67+ </ span >
68+ {% else %}
69+ < span class ="badge text-primary bg-white float-end text-wrap " data-bs-toggle ="tooltip " data-bs-html ="true " title ="
70+ {% for deadline, exercises in module|deadline_extended_exercises_by_deadline %}
71+ {{ deadline }}:<br/>
72+ {% for exercise in exercises %}
73+ {{ exercise.name|parse_localization }}{% if not forloop.last %}<br/>{% endif %}
74+ {% endfor %}
75+ {% if not forloop.last %}<hr/>{% endif %}
76+ {% endfor %} "
77+ >
78+ {% translate "ASSIGNMENTS_WITH_PERSONAL_DEADLINE_DEVIATION" %}
79+ </ span >
80+ {% endif %}
81+
6582 {% endif %}
6683 {% if not accessible %}
6784 < span class ="badge text-primary bg-white float-end text-wrap ">
Original file line number Diff line number Diff line change 1212 < h3 >
1313 < a href ="{{ module.link }} " class ="{% if module.is_in_maintenance %}maintenance{% endif %} "> {{ module.name|parse_localization }}</ a >
1414 {% if module|deadline_extended_exercises_open %}
15- < span class ="badge text-bg-secondary ">
16- {% translate "ASSIGNMENTS_WITH_PERSONAL_DEADLINE_DEVIATION" %}
17- </ span >
15+ <!-- If all exercises of a module have the same deadline, display it directly.
16+ Otherwise display a generic message that has a tooltip with details -->
17+ {% if module|deadline_extended_exercises_same_deadline %}
18+ < span class ="badge text-bg-secondary ">
19+ {% translate "PERSONAL_EXTENDED_DEADLINE" %} {{ module|deadline_extended_exercises_same_deadline }}
20+ </ span >
21+ {% else %}
22+ < span class ="badge text-bg-secondary " data-bs-toggle ="tooltip " data-bs-html ="true " title ="
23+ {% for deadline, exercises in module|deadline_extended_exercises_by_deadline %}
24+ {{ deadline }}:<br/>
25+ {% for exercise in exercises %}
26+ {{ exercise.name|parse_localization }}{% if not forloop.last %}<br/>{% endif %}
27+ {% endfor %}
28+ {% if not forloop.last %}<hr/>{% endif %}
29+ {% endfor %}
30+ ">
31+ {% translate "ASSIGNMENTS_WITH_PERSONAL_DEADLINE_DEVIATION" %}
32+ </ span >
33+ {% endif %}
1834 {% endif %}
1935 </ h3 >
2036 < h4 >
You can’t perform that action at this time.
0 commit comments