Add allow_late_submissions toggle to assignments

This commit is contained in:
Dmitry Belan
2026-09-28 21:18:34 +03:00
parent bc2866280b
commit ece2e51b04
4 changed files with 15 additions and 6 deletions
+2 -2
View File
@@ -18,9 +18,9 @@ class QuestionInline(StackedInline):
@admin.register(Assignment)
class AssignmentAdmin(ModelAdmin):
list_display = ('title', 'subject', 'is_published', 'time_limit', 'deadline', 'created_at')
list_display = ('title', 'subject', 'is_published', 'time_limit', 'deadline', 'allow_late_submissions', 'created_at')
list_display_links = ('title',)
list_filter = ('subject', 'is_published')
list_filter = ('subject', 'is_published', 'allow_late_submissions')
search_fields = ('title', 'description')
exclude = ('created_by',)
filter_horizontal = ('assigned_students',)
+1
View File
@@ -24,6 +24,7 @@ class Assignment(models.Model):
created_at = models.DateTimeField('Дата создания', auto_now_add=True)
deadline = models.DateTimeField('Дедлайн', blank=True, null=True, help_text='После этого времени ответы не принимаются.')
time_limit = models.PositiveIntegerField('Лимит времени (минуты)', blank=True, null=True, help_text='Например, 235 для 3ч 55м. Оставьте пустым, если без таймера.')
allow_late_submissions = models.BooleanField('Разрешить дорешивание', default=True, help_text='Если включено, ученики смогут сдавать задание после дедлайна с пометкой "После дедлайна".')
class Meta:
verbose_name = 'Задание'
+10 -3
View File
@@ -47,9 +47,16 @@
{% endif %}
{% else %}
{% if assignment.deadline and now > assignment.deadline %}
<span class="inline-flex items-center gap-1.5 px-2 py-0.5 rounded text-xs font-mono font-medium bg-obsidian-borderLight/20 text-txt-muted border border-obsidian-borderLight/50">
Дедлайн прошел
</span>
{% if assignment.allow_late_submissions %}
<span class="inline-flex items-center gap-1.5 px-2 py-0.5 rounded text-xs font-mono font-medium bg-obsidian-borderLight/20 text-txt-muted border border-obsidian-borderLight/50">
Дедлайн прошел
</span>
{% else %}
<span class="inline-flex items-center gap-1.5 px-2 py-0.5 rounded text-xs font-mono font-medium bg-rose-950/40 text-rose-400 border border-rose-800/50">
<span class="w-1.5 h-1.5 rounded-full bg-rose-400"></span>
Прием закрыт
</span>
{% endif %}
{% else %}
<span class="inline-flex items-center gap-1.5 px-2 py-0.5 rounded text-xs font-mono font-medium bg-status-roseBg text-status-rose border border-status-rose/30">
<span class="w-1.5 h-1.5 rounded-full bg-status-rose"></span>
+2 -1
View File
@@ -72,7 +72,8 @@ def assignment_detail(request, pk):
if assignment.deadline and now > assignment.deadline:
is_late = True
# can_submit = False # Allow late submissions
if not assignment.allow_late_submissions:
can_submit = False
if assignment.time_limit:
if not submission: