From cc5538a6e9cf3ecc299b4207b639bd0519ca8f79 Mon Sep 17 00:00:00 2001 From: Aqua-sc <108478185+Aqua-sc@users.noreply.github.com> Date: Thu, 23 May 2024 13:09:20 +0200 Subject: [PATCH 1/2] Cancel button + noscore not in edit --- .../project/components/SubmissionsTable.tsx | 56 ++++++++++++++----- 1 file changed, 42 insertions(+), 14 deletions(-) diff --git a/frontend/src/pages/project/components/SubmissionsTable.tsx b/frontend/src/pages/project/components/SubmissionsTable.tsx index 6f7ef987..3b066efb 100644 --- a/frontend/src/pages/project/components/SubmissionsTable.tsx +++ b/frontend/src/pages/project/components/SubmissionsTable.tsx @@ -1,4 +1,4 @@ -import { Button, Input, List, Table, Tooltip, Typography } from "antd"; +import { Button, Input, List, Space, Table, Tooltip, Typography } from "antd"; import { FC, useMemo, useState } from "react"; import { ProjectSubmissionsType } from "./SubmissionsTab"; import { TableProps } from "antd/lib"; @@ -27,7 +27,8 @@ const SubmissionsTable: FC<{ submissions: ProjectSubmissionsType[] | null; onCha const { message } = useAppApi(); const API = useApi(); const [editingFeedback, setEditingFeedback] = useState<{ [key: number]: string }>({}); - const [isEditing, setIsEditing] = useState<{ [key: number]: boolean }>({}); + const [isEditingFeedback, setIsEditingFeedback] = useState<{ [key: number]: boolean }>({}); + const [oldFeedback, setOldFeedback] = useState<{ [key: number]: string }>({}); const updateTable = async (groupId: number, feedback: Omit, usePost: boolean) => { if (!projectId || submissions === null || !groupId) return console.error("No projectId or submissions or groupId found"); @@ -72,21 +73,22 @@ const SubmissionsTable: FC<{ submissions: ProjectSubmissionsType[] | null; onCha else score = parseFloat(scoreStr); if (isNaN(score as number)) score = null; if (score !== null && score > project.maxScore) return message.error(t("project.scoreTooHigh")); - await updateTable(s.group.groupId, { score: score || null, feedback: s.feedback?.feedback ?? "" }, s.feedback === null); + await updateTable(s.group.groupId, { score: score ?? null, feedback: s.feedback?.feedback ?? "" }, s.feedback === null); + setIsEditingScore((prev) => ({ ...prev, [s.group.groupId]: false })); }; const updateFeedback = async (groupId: number) => { const feedback = editingFeedback[groupId]; if (feedback !== undefined) { const s = submissions?.find(s => s.group.groupId === groupId) - await updateTable(groupId, { feedback, score: s?.feedback?.score || null }, s?.feedback === null); + await updateTable(groupId, { feedback, score: s?.feedback?.score ?? null }, s?.feedback === null); setEditingFeedback((prev) => { const newState = { ...prev }; delete newState[groupId]; return newState; }); - setIsEditing((prev) => ({ ...prev, [groupId]: false })); } + setIsEditingFeedback((prev) => ({ ...prev, [groupId]: false })); }; const downloadFile = async (route: ApiRoutes.SUBMISSION_FILE | ApiRoutes.SUBMISSION_ARTIFACT, filename: string) => { @@ -120,9 +122,13 @@ const SubmissionsTable: FC<{ submissions: ProjectSubmissionsType[] | null; onCha }; const handleEditFeedback = (groupId: number) => { - setIsEditing((prev) => ({ ...prev, [groupId]: true })); + setIsEditingFeedback((prev) => { + setOldFeedback((prev) => ({ ...prev, [groupId]: editingFeedback[groupId] })); + return { ...prev, [groupId]: true } + }) }; + const columns: TableProps["columns"] = useMemo(() => { const cols: TableProps["columns"] = [ { @@ -173,7 +179,11 @@ const SubmissionsTable: FC<{ submissions: ProjectSubmissionsType[] | null; onCha render: (s: ProjectSubmissionsType) => ( updateScore(s, e), maxLength: 10 }} + editable={{ + onChange: (e) => updateScore(s, e), + maxLength: 10, + text: s.feedback?.score ? s.feedback?.score?.toString() : "", + }} > {s.feedback?.score ?? t("project.noScoreLabel")} @@ -208,7 +218,7 @@ const SubmissionsTable: FC<{ submissions: ProjectSubmissionsType[] | null; onCha {t("project.feedback")}:

- {isEditing[g.group.groupId] ? ( + {isEditingFeedback[g.group.groupId] ? ( <> + + - + + ) : ( <> From a1f5cdc21af3bc154e1b9fdf2395d208404a35ac Mon Sep 17 00:00:00 2001 From: Aqua-sc <108478185+Aqua-sc@users.noreply.github.com> Date: Thu, 23 May 2024 13:24:58 +0200 Subject: [PATCH 2/2] small fixes --- .../src/components/forms/projectFormTabs/DockerFormTab.tsx | 4 ++-- frontend/src/pages/project/components/SubmissionsTable.tsx | 1 - 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/frontend/src/components/forms/projectFormTabs/DockerFormTab.tsx b/frontend/src/components/forms/projectFormTabs/DockerFormTab.tsx index 77fe216b..f148e778 100644 --- a/frontend/src/components/forms/projectFormTabs/DockerFormTab.tsx +++ b/frontend/src/components/forms/projectFormTabs/DockerFormTab.tsx @@ -109,8 +109,8 @@ const DockerFormTab: FC<{ form: FormInstance }> = ({ form }) => { if (withTemplate) { switchClassName += ' template-switch-active' - scriptPlaceholder = "bash /shared/input/helloworld.sh > \"/shared/output/helloWorldTest\n"+ - "bash /shared/input/helloug.sh > \"/shared/output/helloUGent\n" + scriptPlaceholder = "bash /shared/input/helloworld.sh > \"/shared/output/helloWorldTest\"\n"+ + "bash /shared/input/helloug.sh > \"/shared/output/helloUGent\"\n" } else { switchClassName += ' template-switch-inactive' scriptPlaceholder = "output=$(bash /shared/input/helloworld.sh)\n"+ diff --git a/frontend/src/pages/project/components/SubmissionsTable.tsx b/frontend/src/pages/project/components/SubmissionsTable.tsx index 3b066efb..fc321c74 100644 --- a/frontend/src/pages/project/components/SubmissionsTable.tsx +++ b/frontend/src/pages/project/components/SubmissionsTable.tsx @@ -74,7 +74,6 @@ const SubmissionsTable: FC<{ submissions: ProjectSubmissionsType[] | null; onCha if (isNaN(score as number)) score = null; if (score !== null && score > project.maxScore) return message.error(t("project.scoreTooHigh")); await updateTable(s.group.groupId, { score: score ?? null, feedback: s.feedback?.feedback ?? "" }, s.feedback === null); - setIsEditingScore((prev) => ({ ...prev, [s.group.groupId]: false })); }; const updateFeedback = async (groupId: number) => {