From ef857c261810f37e5e86ae50c60605b4b9238698 Mon Sep 17 00:00:00 2001 From: "Sakamoto, Kazunori" Date: Thu, 26 Sep 2024 13:52:57 +0900 Subject: [PATCH] =?UTF-8?q?feat:=20=E4=B8=80=E7=99=BA=E8=A7=A3=E7=AD=94?= =?UTF-8?q?=E3=83=A2=E3=83=BC=E3=83=89=E3=81=AB3=E5=9B=9E=E6=8C=91?= =?UTF-8?q?=E6=88=A6=E3=81=A7=E3=81=8D=E3=82=8B=E3=82=88=E3=81=86=E3=81=AB?= =?UTF-8?q?=E3=81=99=E3=82=8B=20(#156)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../[courseId]/lectures/[lectureId]/page.tsx | 3 +- .../lectures/[lectureId]/pageOnClient.tsx | 4 +- .../problems/[problemId]/BoardEditor.tsx | 3 +- .../problems/[problemId]/ProblmBody.tsx | 55 +++++++++++++++---- src/constants.ts | 2 + .../trpcBackend/routers/index.ts | 16 ++++++ 6 files changed, 66 insertions(+), 17 deletions(-) diff --git a/src/app/(withAuth)/courses/[courseId]/lectures/[lectureId]/page.tsx b/src/app/(withAuth)/courses/[courseId]/lectures/[lectureId]/page.tsx index ea7f2995..f904ab0b 100644 --- a/src/app/(withAuth)/courses/[courseId]/lectures/[lectureId]/page.tsx +++ b/src/app/(withAuth)/courses/[courseId]/lectures/[lectureId]/page.tsx @@ -25,8 +25,7 @@ const LecturePage: NextPage = async (props) => { select: { problemId: true, completedAt: true, - elapsedMilliseconds: true, - submissions: { select: { elapsedMilliseconds: true, isCorrect: true } }, + submissions: { select: { isCorrect: true } }, }, where: { userId: session.superTokensUserId, courseId: props.params.courseId, lectureId: props.params.lectureId }, }); diff --git a/src/app/(withAuth)/courses/[courseId]/lectures/[lectureId]/pageOnClient.tsx b/src/app/(withAuth)/courses/[courseId]/lectures/[lectureId]/pageOnClient.tsx index b6ea3add..ac4e7242 100644 --- a/src/app/(withAuth)/courses/[courseId]/lectures/[lectureId]/pageOnClient.tsx +++ b/src/app/(withAuth)/courses/[courseId]/lectures/[lectureId]/pageOnClient.tsx @@ -35,8 +35,8 @@ import { type Props = { params: { courseId: CourseId; lectureId: string }; lectureIndex: number; - problemSessions: (Pick & { - submissions: Pick[]; + problemSessions: (Pick & { + submissions: Pick[]; })[]; }; diff --git a/src/app/(withAuth)/courses/[courseId]/lectures/[lectureId]/problems/[problemId]/BoardEditor.tsx b/src/app/(withAuth)/courses/[courseId]/lectures/[lectureId]/problems/[problemId]/BoardEditor.tsx index 1b98bda6..25676647 100644 --- a/src/app/(withAuth)/courses/[courseId]/lectures/[lectureId]/problems/[problemId]/BoardEditor.tsx +++ b/src/app/(withAuth)/courses/[courseId]/lectures/[lectureId]/problems/[problemId]/BoardEditor.tsx @@ -236,12 +236,13 @@ export const BoardEditor = forwardRef onClick={() => handleTurnTurtle(false)} /> - + + + )} -
+ {problemType === 'executionResult' ? ( 'プログラムを実行した後' @@ -139,7 +170,7 @@ export const ProblemBody: React.FC = (props) => { )} の盤面を作成し、提出ボタンを押してください。 -
+ = (props) => { colorScheme="brand" rightIcon={ - {isMacOS ? 'Cmd + Enter' : 'Ctrl + Enter'} + (Enter) } onClick={() => handleClickSubmitButton()} @@ -254,7 +285,7 @@ export const ProblemBody: React.FC = (props) => { function useShortcutKeys(handleClickAnswerButton: () => Promise): void { useEffect(() => { const handleKeyDown = (event: KeyboardEvent): void => { - if ((event.ctrlKey || event.metaKey) && event.key === 'Enter') { + if (event.key === 'Enter') { event.preventDefault(); void handleClickAnswerButton(); } diff --git a/src/constants.ts b/src/constants.ts index d6b8eeb7..966aa64a 100644 --- a/src/constants.ts +++ b/src/constants.ts @@ -16,6 +16,8 @@ export const SUPERTOKENS_ACCESS_TOKEN_COOKIE_NAME = 'sAccessToken'; export const SUPERTOKENS_REFRESH_TOKEN_COOKIE_NAME = 'sRefreshToken'; export const SERVICE_ADMIN_ROLE = 'admin'; +export const MAX_CHALLENGE_COUNT = 3; + /** * 最後のイベントから今回のイベント発生時の期間において、アクティブと解釈される最大時間。 */ diff --git a/src/infrastructures/trpcBackend/routers/index.ts b/src/infrastructures/trpcBackend/routers/index.ts index 5765b7c5..08ac3300 100644 --- a/src/infrastructures/trpcBackend/routers/index.ts +++ b/src/infrastructures/trpcBackend/routers/index.ts @@ -57,6 +57,22 @@ export const backendRouter = router({ await prisma.problemSubmission.create({ data: input }); }), + + countIncorrectSubmissions: procedure + .use(authorize) + .input( + z.object({ + sessionId: z.number().int().positive(), + }) + ) + .query(async ({ input }) => { + return await prisma.problemSubmission.count({ + where: { + sessionId: input.sessionId, + isCorrect: false, + }, + }); + }), }); // export type definition of API