mirror of
https://gitlab.com/megazordpobeda/DataRush.git
synced 2026-05-22 22:07:10 +00:00
Merge remote-tracking branch 'origin/master'
This commit is contained in:
@@ -0,0 +1,79 @@
|
||||
# Креды для DATARUSH
|
||||
|
||||
Найдите номер набора на вашей карточке(слева вверху)
|
||||
#### Администратор
|
||||
- Логин: `admin`
|
||||
- Пароль: `prooooooood`
|
||||
- Ссылка: https://clck.ru/3GkMoo
|
||||
### Набор 1
|
||||
#### Участник
|
||||
- Почта: germanivanov1984@gmail.com
|
||||
- Пароль: `password123!`
|
||||
#### Ревьювер
|
||||
Ссылка: https://clck.ru/3Gjrtg
|
||||
### Набор 2
|
||||
#### Участник
|
||||
- Почта: dreamonovich@gmail.com
|
||||
- Пароль: `password123!`
|
||||
#### Ревьювер
|
||||
Ссылка: https://clck.ru/3Gjs9y
|
||||
### Набор 3
|
||||
#### Участник
|
||||
- Почта: alisa.kuznetsova@gmail.com
|
||||
- Пароль: `password123!`
|
||||
#### Ревьювер
|
||||
Ссылка: https://clck.ru/3GjsDq
|
||||
### Набор 4
|
||||
#### Участник
|
||||
- Почта: ivan.petrov@gmail.com
|
||||
- Пароль: `password123!`
|
||||
#### Ревьювер
|
||||
Ссылка: https://clck.ru/3GjsK3
|
||||
### Набор 5
|
||||
#### Участник
|
||||
- Почта: olga.sidorova@gmail.com
|
||||
- Пароль: `password123!`
|
||||
#### Ревьювер
|
||||
Ссылка: https://clck.ru/3Gjrtg
|
||||
### Набор 6
|
||||
#### Участник
|
||||
- Почта: karim@gmail.com
|
||||
- Пароль: `password123!`
|
||||
#### Ревьювер
|
||||
Ссылка: https://clck.ru/3Gjsa3
|
||||
### Набор 7
|
||||
#### Участник
|
||||
- Почта: noble@gmail.com
|
||||
- Пароль: `password123!`
|
||||
#### Ревьювер
|
||||
Ссылка: https://clck.ru/3Gjsq2
|
||||
### Набор 8
|
||||
#### Участник
|
||||
- Почта: koller@gmail.com
|
||||
- Пароль: `password123!`
|
||||
#### Ревьювер
|
||||
Ссылка: https://clck.ru/3Gjt7n
|
||||
### Набор 9
|
||||
#### Участник
|
||||
- Почта: gold_checker@gmail.com
|
||||
- Пароль: `password123!`
|
||||
#### Ревьювер
|
||||
Ссылка: https://clck.ru/3GjtBp
|
||||
### Набор 10
|
||||
#### Участник
|
||||
- Почта: looka@gmail.com
|
||||
- Пароль: `password123!`
|
||||
#### Ревьювер
|
||||
Ссылка: https://clck.ru/3GjtLv
|
||||
### Набор 11
|
||||
#### Участник
|
||||
- Почта: danil_malikov@gmail.com
|
||||
- Пароль: `password123!`
|
||||
#### Ревьювер
|
||||
Ссылка: https://clck.ru/3GjtMh
|
||||
### Набор 12
|
||||
#### Участник
|
||||
- Почта: marina-looks@gmail.com
|
||||
- Пароль: `password123!`
|
||||
#### Ревьювер
|
||||
Ссылка: https://clck.ru/3GjtNP
|
||||
@@ -2,7 +2,6 @@
|
||||
|
||||
Инновационный сервис для проведения соревнований по анализу данных
|
||||
|
||||
|
||||
## Запуск
|
||||
|
||||
Склонируйте репозиторий и пропишите.
|
||||
@@ -24,10 +23,49 @@ docker compose up
|
||||
* `admin` - логин
|
||||
* `proooooood` - пароль
|
||||
|
||||
## Как устроен проект
|
||||
|
||||
В проекте используются 3 основных модуля: backend, frontend и checker
|
||||
|
||||
1. `backend` представляет собой приложение, написанное на Django с применением [Django Ninja](https://django-ninja.dev/), который позволяет быстро и легко создавать Restful API.
|
||||
|
||||
Сам бекенд состоит из 2-х основных компонентов: приложений (где хранятся модели, тесты и настройки админ-панели) и основных колбеков (где хранятся схемы OpenAPI и сами ручки)
|
||||
|
||||
Решения на проверку отсылаются через `celery` для асинхронного взаимодействия, так как его ожидание может занять довольно длительное время.
|
||||
|
||||
2. `frontend` является React приложением, которое запускается через Vite. В нем также используется TypeScript для более строгой типизации. Структура приложения является стандартной для подобного вида проектов: есть отдельная папка для компонентов, страниц, стилей, работы с API.
|
||||
|
||||
3. `checker` - микросервис на FastAPI, созданный для безопасного асинхронного запуска посылок пользователей.
|
||||
|
||||
Данные в этот сервис отсылаются по специальной ручке `/execute`, которая является приватной (ее нет в документации)
|
||||
|
||||
Проверка заданий осуществляется через запуск кода пользователя через специально создаваемый Docker контейнер, на который выдаются следующие ресурсы:
|
||||
|
||||
* 1 ядро CPU
|
||||
* 1 ГБ ОЗУ
|
||||
|
||||
Для приближения к условиям работы аналитиков в интерпритаторе Python есть следующие библиотеки:
|
||||
|
||||
```python
|
||||
pandas==2.2.3
|
||||
numpy==2.2.3
|
||||
matplotlib==3.10.1
|
||||
scipy==1.15.2
|
||||
scikit-learn==1.6.1
|
||||
seaborn==0.13.2
|
||||
statsmodels==0.14.4
|
||||
```
|
||||
|
||||
Контейнеру дается 1 минута на выполнение кода, потом - контейнер удаляется
|
||||
|
||||
## Тесты
|
||||
|
||||
Написаны unit-тесты (на базе Django TestCase) и E2E (Postman коллекция). Они покрывают flow регистрации, просмотра и участия в соревновании.
|
||||
|
||||
Unit-тесты находятся в соответствующих приложениях, которые располагаются по пути `services/backend/apps`
|
||||
|
||||
JSON коллекция, в которой хранятся E2E тесты, находится по пути `img/postman_e2e.json`. Ее можно импортировать в постман, нажав на соответсвующую кнопку в интерфейсе Postman
|
||||
|
||||

|
||||
|
||||
Ниже можно увидеть Coverage тестами бекенда данного приложения
|
||||
|
||||
@@ -33,7 +33,7 @@ class TaskOutSchema(ModelSchema):
|
||||
"description",
|
||||
"in_competition_position",
|
||||
"points",
|
||||
"max_attempts"
|
||||
"max_attempts",
|
||||
]
|
||||
|
||||
|
||||
@@ -68,3 +68,4 @@ class TaskStatusSchema(Schema):
|
||||
task_name: str
|
||||
result: int
|
||||
max_points: int
|
||||
position: int
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
from http import HTTPStatus as status
|
||||
from uuid import UUID
|
||||
|
||||
from django.shortcuts import get_object_or_404, get_list_or_404
|
||||
from django.shortcuts import get_list_or_404, get_object_or_404
|
||||
from ninja import File, Router, UploadedFile
|
||||
|
||||
from api.v1.ping.schemas import PingOut
|
||||
@@ -10,8 +10,8 @@ from api.v1.task.schemas import (
|
||||
HistorySubmissionOut,
|
||||
TaskAttachmentSchema,
|
||||
TaskOutSchema,
|
||||
TaskSubmissionOut,
|
||||
TaskStatusSchema,
|
||||
TaskSubmissionOut,
|
||||
)
|
||||
from apps.achievement.models import Achievement, UserAchievement
|
||||
from apps.competition.models import State
|
||||
@@ -125,10 +125,8 @@ def submit_task(
|
||||
task=task,
|
||||
status=CompetitionTaskSubmission.StatusChoices.CHECKED,
|
||||
content=content,
|
||||
result={
|
||||
"correct": verdict
|
||||
},
|
||||
earned_points=task.points if verdict else 0
|
||||
result={"correct": verdict},
|
||||
earned_points=task.points if verdict else 0,
|
||||
)
|
||||
if task.type == CompetitionTask.CompetitionTaskType.REVIEW:
|
||||
submission = CompetitionTaskSubmission.objects.create(
|
||||
@@ -184,7 +182,7 @@ def get_task_attachments(request, competition_id: UUID, task_id: UUID):
|
||||
"competitions/{competition_id}/results",
|
||||
response={
|
||||
status.OK: list[TaskStatusSchema],
|
||||
status.UNAUTHORIZED: UnauthorizedError
|
||||
status.UNAUTHORIZED: UnauthorizedError,
|
||||
},
|
||||
)
|
||||
def get_competition_results(request, competition_id: UUID):
|
||||
@@ -193,9 +191,14 @@ def get_competition_results(request, competition_id: UUID):
|
||||
data = []
|
||||
|
||||
for task in tasks:
|
||||
submissions = CompetitionTaskSubmission.objects.filter(
|
||||
submissions = (
|
||||
CompetitionTaskSubmission.objects.filter(
|
||||
user=request.auth, task=task
|
||||
).filter(status="checked").order_by("-earned_points").all()
|
||||
)
|
||||
.filter(status="checked")
|
||||
.order_by("-earned_points")
|
||||
.all()
|
||||
)
|
||||
if not submissions:
|
||||
all_submissions_count = CompetitionTaskSubmission.objects.filter(
|
||||
user=request.auth, task=task
|
||||
@@ -206,10 +209,13 @@ def get_competition_results(request, competition_id: UUID):
|
||||
result = -1
|
||||
else:
|
||||
result = submissions[0].earned_points
|
||||
data.append(TaskStatusSchema(
|
||||
data.append(
|
||||
TaskStatusSchema(
|
||||
task_name=task.title,
|
||||
result=result,
|
||||
max_points=task.points,
|
||||
))
|
||||
position=task.in_competition_position,
|
||||
)
|
||||
)
|
||||
|
||||
return status.OK, data
|
||||
|
||||
@@ -3,7 +3,6 @@ from uuid import UUID
|
||||
from django.shortcuts import get_object_or_404
|
||||
from ninja import Router
|
||||
|
||||
from api.v1.schemas import BadRequestError, NotFoundError, UnauthorizedError
|
||||
from api.v1.team.schemas import CreateTeamSchema, TeamSchemaOut
|
||||
from apps.team.models import Team
|
||||
|
||||
|
||||
@@ -23,7 +23,7 @@ from api.v1.user.schemas import (
|
||||
TokenSchema,
|
||||
UserSchema,
|
||||
)
|
||||
from apps.task.models import CompetitionTaskSubmission, CompetitionTask
|
||||
from apps.task.models import CompetitionTask, CompetitionTaskSubmission
|
||||
from apps.user.models import User
|
||||
|
||||
router = Router(tags=["user"])
|
||||
|
||||
@@ -7,4 +7,4 @@ class CompetitionsConfig(AppConfig):
|
||||
verbose_name = "Соревнование"
|
||||
|
||||
def ready(self):
|
||||
import apps.competition.signals
|
||||
pass
|
||||
|
||||
@@ -3,15 +3,23 @@ from django.dispatch import receiver
|
||||
|
||||
from apps.achievement.models import Achievement, UserAchievement
|
||||
from apps.competition.models import State
|
||||
from apps.user.models import User
|
||||
|
||||
|
||||
@receiver(post_save, sender=State)
|
||||
def assign_start_competition_achievement(sender, instance, created, **kwargs):
|
||||
if created:
|
||||
if State.objects.filter(user=instance.user, state=State.StateChoices.STARTED.value).count() == 1 \
|
||||
and not State.objects.filter(user=instance.user, state=State.StateChoices.FINISHED.value).exists():
|
||||
start_competition_achievement = Achievement.objects.get(slug="start_competition")
|
||||
if (
|
||||
State.objects.filter(
|
||||
user=instance.user, state=State.StateChoices.STARTED.value
|
||||
).count()
|
||||
== 1
|
||||
and not State.objects.filter(
|
||||
user=instance.user, state=State.StateChoices.FINISHED.value
|
||||
).exists()
|
||||
):
|
||||
start_competition_achievement = Achievement.objects.get(
|
||||
slug="start_competition"
|
||||
)
|
||||
UserAchievement.objects.create(
|
||||
user=instance.user, achievement=start_competition_achievement
|
||||
)
|
||||
|
||||
@@ -19,6 +19,7 @@ from apps.user.models import User, UserRole
|
||||
|
||||
faker = Faker("ru_RU")
|
||||
|
||||
|
||||
class Command(BaseCommand):
|
||||
help = "Generate sample data for Users, Competitions, Tasks, Submissions, and States."
|
||||
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
import random
|
||||
import uuid
|
||||
from datetime import timedelta, datetime
|
||||
from datetime import timedelta
|
||||
|
||||
from PIL.Image import Image
|
||||
from django.conf import settings
|
||||
from django.contrib.auth.hashers import make_password
|
||||
from django.core.files.base import ContentFile, File
|
||||
@@ -13,9 +12,9 @@ from apps.competition.models import Competition, State
|
||||
from apps.review.models import Reviewer
|
||||
from apps.task.models import (
|
||||
CompetitionTask,
|
||||
CompetitionTaskAttachment,
|
||||
CompetitionTaskCriteria,
|
||||
CompetitionTaskSubmission,
|
||||
CompetitionTaskAttachment,
|
||||
)
|
||||
from apps.user.models import User, UserRole
|
||||
|
||||
@@ -47,11 +46,11 @@ dataset2 = ContentFile(
|
||||
|
||||
correct_answer_file = ContentFile(
|
||||
b"42",
|
||||
name=f"answer.txt",
|
||||
name="answer.txt",
|
||||
)
|
||||
correct2_answer_file = ContentFile(
|
||||
b"it is a dataset",
|
||||
name=f"answer.txt",
|
||||
name="answer.txt",
|
||||
)
|
||||
|
||||
now = timezone.now()
|
||||
@@ -666,7 +665,7 @@ class Command(BaseCommand):
|
||||
type=competition["type"],
|
||||
participation_type=competition["participation_type"],
|
||||
)
|
||||
except Exception as e:
|
||||
except Exception:
|
||||
print(competition)
|
||||
|
||||
if competition.get("image"):
|
||||
@@ -697,13 +696,18 @@ class Command(BaseCommand):
|
||||
points=task["points"],
|
||||
submission_reviewers_count=task[
|
||||
"submission_reviewers_count"
|
||||
] if task["type"] == CompetitionTask.CompetitionTaskType.REVIEW.value else None,
|
||||
correct_answer_file=task["correct_answer_file"] if task["type"] != CompetitionTask.CompetitionTaskType.REVIEW.value else None,
|
||||
]
|
||||
if task["type"]
|
||||
== CompetitionTask.CompetitionTaskType.REVIEW.value
|
||||
else None,
|
||||
correct_answer_file=task["correct_answer_file"]
|
||||
if task["type"]
|
||||
!= CompetitionTask.CompetitionTaskType.REVIEW.value
|
||||
else None,
|
||||
max_attempts=task.get("max_attempts"),
|
||||
)
|
||||
competitions[i]["tasks"][j]["obj"] = task_obj
|
||||
|
||||
|
||||
if task.get("attachment"):
|
||||
CompetitionTaskAttachment.objects.create(
|
||||
task=task_obj,
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
# Generated by Django 5.1.6 on 2025-03-03 23:02
|
||||
|
||||
import django.core.validators
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('task', '0003_alter_competitiontaskattachment_task'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterField(
|
||||
model_name='competitiontaskattachment',
|
||||
name='bind_at',
|
||||
field=models.CharField(max_length=255, validators=[django.core.validators.RegexValidator('^(?:[a-zA-Z]:\\\\(?:[^<>:\\"\\/\\\\|?*]*\\\\)*|/(?:[^<>:\\"\\/\\\\|?*]+/?)*)$', message='Введите абсолютный путь до папки')], verbose_name='путь сохранения'),
|
||||
),
|
||||
]
|
||||
@@ -1,10 +1,9 @@
|
||||
from sys import stdout
|
||||
from uuid import uuid4
|
||||
|
||||
from django.core.exceptions import ValidationError
|
||||
from django.core.validators import RegexValidator
|
||||
from django.db import models
|
||||
from django.db.models import Count, Q
|
||||
from django.core.validators import RegexValidator
|
||||
from django.core.exceptions import ValidationError
|
||||
from mdeditor.fields import MDTextField
|
||||
|
||||
from apps.competition.models import Competition
|
||||
@@ -88,23 +87,27 @@ class CompetitionTask(BaseModel):
|
||||
# "type": "Если загружен файл правильного ответа, то тип проверки не может быть ручным"
|
||||
# })
|
||||
if not self.correct_answer_file and self.type != "review":
|
||||
raise ValidationError({
|
||||
"correct_answer_file": "Загрузите правильный ответ"
|
||||
})
|
||||
raise ValidationError(
|
||||
{"correct_answer_file": "Загрузите правильный ответ"}
|
||||
)
|
||||
|
||||
# if self.answer_file_path and not self.type == "checker":
|
||||
# raise ValidationError({
|
||||
# "type": "Укажите другой тип задания: этот не совместим с путем правильного ответа"
|
||||
# })
|
||||
if not self.answer_file_path and self.type == "checker":
|
||||
raise ValidationError({
|
||||
raise ValidationError(
|
||||
{
|
||||
"answer_file_path": "Введите путь правильного ответа - это нужно для корректной работы чекера"
|
||||
})
|
||||
}
|
||||
)
|
||||
|
||||
if not self.reviewers and self.type == "review":
|
||||
raise ValidationError({
|
||||
raise ValidationError(
|
||||
{
|
||||
"reviewers": "Загрузите ревьюверов - кто будет проверять задания, если не они?"
|
||||
})
|
||||
}
|
||||
)
|
||||
# elif self.reviewers and not self.type == "review":
|
||||
# raise ValidationError({
|
||||
# "type": "Проверьте тип - вы ввели ревьюверов, но задание не является ручным"
|
||||
|
||||
@@ -1,11 +1,10 @@
|
||||
import base64
|
||||
import hashlib
|
||||
from urllib.parse import urlparse
|
||||
|
||||
import httpx
|
||||
from celery import shared_task
|
||||
from django.conf import settings
|
||||
from django.core.files.base import ContentFile
|
||||
from urllib.parse import urlparse
|
||||
import base64
|
||||
|
||||
from apps.task.models import CompetitionTaskSubmission
|
||||
|
||||
@@ -35,23 +34,27 @@ def analyze_data_task(self, submission_id):
|
||||
"code": base64.b64encode(code).decode("utf-8"),
|
||||
"answer_file_path": submission.task.answer_file_path,
|
||||
"expected_hash": hashlib.sha256(
|
||||
submission.task.correct_answer_file.read().decode("utf-8")
|
||||
submission.task.correct_answer_file.read()
|
||||
).hexdigest(),
|
||||
},
|
||||
timeout=30,
|
||||
)
|
||||
response.raise_for_status()
|
||||
result = response.json()
|
||||
print(result, response.request)
|
||||
print(result)
|
||||
|
||||
submission.stdout.save("output.txt", ContentFile(result["output"]))
|
||||
# submission.stdout = ContentFile(
|
||||
# bytes(result["output"]),
|
||||
# "output.txt",
|
||||
# )
|
||||
# submission.stdout.save()
|
||||
submission.result = {
|
||||
"correct": result["correct"],
|
||||
"correct": result["hash_match"],
|
||||
"hash_match": result["hash_match"],
|
||||
"error": result.get("error"),
|
||||
}
|
||||
submission.earned_points = (
|
||||
submission.task.points if result["correct"] else 0
|
||||
submission.task.points if result["hash_match"] else 0
|
||||
)
|
||||
submission.status = CompetitionTaskSubmission.StatusChoices.CHECKED
|
||||
|
||||
|
||||
@@ -7,4 +7,4 @@ class UsersConfig(AppConfig):
|
||||
verbose_name = "контестанты"
|
||||
|
||||
def ready(self):
|
||||
import apps.user.signals
|
||||
pass
|
||||
|
||||
@@ -88,9 +88,7 @@ async def download_file(
|
||||
session: aiohttp.ClientSession, url: str, dest_path: str
|
||||
) -> None:
|
||||
try:
|
||||
async with session.get(
|
||||
url, timeout=aiohttp.ClientTimeout(total=30)
|
||||
) as resp:
|
||||
async with session.get(url, timeout=aiohttp.ClientTimeout(total=30)) as resp:
|
||||
if resp.status != 200:
|
||||
raise HTTPException(
|
||||
status_code=status.HTTP_400_BAD_REQUEST,
|
||||
@@ -271,9 +269,7 @@ async def execute_code(request: ExecutionRequest) -> ExecutionResponse:
|
||||
response = ExecutionResponse(
|
||||
success=success,
|
||||
hash_match=(
|
||||
result_hash == request.expected_hash
|
||||
if request.expected_hash
|
||||
else None
|
||||
result_hash == request.expected_hash if request.expected_hash else None
|
||||
),
|
||||
output=output[:5000],
|
||||
result_hash=result_hash,
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 33 KiB |
@@ -30,13 +30,14 @@ export const Header = () => {
|
||||
</Link>
|
||||
|
||||
<div className="flex items-center gap-4">
|
||||
<a
|
||||
href="/docs/"
|
||||
|
||||
<Link
|
||||
to="/docs" target="_blank"
|
||||
className="hidden md:flex text-sm font-medium text-gray-700 hover:text-gray-900 transition-colors items-center gap-1"
|
||||
>
|
||||
<FileText className="h-4 w-4" />
|
||||
Материалы
|
||||
</a>
|
||||
</Link>
|
||||
|
||||
<DropdownMenu>
|
||||
<DropdownMenuTrigger asChild>
|
||||
@@ -53,7 +54,7 @@ export const Header = () => {
|
||||
</Link>
|
||||
|
||||
<div className="md:hidden">
|
||||
<Link to="/docs">
|
||||
<Link to="/docs" target="_blank">
|
||||
<DropdownMenuItem>
|
||||
Материалы
|
||||
</DropdownMenuItem>
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
// src/components/competition/CompetitionResultsModal.tsx
|
||||
import React from 'react';
|
||||
import {
|
||||
Dialog,
|
||||
@@ -12,7 +11,8 @@ import { Loader2 } from 'lucide-react';
|
||||
export interface CompetitionResult {
|
||||
task_name: string;
|
||||
result: number;
|
||||
max_points: number
|
||||
max_points: number;
|
||||
position: number;
|
||||
}
|
||||
|
||||
interface CompetitionResultsModalProps {
|
||||
@@ -111,7 +111,9 @@ export const CompetitionResultsModal: React.FC<CompetitionResultsModalProps> = (
|
||||
Произошла ошибка при загрузке результатов
|
||||
</div>
|
||||
) : results && results.length > 0 ? (
|
||||
results.map((result, index) => (
|
||||
[...results]
|
||||
.sort((a, b) => a.position - b.position)
|
||||
.map((result, index) => (
|
||||
<div
|
||||
key={index}
|
||||
className="flex flex-col md:flex-row justify-between items-start md:items-center p-4 bg-gray-50 rounded-lg border"
|
||||
|
||||
@@ -74,7 +74,11 @@ const TaskContent: React.FC<TaskContentProps> = ({ task }) => {
|
||||
const getFileNameFromUrl = (url: string): string => {
|
||||
try {
|
||||
const parts = url.split('/');
|
||||
return parts[parts.length - 1];
|
||||
const fullFileName = parts[parts.length - 1]
|
||||
const fileName = fullFileName.length > 20
|
||||
? fullFileName.substring(0, 20) + '...'
|
||||
: fullFileName;
|
||||
return fileName;
|
||||
} catch (e) {
|
||||
return 'Файл';
|
||||
}
|
||||
|
||||
@@ -151,8 +151,8 @@ const CompetitionSession = () => {
|
||||
isSubmitting={isSubmitting}
|
||||
/>
|
||||
{isReloading && (
|
||||
<div className="fixed inset-0 flex items-center justify-center bg-black bg-opacity-50 z-50">
|
||||
<div className="bg-white p-6 rounded-lg shadow-xl text-center">
|
||||
<div className="fixed inset-0 z-50 flex items-center justify-center backdrop-blur-sm bg-white/30">
|
||||
<div className="bg-white p-6 rounded-lg shadow-xl text-center max-w-xs lg:max-w-md mx-4 w-full">
|
||||
<Loader2 className="h-8 w-8 animate-spin mx-auto mb-4" />
|
||||
<p className="font-hse-sans text-gray-700">
|
||||
Решение отправлено! Пожалуйста, подождите...
|
||||
|
||||
+1
-1
@@ -35,7 +35,7 @@ const ActionButtons: React.FC<ActionButtonsProps> = ({
|
||||
>
|
||||
Задача сдана!
|
||||
</Button>
|
||||
) : hasSubmissionsLeft ? (
|
||||
) : hasSubmissionsLeft? (
|
||||
<Button
|
||||
onClick={onSubmit}
|
||||
className="font-hse-sans flex-grow"
|
||||
|
||||
+17
-17
@@ -116,29 +116,29 @@ const CodeSolution: React.FC<CodeSolutionProps> = ({
|
||||
|
||||
<div className="mt-4 space-y-6">
|
||||
<div>
|
||||
<h3 className="text-lg font-semibold mb-3 text-indigo-700 border-b pb-2">Ограничения</h3>
|
||||
<h3 className="text-lg font-semibold mb-3 border-b pb-2">Ограничение ресурсов</h3>
|
||||
<ul className="space-y-3 text-gray-700">
|
||||
<li className="flex items-start">
|
||||
<div className="bg-indigo-100 p-1.5 rounded-full mr-3 mt-0.5">
|
||||
<div className="w-1.5 h-1.5 bg-indigo-500 rounded-full"></div>
|
||||
<div className="bg-yellow-100 p-1.5 rounded-full mr-3 mt-0.5">
|
||||
<div className="w-1.5 h-1.5 bg-yellow-500 rounded-full"></div>
|
||||
</div>
|
||||
Максимум 1 посылка в 10 секунд
|
||||
</li>
|
||||
<li className="flex items-start">
|
||||
<div className="bg-indigo-100 p-1.5 rounded-full mr-3 mt-0.5">
|
||||
<div className="w-1.5 h-1.5 bg-indigo-500 rounded-full"></div>
|
||||
<div className="bg-yellow-100 p-1.5 rounded-full mr-3 mt-0.5">
|
||||
<div className="w-1.5 h-1.5 bg-yellow-500 rounded-full"></div>
|
||||
</div>
|
||||
Максимальный размер решения 4MB
|
||||
</li>
|
||||
<li className="flex items-start">
|
||||
<div className="bg-indigo-100 p-1.5 rounded-full mr-3 mt-0.5">
|
||||
<div className="w-1.5 h-1.5 bg-indigo-500 rounded-full"></div>
|
||||
<div className="bg-yellow-100 p-1.5 rounded-full mr-3 mt-0.5">
|
||||
<div className="w-1.5 h-1.5 bg-yellow-500 rounded-full"></div>
|
||||
</div>
|
||||
Максимальное время работы программы 1 минута
|
||||
</li>
|
||||
<li className="flex items-start">
|
||||
<div className="bg-indigo-100 p-1.5 rounded-full mr-3 mt-0.5">
|
||||
<div className="w-1.5 h-1.5 bg-indigo-500 rounded-full"></div>
|
||||
<div className="bg-yellow-100 p-1.5 rounded-full mr-3 mt-0.5">
|
||||
<div className="w-1.5 h-1.5 bg-yellow-500 rounded-full"></div>
|
||||
</div>
|
||||
Выделяется 512MB на решение
|
||||
</li>
|
||||
@@ -146,35 +146,35 @@ const CodeSolution: React.FC<CodeSolutionProps> = ({
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<h3 className="text-lg font-semibold mb-3 text-indigo-700 border-b pb-2">Доступные библиотеки</h3>
|
||||
<h3 className="text-lg font-semibold mb-3 border-b pb-2">Доступные библиотеки</h3>
|
||||
<div className="bg-gray-50 p-4 rounded-md font-mono text-sm">
|
||||
<div className="grid grid-cols-1 md:grid-cols-2 gap-2">
|
||||
<div className="flex items-center">
|
||||
<span className="text-indigo-600 font-semibold">pandas</span>
|
||||
<span className="text-yellow-600 font-semibold">pandas</span>
|
||||
<span className="text-gray-500 ml-2">2.2.3</span>
|
||||
</div>
|
||||
<div className="flex items-center">
|
||||
<span className="text-indigo-600 font-semibold">numpy</span>
|
||||
<span className="text-yellow-600 font-semibold">numpy</span>
|
||||
<span className="text-gray-500 ml-2">2.2.3</span>
|
||||
</div>
|
||||
<div className="flex items-center">
|
||||
<span className="text-indigo-600 font-semibold">matplotlib</span>
|
||||
<span className="text-yellow-600 font-semibold">matplotlib</span>
|
||||
<span className="text-gray-500 ml-2">3.10.1</span>
|
||||
</div>
|
||||
<div className="flex items-center">
|
||||
<span className="text-indigo-600 font-semibold">scipy</span>
|
||||
<span className="text-yellow-600 font-semibold">scipy</span>
|
||||
<span className="text-gray-500 ml-2">1.15.2</span>
|
||||
</div>
|
||||
<div className="flex items-center">
|
||||
<span className="text-indigo-600 font-semibold">scikit-learn</span>
|
||||
<span className="text-yellow-600 font-semibold">scikit-learn</span>
|
||||
<span className="text-gray-500 ml-2">1.6.1</span>
|
||||
</div>
|
||||
<div className="flex items-center">
|
||||
<span className="text-indigo-600 font-semibold">seaborn</span>
|
||||
<span className="text-yellow-600 font-semibold">seaborn</span>
|
||||
<span className="text-gray-500 ml-2">0.13.2</span>
|
||||
</div>
|
||||
<div className="flex items-center">
|
||||
<span className="text-indigo-600 font-semibold">statsmodels</span>
|
||||
<span className="text-yellow-600 font-semibold">statsmodels</span>
|
||||
<span className="text-gray-500 ml-2">0.14.4</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
+5
-1
@@ -60,12 +60,16 @@ const FileSolution: React.FC<FileSolutionProps> = ({
|
||||
};
|
||||
|
||||
|
||||
const fileName = selectedFile
|
||||
const fullFileName = selectedFile
|
||||
? selectedFile.name
|
||||
: existingFileUrl
|
||||
? existingFileUrl.split('/').pop() || 'file'
|
||||
: '';
|
||||
|
||||
const fileName = fullFileName.length > 20
|
||||
? fullFileName.substring(0, 20) + '...'
|
||||
: fullFileName;
|
||||
|
||||
const hasFile = !!selectedFile || !!existingFileUrl;
|
||||
|
||||
return (
|
||||
|
||||
@@ -42,7 +42,11 @@ const TaskSolution: React.FC<TaskSolutionProps> = ({
|
||||
enabled: !!(competitionId && task.id),
|
||||
});
|
||||
|
||||
const solutionHistory = solutionsQuery.data || [];
|
||||
const solutionHistory = [...(solutionsQuery.data || [])].sort((a, b) => {
|
||||
const dateA = new Date(a.timestamp);
|
||||
const dateB = new Date(b.timestamp);
|
||||
return dateA.getTime() - dateB.getTime();
|
||||
});
|
||||
|
||||
let lastSolutionPoints = 0;
|
||||
if (solutionHistory.length > 0) {
|
||||
@@ -51,7 +55,7 @@ const TaskSolution: React.FC<TaskSolutionProps> = ({
|
||||
const maxAttempts = task.max_attempts || -1;
|
||||
const submissionsUsed = solutionHistory.length;
|
||||
const submissionsLeft = Math.max(0, maxAttempts - submissionsUsed);
|
||||
const hasSubmissionsLeft = submissionsLeft > 0;
|
||||
const hasSubmissionsLeft = submissionsLeft > 0 || maxAttempts === -1;
|
||||
|
||||
useEffect(() => {
|
||||
if (solutionHistory.length > 0 && !displayedSolution) {
|
||||
@@ -155,10 +159,10 @@ const TaskSolution: React.FC<TaskSolutionProps> = ({
|
||||
? 'bg-blue-50 text-blue-700'
|
||||
: 'bg-red-50 text-red-700'}`}
|
||||
>
|
||||
{hasSubmissionsLeft ? (
|
||||
{maxAttempts === -1 || hasSubmissionsLeft ? (
|
||||
<>
|
||||
<span className="font-medium">
|
||||
Осталось посылок: {submissionsLeft === Infinity ? '∞' : submissionsLeft}
|
||||
Осталось посылок: {maxAttempts === -1 ? '∞' : submissionsLeft}
|
||||
</span>
|
||||
{maxAttempts !== -1 && (
|
||||
<span className="text-blue-500 ml-1">
|
||||
|
||||
@@ -3,15 +3,14 @@ import { User } from "@/shared/types/user";
|
||||
export const UserInfo = ({ user }: { user: User }) => {
|
||||
return (
|
||||
<section className="flex flex-1 flex-col items-center gap-6 text-center md:max-w-[420px] md:items-start md:text-left md:text-ellipsis">
|
||||
{user.avatar && (
|
||||
<div className="aspect-square h-auto w-full max-w-[300px] overflow-hidden rounded-full border">
|
||||
<div className="bg-card aspect-square h-auto w-full max-w-[300px] overflow-hidden rounded-full border">
|
||||
<img
|
||||
src={user.avatar}
|
||||
src={user.avatar ?? "/lottie.png"}
|
||||
alt={user.username}
|
||||
className="h-full w-full object-cover object-center"
|
||||
/>
|
||||
</div>
|
||||
)}
|
||||
|
||||
<div className="flex flex-col gap-3">
|
||||
<h1 className="text-4xl font-semibold">{user.username}</h1>
|
||||
<p className="text-muted-foreground">{user.email}</p>
|
||||
|
||||
@@ -148,7 +148,12 @@ const ReviewDescription = ({ review }: { review: Review }) => {
|
||||
|
||||
const ReviewContent = ({ review }: { review: Review }) => {
|
||||
const extension = review.content.split(".").at(-1);
|
||||
const filename = review.content.split("/").at(-1);
|
||||
const fullFilename = review.content.split("/").at(-1);
|
||||
|
||||
const filename = fullFilename ?
|
||||
(fullFilename.length > 20 ? fullFilename.substring(0, 20) + '...' : fullFilename)
|
||||
: '';
|
||||
|
||||
|
||||
const { data: content, isLoading } = useQuery({
|
||||
queryKey: ["review-file", review.id],
|
||||
|
||||
Reference in New Issue
Block a user