This commit is contained in:
rngsurrounded
2025-03-03 22:04:41 +09:00
4 changed files with 16 additions and 9 deletions
+1 -1
View File
@@ -41,7 +41,7 @@ http_addr =
http_port = 3000 http_port = 3000
# The public facing domain name used to access grafana from a browser # The public facing domain name used to access grafana from a browser
domain = prod-team-15-2pc0i3lc.final.prodcontest.ru domain = localhost
# Redirect to correct domain if host header does not match domain # Redirect to correct domain if host header does not match domain
# Prevents DNS rebinding attacks # Prevents DNS rebinding attacks
+8 -2
View File
@@ -109,17 +109,23 @@ def submit_task(
user=user, achievement=first_steps_achievement user=user, achievement=first_steps_achievement
) )
total_attempts = CompetitionTaskSubmission.objects.filter(user=user, task=task).count() total_attempts = CompetitionTaskSubmission.objects.filter(
user=user, task=task
).count()
if task.max_attempts == total_attempts: if task.max_attempts == total_attempts:
return status.FORBIDDEN, ForbiddenError() return status.FORBIDDEN, ForbiddenError()
if task.type == CompetitionTask.CompetitionTaskType.INPUT: if task.type == CompetitionTask.CompetitionTaskType.INPUT:
verdict = content.read() == task.correct_answer_file.read()
submission = CompetitionTaskSubmission.objects.create( submission = CompetitionTaskSubmission.objects.create(
user=user, user=user,
task=task, task=task,
status=CompetitionTaskSubmission.StatusChoices.CHECKED, status=CompetitionTaskSubmission.StatusChoices.CHECKED,
result={"correct": content == task.answer_file_path},
content=content, content=content,
result={
"correct": verdict
},
earned_points=task.points
) )
if task.type == CompetitionTask.CompetitionTaskType.REVIEW: if task.type == CompetitionTask.CompetitionTaskType.REVIEW:
submission = CompetitionTaskSubmission.objects.create( submission = CompetitionTaskSubmission.objects.create(
@@ -4,7 +4,7 @@ from datetime import timedelta, datetime
from django.conf import settings from django.conf import settings
from django.contrib.auth.hashers import make_password from django.contrib.auth.hashers import make_password
from django.core.files.base import ContentFile from django.core.files.base import ContentFile, File
from django.core.management.base import BaseCommand from django.core.management.base import BaseCommand
from django.utils import timezone from django.utils import timezone
@@ -229,12 +229,12 @@ reviewers = [
{ {
"name": "Владислав", "name": "Владислав",
"surname": "Пикиневич", "surname": "Пикиневич",
"token": "pikinevich" "token": "aa443163-9861-4b8d-b8f7-81ecd25f6088"
}, },
{ {
"name": "Александр", "name": "Александр",
"surname": "Шахов", "surname": "Шахов",
"token": "ashakhov" "token": "d2e8904a-01dd-4f84-a8b0-8a60f1a3b6c0"
} }
] ]
@@ -357,7 +357,8 @@ class Command(BaseCommand):
content_dir = f"{settings.BASE_DIR}/apps/core/contents" content_dir = f"{settings.BASE_DIR}/apps/core/contents"
with open(f"{content_dir}/presentation.pptx", "rb") as f: with open(f"{content_dir}/presentation.pptx", "rb") as f:
files = [f, f, dummy_content_txt] pptx = File(f, name="presentation.pptx")
files = [pptx, pptx, dummy_content_txt]
submission = CompetitionTaskSubmission.objects.create( submission = CompetitionTaskSubmission.objects.create(
user=user, user=user,
task=task, task=task,
+2 -2
View File
@@ -41,11 +41,11 @@ def analyze_data_task(self, submission_id):
submission.stdout.save("output.txt", ContentFile(result["output"])) submission.stdout.save("output.txt", ContentFile(result["output"]))
submission.result = { submission.result = {
"correct": result["hash_match"], "correct": result["hash_match"],
"result_hash": result["result_hash"], "hash_match": result["hash_match"],
"error": result.get("error"), "error": result.get("error"),
} }
submission.earned_points = ( submission.earned_points = (
submission.task.points if result["hash_match"] else 0 submission.task.points if result["correct"] else 0
) )
submission.status = CompetitionTaskSubmission.StatusChoices.CHECKED submission.status = CompetitionTaskSubmission.StatusChoices.CHECKED