mirror of
https://gitlab.com/megazordpobeda/DataRush.git
synced 2026-05-22 23:17:09 +00:00
Merge branch 'master' of gitlab.prodcontest.ru:team-15/project
This commit is contained in:
@@ -22,6 +22,10 @@ services:
|
|||||||
restart: false
|
restart: false
|
||||||
condition: service_healthy
|
condition: service_healthy
|
||||||
required: true
|
required: true
|
||||||
|
checker:
|
||||||
|
restart: false
|
||||||
|
condition: service_healthy
|
||||||
|
required: true
|
||||||
env_file:
|
env_file:
|
||||||
- path: ./infrastructure/backend/.env.template
|
- path: ./infrastructure/backend/.env.template
|
||||||
required: true
|
required: true
|
||||||
@@ -384,6 +388,10 @@ services:
|
|||||||
restart: false
|
restart: false
|
||||||
condition: service_completed_successfully
|
condition: service_completed_successfully
|
||||||
required: true
|
required: true
|
||||||
|
minio:
|
||||||
|
restart: false
|
||||||
|
condition: service_healthy
|
||||||
|
required: true
|
||||||
env_file:
|
env_file:
|
||||||
- path: ./infrastructure/checker/.env.template
|
- path: ./infrastructure/checker/.env.template
|
||||||
required: true
|
required: true
|
||||||
|
|||||||
@@ -117,7 +117,10 @@ def submit_task(
|
|||||||
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()
|
user_input = content.read()
|
||||||
|
correct_answer = task.correct_answer_file.read()
|
||||||
|
verdict = user_input == correct_answer
|
||||||
|
print(user_input, correct_answer)
|
||||||
submission = CompetitionTaskSubmission.objects.create(
|
submission = CompetitionTaskSubmission.objects.create(
|
||||||
user=user,
|
user=user,
|
||||||
task=task,
|
task=task,
|
||||||
@@ -126,7 +129,7 @@ def submit_task(
|
|||||||
result={
|
result={
|
||||||
"correct": verdict
|
"correct": verdict
|
||||||
},
|
},
|
||||||
earned_points=task.points
|
earned_points=task.points if verdict else 0
|
||||||
)
|
)
|
||||||
if task.type == CompetitionTask.CompetitionTaskType.REVIEW:
|
if task.type == CompetitionTask.CompetitionTaskType.REVIEW:
|
||||||
submission = CompetitionTaskSubmission.objects.create(
|
submission = CompetitionTaskSubmission.objects.create(
|
||||||
|
|||||||
@@ -0,0 +1,19 @@
|
|||||||
|
# Generated by Django 5.1.6 on 2025-03-03 15:11
|
||||||
|
|
||||||
|
import django.db.models.deletion
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('task', '0002_remove_competitiontasksubmission_plagiarism_checked_and_more'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='competitiontaskattachment',
|
||||||
|
name='task',
|
||||||
|
field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='attachments', to='task.competitiontask', verbose_name='задание'),
|
||||||
|
),
|
||||||
|
]
|
||||||
@@ -111,7 +111,10 @@ class CompetitionTaskAttachment(BaseModel):
|
|||||||
return f"attachments/{instance.id}/file/{filename}"
|
return f"attachments/{instance.id}/file/{filename}"
|
||||||
|
|
||||||
task = models.ForeignKey(
|
task = models.ForeignKey(
|
||||||
CompetitionTask, on_delete=models.CASCADE, verbose_name="задание"
|
CompetitionTask,
|
||||||
|
on_delete=models.CASCADE,
|
||||||
|
verbose_name="задание",
|
||||||
|
related_name="attachments",
|
||||||
)
|
)
|
||||||
file = models.FileField(upload_to=file_upload_at, verbose_name="файл")
|
file = models.FileField(upload_to=file_upload_at, verbose_name="файл")
|
||||||
bind_at = models.CharField(verbose_name="путь сохранения", max_length=255)
|
bind_at = models.CharField(verbose_name="путь сохранения", max_length=255)
|
||||||
|
|||||||
@@ -21,12 +21,12 @@ def analyze_data_task(self, submission_id):
|
|||||||
{
|
{
|
||||||
"url": (
|
"url": (
|
||||||
f"{settings.MINIO_DEFAULT_CUSTOM_ENDPOINT_URL}/"
|
f"{settings.MINIO_DEFAULT_CUSTOM_ENDPOINT_URL}/"
|
||||||
f"{urlparse(submission.content.url).path}"
|
f"{urlparse(attachment.file.url).path}"
|
||||||
),
|
),
|
||||||
"bind_path": attachment.bind_at,
|
"bind_path": attachment.bind_at,
|
||||||
}
|
}
|
||||||
for attachment in submission.task.attachments.filter(
|
for attachment in submission.task.attachments.filter(
|
||||||
bind_path__isnull=False
|
bind_at__isnull=False
|
||||||
)
|
)
|
||||||
]
|
]
|
||||||
|
|
||||||
@@ -37,7 +37,7 @@ def analyze_data_task(self, submission_id):
|
|||||||
"code_url": code_url,
|
"code_url": code_url,
|
||||||
"answer_file_path": submission.task.answer_file_path,
|
"answer_file_path": submission.task.answer_file_path,
|
||||||
"expected_hash": hashlib.sha256(
|
"expected_hash": hashlib.sha256(
|
||||||
submission.task.correct_answer_file.read().encode()
|
submission.task.correct_answer_file.read()
|
||||||
).hexdigest(),
|
).hexdigest(),
|
||||||
},
|
},
|
||||||
timeout=30,
|
timeout=30,
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { DataRush } from "@/components/ui/icons/datarush";
|
import { DataRush } from "@/components/ui/icons/datarush";
|
||||||
import { ChevronDown } from "lucide-react";
|
import { ChevronDown, FileText } from "lucide-react";
|
||||||
import { Link, useNavigate } from "react-router";
|
import { Link, useNavigate } from "react-router";
|
||||||
import { useUserStore } from "@/shared/stores/user";
|
import { useUserStore } from "@/shared/stores/user";
|
||||||
import {
|
import {
|
||||||
@@ -14,6 +14,13 @@ import { removeToken } from "@/shared/token";
|
|||||||
export const Header = () => {
|
export const Header = () => {
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
const user = useUserStore((state) => state.user);
|
const user = useUserStore((state) => state.user);
|
||||||
|
const clearUser = useUserStore((state) => state.clearUser);
|
||||||
|
|
||||||
|
const handleLogout = () => {
|
||||||
|
removeToken();
|
||||||
|
clearUser();
|
||||||
|
navigate("/login");
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<header className="bg-card sticky top-0 z-30 flex h-[72px] w-full items-center justify-center px-4 sm:px-6">
|
<header className="bg-card sticky top-0 z-30 flex h-[72px] w-full items-center justify-center px-4 sm:px-6">
|
||||||
@@ -21,33 +28,39 @@ export const Header = () => {
|
|||||||
<Link to="/">
|
<Link to="/">
|
||||||
<DataRush />
|
<DataRush />
|
||||||
</Link>
|
</Link>
|
||||||
<DropdownMenu>
|
|
||||||
<DropdownMenuTrigger asChild>
|
<div className="flex items-center gap-4">
|
||||||
<button className="flex cursor-pointer items-center gap-1 rounded-md px-2 py-1 text-left transition-opacity hover:opacity-80">
|
<Link
|
||||||
<span className="font-hse-sans text-lg font-semibold">
|
to="/docs/"
|
||||||
{user?.username}
|
className="text-sm font-medium text-gray-700 hover:text-gray-900 transition-colors flex items-center gap-1"
|
||||||
</span>
|
>
|
||||||
<ChevronDown size={20} />
|
<FileText className="h-4 w-4" />
|
||||||
</button>
|
</Link>
|
||||||
</DropdownMenuTrigger>
|
|
||||||
<DropdownMenuContent>
|
<DropdownMenu>
|
||||||
<Link to="/profile">
|
<DropdownMenuTrigger asChild>
|
||||||
<DropdownMenuItem>Аккаунт</DropdownMenuItem>
|
<button className="flex cursor-pointer items-center gap-1 rounded-md px-2 py-1 text-left transition-opacity hover:opacity-80">
|
||||||
</Link>
|
<span className="font-hse-sans text-lg font-semibold">
|
||||||
<DropdownMenuSeparator />
|
{user?.username}
|
||||||
|
</span>
|
||||||
<DropdownMenuItem
|
<ChevronDown size={20} />
|
||||||
variant="destructive"
|
</button>
|
||||||
onClick={() => {
|
</DropdownMenuTrigger>
|
||||||
removeToken();
|
<DropdownMenuContent>
|
||||||
navigate("/login");
|
<Link to="/profile">
|
||||||
}}
|
<DropdownMenuItem>Аккаунт</DropdownMenuItem>
|
||||||
>
|
</Link>
|
||||||
Выйти
|
<DropdownMenuSeparator />
|
||||||
</DropdownMenuItem>
|
<DropdownMenuItem
|
||||||
</DropdownMenuContent>
|
variant="destructive"
|
||||||
</DropdownMenu>
|
onClick={handleLogout}
|
||||||
|
>
|
||||||
|
Выйти
|
||||||
|
</DropdownMenuItem>
|
||||||
|
</DropdownMenuContent>
|
||||||
|
</DropdownMenu>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</header>
|
</header>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
import { useState } from "react";
|
import { useState, useEffect } from "react";
|
||||||
import { useParams, Navigate } from "react-router-dom";
|
import { useParams, Navigate, useNavigate } from "react-router-dom";
|
||||||
import CompetitionHeader from "./components/CompetitionHeader";
|
import CompetitionHeader from "./components/CompetitionHeader";
|
||||||
import TaskContent from "./components/TaskContent";
|
import TaskContent from "./components/TaskContent";
|
||||||
import TaskSolution from "./modules/TaskSolution";
|
import TaskSolution from "./modules/TaskSolution";
|
||||||
@@ -13,8 +13,10 @@ const CompetitionSession = () => {
|
|||||||
const { id, taskId } = useParams<{ id: string; taskId?: string }>();
|
const { id, taskId } = useParams<{ id: string; taskId?: string }>();
|
||||||
const [answer, setAnswer] = useState("");
|
const [answer, setAnswer] = useState("");
|
||||||
const [selectedFile, setSelectedFile] = useState<File | null>(null);
|
const [selectedFile, setSelectedFile] = useState<File | null>(null);
|
||||||
|
const [isReloading, setIsReloading] = useState(false);
|
||||||
const competitionId = id || "";
|
const competitionId = id || "";
|
||||||
const queryClient = useQueryClient();
|
const queryClient = useQueryClient();
|
||||||
|
const navigate = useNavigate();
|
||||||
|
|
||||||
const competitionQuery = useQuery({
|
const competitionQuery = useQuery({
|
||||||
queryKey: ["competition", competitionId],
|
queryKey: ["competition", competitionId],
|
||||||
@@ -45,8 +47,12 @@ const CompetitionSession = () => {
|
|||||||
queryKey: ['solutionHistory', competitionId, taskId]
|
queryKey: ['solutionHistory', competitionId, taskId]
|
||||||
});
|
});
|
||||||
|
|
||||||
setAnswer("");
|
setIsReloading(true);
|
||||||
setSelectedFile(null);
|
|
||||||
|
setTimeout(() => {
|
||||||
|
window.location.reload()
|
||||||
|
setIsReloading(false);
|
||||||
|
}, 2500);
|
||||||
},
|
},
|
||||||
onError: (error) => {
|
onError: (error) => {
|
||||||
console.error("Error submitting solution:", error);
|
console.error("Error submitting solution:", error);
|
||||||
@@ -89,6 +95,13 @@ const CompetitionSession = () => {
|
|||||||
|
|
||||||
const competitionTitle = competition?.title || "Загрузка соревнования...";
|
const competitionTitle = competition?.title || "Загрузка соревнования...";
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
setAnswer("");
|
||||||
|
setSelectedFile(null);
|
||||||
|
}, [taskId]);
|
||||||
|
|
||||||
|
const isSubmitting = submitMutation.isPending || isReloading;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="flex min-h-screen flex-col">
|
<div className="flex min-h-screen flex-col">
|
||||||
<CompetitionHeader
|
<CompetitionHeader
|
||||||
@@ -123,7 +136,7 @@ const CompetitionSession = () => {
|
|||||||
selectedFile={selectedFile}
|
selectedFile={selectedFile}
|
||||||
setSelectedFile={setSelectedFile}
|
setSelectedFile={setSelectedFile}
|
||||||
onSubmit={handleSubmit}
|
onSubmit={handleSubmit}
|
||||||
isSubmitting={submitMutation.isPending}
|
isSubmitting={isSubmitting}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
) : (
|
) : (
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ const TaskSolution: React.FC<TaskSolutionProps> = ({
|
|||||||
selectedFile,
|
selectedFile,
|
||||||
setSelectedFile,
|
setSelectedFile,
|
||||||
onSubmit,
|
onSubmit,
|
||||||
isSubmitting = false
|
isSubmitting = false,
|
||||||
}) => {
|
}) => {
|
||||||
const fileInputRef = useRef<HTMLInputElement>(null);
|
const fileInputRef = useRef<HTMLInputElement>(null);
|
||||||
const [isHistoryOpen, setIsHistoryOpen] = useState(false);
|
const [isHistoryOpen, setIsHistoryOpen] = useState(false);
|
||||||
@@ -70,14 +70,6 @@ const TaskSolution: React.FC<TaskSolutionProps> = ({
|
|||||||
}
|
}
|
||||||
}, [task.id, solutionHistory]);
|
}, [task.id, solutionHistory]);
|
||||||
|
|
||||||
// useEffect(() => {
|
|
||||||
// if (solutionHistory.length > 0 &&
|
|
||||||
// (!displayedSolution ||
|
|
||||||
// (solutionHistory[solutionHistory.length - 1].id !== displayedSolution.id))) {
|
|
||||||
// setDisplayedSolution(solutionHistory[solutionHistory.length - 1]);
|
|
||||||
// }
|
|
||||||
// }, [solutionHistory, displayedSolution]);
|
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const loadSolutionContent = async () => {
|
const loadSolutionContent = async () => {
|
||||||
if (!displayedSolution || !displayedSolution.content) return;
|
if (!displayedSolution || !displayedSolution.content) return;
|
||||||
@@ -122,9 +114,6 @@ const TaskSolution: React.FC<TaskSolutionProps> = ({
|
|||||||
<div className="md:w-[500px] flex flex-col gap-4">
|
<div className="md:w-[500px] flex flex-col gap-4">
|
||||||
{displayedSolution ? (
|
{displayedSolution ? (
|
||||||
<>
|
<>
|
||||||
<div className="bg-gray-100 rounded-lg p-4 text-gray-600 font-hse-sans">
|
|
||||||
Результат последней посылки:
|
|
||||||
</div>
|
|
||||||
<SolutionStatus key={displayedSolution.id} solution={displayedSolution} maxPoints={task.points}/>
|
<SolutionStatus key={displayedSolution.id} solution={displayedSolution} maxPoints={task.points}/>
|
||||||
</>
|
</>
|
||||||
) : (
|
) : (
|
||||||
|
|||||||
@@ -1,13 +1,22 @@
|
|||||||
import { buttonVariants } from "@/components/ui/button";
|
import { buttonVariants } from "@/components/ui/button";
|
||||||
import { DataRushReview } from "@/components/ui/icons/datarush-review";
|
import { DataRushReview } from "@/components/ui/icons/datarush-review";
|
||||||
import { Reviewer } from "@/shared/types/review";
|
import { Reviewer } from "@/shared/types/review";
|
||||||
import { Link } from "react-router";
|
import { useUserStore } from "@/shared/stores/user";
|
||||||
|
import { useNavigate } from "react-router-dom";
|
||||||
|
|
||||||
interface ReviewHeaderProps {
|
interface ReviewHeaderProps {
|
||||||
reviewer: Reviewer;
|
reviewer: Reviewer;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const ReviewHeader = ({ reviewer }: ReviewHeaderProps) => {
|
export const ReviewHeader = ({ reviewer }: ReviewHeaderProps) => {
|
||||||
|
const clearUser = useUserStore((state) => state.clearUser);
|
||||||
|
const navigate = useNavigate();
|
||||||
|
|
||||||
|
const handleLogout = () => {
|
||||||
|
clearUser();
|
||||||
|
navigate("/");
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<header className="flex h-[90px] items-center justify-between gap-4">
|
<header className="flex h-[90px] items-center justify-between gap-4">
|
||||||
<DataRushReview />
|
<DataRushReview />
|
||||||
@@ -15,13 +24,13 @@ export const ReviewHeader = ({ reviewer }: ReviewHeaderProps) => {
|
|||||||
<p className="text-right font-semibold">
|
<p className="text-right font-semibold">
|
||||||
{reviewer.name} {reviewer.surname}
|
{reviewer.name} {reviewer.surname}
|
||||||
</p>
|
</p>
|
||||||
<Link
|
<button
|
||||||
to="/"
|
onClick={handleLogout}
|
||||||
className={buttonVariants({ size: "sm", variant: "secondary" })}
|
className={buttonVariants({ size: "sm", variant: "secondary" })}
|
||||||
>
|
>
|
||||||
Выйти
|
Выйти
|
||||||
</Link>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
</header>
|
</header>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
Reference in New Issue
Block a user