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
|
||||
condition: service_healthy
|
||||
required: true
|
||||
checker:
|
||||
restart: false
|
||||
condition: service_healthy
|
||||
required: true
|
||||
env_file:
|
||||
- path: ./infrastructure/backend/.env.template
|
||||
required: true
|
||||
@@ -384,6 +388,10 @@ services:
|
||||
restart: false
|
||||
condition: service_completed_successfully
|
||||
required: true
|
||||
minio:
|
||||
restart: false
|
||||
condition: service_healthy
|
||||
required: true
|
||||
env_file:
|
||||
- path: ./infrastructure/checker/.env.template
|
||||
required: true
|
||||
|
||||
@@ -117,7 +117,10 @@ def submit_task(
|
||||
return status.FORBIDDEN, ForbiddenError()
|
||||
|
||||
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(
|
||||
user=user,
|
||||
task=task,
|
||||
@@ -126,7 +129,7 @@ def submit_task(
|
||||
result={
|
||||
"correct": verdict
|
||||
},
|
||||
earned_points=task.points
|
||||
earned_points=task.points if verdict else 0
|
||||
)
|
||||
if task.type == CompetitionTask.CompetitionTaskType.REVIEW:
|
||||
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}"
|
||||
|
||||
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="файл")
|
||||
bind_at = models.CharField(verbose_name="путь сохранения", max_length=255)
|
||||
|
||||
@@ -21,12 +21,12 @@ def analyze_data_task(self, submission_id):
|
||||
{
|
||||
"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,
|
||||
}
|
||||
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,
|
||||
"answer_file_path": submission.task.answer_file_path,
|
||||
"expected_hash": hashlib.sha256(
|
||||
submission.task.correct_answer_file.read().encode()
|
||||
submission.task.correct_answer_file.read()
|
||||
).hexdigest(),
|
||||
},
|
||||
timeout=30,
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
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 { useUserStore } from "@/shared/stores/user";
|
||||
import {
|
||||
@@ -14,6 +14,13 @@ import { removeToken } from "@/shared/token";
|
||||
export const Header = () => {
|
||||
const navigate = useNavigate();
|
||||
const user = useUserStore((state) => state.user);
|
||||
const clearUser = useUserStore((state) => state.clearUser);
|
||||
|
||||
const handleLogout = () => {
|
||||
removeToken();
|
||||
clearUser();
|
||||
navigate("/login");
|
||||
};
|
||||
|
||||
return (
|
||||
<header className="bg-card sticky top-0 z-30 flex h-[72px] w-full items-center justify-center px-4 sm:px-6">
|
||||
@@ -21,6 +28,15 @@ export const Header = () => {
|
||||
<Link to="/">
|
||||
<DataRush />
|
||||
</Link>
|
||||
|
||||
<div className="flex items-center gap-4">
|
||||
<Link
|
||||
to="/docs/"
|
||||
className="text-sm font-medium text-gray-700 hover:text-gray-900 transition-colors flex items-center gap-1"
|
||||
>
|
||||
<FileText className="h-4 w-4" />
|
||||
</Link>
|
||||
|
||||
<DropdownMenu>
|
||||
<DropdownMenuTrigger asChild>
|
||||
<button className="flex cursor-pointer items-center gap-1 rounded-md px-2 py-1 text-left transition-opacity hover:opacity-80">
|
||||
@@ -35,19 +51,16 @@ export const Header = () => {
|
||||
<DropdownMenuItem>Аккаунт</DropdownMenuItem>
|
||||
</Link>
|
||||
<DropdownMenuSeparator />
|
||||
|
||||
<DropdownMenuItem
|
||||
variant="destructive"
|
||||
onClick={() => {
|
||||
removeToken();
|
||||
navigate("/login");
|
||||
}}
|
||||
onClick={handleLogout}
|
||||
>
|
||||
Выйти
|
||||
</DropdownMenuItem>
|
||||
</DropdownMenuContent>
|
||||
</DropdownMenu>
|
||||
</div>
|
||||
</div>
|
||||
</header>
|
||||
);
|
||||
};
|
||||
@@ -1,5 +1,5 @@
|
||||
import { useState } from "react";
|
||||
import { useParams, Navigate } from "react-router-dom";
|
||||
import { useState, useEffect } from "react";
|
||||
import { useParams, Navigate, useNavigate } from "react-router-dom";
|
||||
import CompetitionHeader from "./components/CompetitionHeader";
|
||||
import TaskContent from "./components/TaskContent";
|
||||
import TaskSolution from "./modules/TaskSolution";
|
||||
@@ -13,8 +13,10 @@ const CompetitionSession = () => {
|
||||
const { id, taskId } = useParams<{ id: string; taskId?: string }>();
|
||||
const [answer, setAnswer] = useState("");
|
||||
const [selectedFile, setSelectedFile] = useState<File | null>(null);
|
||||
const [isReloading, setIsReloading] = useState(false);
|
||||
const competitionId = id || "";
|
||||
const queryClient = useQueryClient();
|
||||
const navigate = useNavigate();
|
||||
|
||||
const competitionQuery = useQuery({
|
||||
queryKey: ["competition", competitionId],
|
||||
@@ -45,8 +47,12 @@ const CompetitionSession = () => {
|
||||
queryKey: ['solutionHistory', competitionId, taskId]
|
||||
});
|
||||
|
||||
setAnswer("");
|
||||
setSelectedFile(null);
|
||||
setIsReloading(true);
|
||||
|
||||
setTimeout(() => {
|
||||
window.location.reload()
|
||||
setIsReloading(false);
|
||||
}, 2500);
|
||||
},
|
||||
onError: (error) => {
|
||||
console.error("Error submitting solution:", error);
|
||||
@@ -89,6 +95,13 @@ const CompetitionSession = () => {
|
||||
|
||||
const competitionTitle = competition?.title || "Загрузка соревнования...";
|
||||
|
||||
useEffect(() => {
|
||||
setAnswer("");
|
||||
setSelectedFile(null);
|
||||
}, [taskId]);
|
||||
|
||||
const isSubmitting = submitMutation.isPending || isReloading;
|
||||
|
||||
return (
|
||||
<div className="flex min-h-screen flex-col">
|
||||
<CompetitionHeader
|
||||
@@ -123,7 +136,7 @@ const CompetitionSession = () => {
|
||||
selectedFile={selectedFile}
|
||||
setSelectedFile={setSelectedFile}
|
||||
onSubmit={handleSubmit}
|
||||
isSubmitting={submitMutation.isPending}
|
||||
isSubmitting={isSubmitting}
|
||||
/>
|
||||
</div>
|
||||
) : (
|
||||
|
||||
@@ -27,7 +27,7 @@ const TaskSolution: React.FC<TaskSolutionProps> = ({
|
||||
selectedFile,
|
||||
setSelectedFile,
|
||||
onSubmit,
|
||||
isSubmitting = false
|
||||
isSubmitting = false,
|
||||
}) => {
|
||||
const fileInputRef = useRef<HTMLInputElement>(null);
|
||||
const [isHistoryOpen, setIsHistoryOpen] = useState(false);
|
||||
@@ -70,14 +70,6 @@ const TaskSolution: React.FC<TaskSolutionProps> = ({
|
||||
}
|
||||
}, [task.id, solutionHistory]);
|
||||
|
||||
// useEffect(() => {
|
||||
// if (solutionHistory.length > 0 &&
|
||||
// (!displayedSolution ||
|
||||
// (solutionHistory[solutionHistory.length - 1].id !== displayedSolution.id))) {
|
||||
// setDisplayedSolution(solutionHistory[solutionHistory.length - 1]);
|
||||
// }
|
||||
// }, [solutionHistory, displayedSolution]);
|
||||
|
||||
useEffect(() => {
|
||||
const loadSolutionContent = async () => {
|
||||
if (!displayedSolution || !displayedSolution.content) return;
|
||||
@@ -122,9 +114,6 @@ const TaskSolution: React.FC<TaskSolutionProps> = ({
|
||||
<div className="md:w-[500px] flex flex-col gap-4">
|
||||
{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}/>
|
||||
</>
|
||||
) : (
|
||||
|
||||
@@ -1,13 +1,22 @@
|
||||
import { buttonVariants } from "@/components/ui/button";
|
||||
import { DataRushReview } from "@/components/ui/icons/datarush-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 {
|
||||
reviewer: Reviewer;
|
||||
}
|
||||
|
||||
export const ReviewHeader = ({ reviewer }: ReviewHeaderProps) => {
|
||||
const clearUser = useUserStore((state) => state.clearUser);
|
||||
const navigate = useNavigate();
|
||||
|
||||
const handleLogout = () => {
|
||||
clearUser();
|
||||
navigate("/");
|
||||
};
|
||||
|
||||
return (
|
||||
<header className="flex h-[90px] items-center justify-between gap-4">
|
||||
<DataRushReview />
|
||||
@@ -15,12 +24,12 @@ export const ReviewHeader = ({ reviewer }: ReviewHeaderProps) => {
|
||||
<p className="text-right font-semibold">
|
||||
{reviewer.name} {reviewer.surname}
|
||||
</p>
|
||||
<Link
|
||||
to="/"
|
||||
<button
|
||||
onClick={handleLogout}
|
||||
className={buttonVariants({ size: "sm", variant: "secondary" })}
|
||||
>
|
||||
Выйти
|
||||
</Link>
|
||||
</button>
|
||||
</div>
|
||||
</header>
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user