From ad7aeee1e05d6124d0f0218de13c1f614959ca4d Mon Sep 17 00:00:00 2001 From: Michal Stanik Date: Tue, 21 Feb 2023 18:11:54 +0100 Subject: [PATCH 1/4] notify users if they have submitted a text answer but sent no description --- trojsten/contests/helpers.py | 15 ++++ .../trojsten/contests/parts/task_list.html | 7 ++ .../contests/view_task_statement.html | 6 ++ .../contests/templatetags/statements_parts.py | 4 +- trojsten/contests/tests.py | 83 +++++++++++++++++++ trojsten/contests/views.py | 4 + trojsten/locale/sk/LC_MESSAGES/django.po | 3 + 7 files changed, 121 insertions(+), 1 deletion(-) diff --git a/trojsten/contests/helpers.py b/trojsten/contests/helpers.py index fce140948..534e97500 100644 --- a/trojsten/contests/helpers.py +++ b/trojsten/contests/helpers.py @@ -3,6 +3,8 @@ from trojsten.contests.models import Round from trojsten.results.helpers import UserResult from trojsten.results.manager import get_results_tags_for_rounds +from trojsten.submit.constants import SUBMIT_TYPE_DESCRIPTION, SUBMIT_TYPE_TEXT +from trojsten.submit.models import Submit from .constants import DEFAULT_NUMBER_OF_TAGS, MAX_NUMBER_OF_TAGS @@ -41,3 +43,16 @@ def get_points_from_submits(tasks, submits): submit.task, submit.submit_type, submit.user_points, submit.testing_status ) return res + + +def check_description_at_text_submit(user, tasks): + user_submits = Submit.objects.latest_for_user(tasks, user) + for task in tasks: + if ( + task.has_text_submit + and task.has_description + and user_submits.filter(task=task, submit_type=SUBMIT_TYPE_TEXT, points__gt=0) + and not user_submits.filter(task=task, submit_type=SUBMIT_TYPE_DESCRIPTION) + ): + return True + return False diff --git a/trojsten/contests/templates/trojsten/contests/parts/task_list.html b/trojsten/contests/templates/trojsten/contests/parts/task_list.html index 1f65b4332..4da5b5edc 100644 --- a/trojsten/contests/templates/trojsten/contests/parts/task_list.html +++ b/trojsten/contests/templates/trojsten/contests/parts/task_list.html @@ -1,6 +1,13 @@ {% load utils %} +{% load i18n %} +{% if warning_no_description %} +
+ {% trans "You have submitted a text answer but have not submitted a description. This may lead to point deduction." %} +
+{% endif %} + {% if categories.count > 1 %}