diff --git a/src/app/(withAuth)/courses/[courseId]/[languageId]/[programId]/CheckpointProblem.tsx b/src/app/(withAuth)/courses/[courseId]/[languageId]/[programId]/CheckpointProblem.tsx index d7dde548..07436357 100644 --- a/src/app/(withAuth)/courses/[courseId]/[languageId]/[programId]/CheckpointProblem.tsx +++ b/src/app/(withAuth)/courses/[courseId]/[languageId]/[programId]/CheckpointProblem.tsx @@ -1,12 +1,20 @@ 'use client'; -import { useRef } from 'react'; +import { useEffect, useRef } from 'react'; import { CustomModal } from '../../../../../../components/molecules/CustomModal'; import { SyntaxHighlighter } from '../../../../../../components/organisms/SyntaxHighlighter'; import type { TurtleGraphicsHandle } from '../../../../../../components/organisms/TurtleGraphics'; import { TurtleGraphics } from '../../../../../../components/organisms/TurtleGraphics'; -import { Box, Button, Flex, HStack, useDisclosure, VStack } from '../../../../../../infrastructures/useClient/chakra'; +import { + Box, + Button, + Flex, + HStack, + Tooltip, + useDisclosure, + VStack, +} from '../../../../../../infrastructures/useClient/chakra'; import type { Problem } from '../../../../../../problems/generateProblem'; import type { ProblemType } from '../../../../../../types'; @@ -81,30 +89,64 @@ export const CheckpointProblem: React.FC = ({ } }; + useEffect(() => { + const handleKeyDown = (event: KeyboardEvent): void => { + if ((event.ctrlKey || event.metaKey) && event.key === 'Enter') { + event.preventDefault(); + handleClickAnswerButton(); + } + }; + + window.addEventListener('keydown', handleKeyDown); + + return () => { + window.removeEventListener('keydown', handleKeyDown); + }; + }, []); + return ( - - 赤線で囲まれている行における盤面を作成してください。 - 赤線で囲まれた時点の実行結果 - - - - 青色のハイライト時点の実行結果 - - - + + + 赤色にハイライトされている行における盤面を作成してください。 + + + + + + + + + + 赤線で囲われた時点の実行結果 + + + + + + + 青色のハイライト時点の実行結果 + + + + @@ -140,10 +182,6 @@ export const CheckpointProblem: React.FC = ({ /> - - - - ); diff --git a/src/app/(withAuth)/courses/[courseId]/[languageId]/[programId]/ExecutionResultProblem.tsx b/src/app/(withAuth)/courses/[courseId]/[languageId]/[programId]/ExecutionResultProblem.tsx index 0361644c..65a27bc5 100644 --- a/src/app/(withAuth)/courses/[courseId]/[languageId]/[programId]/ExecutionResultProblem.tsx +++ b/src/app/(withAuth)/courses/[courseId]/[languageId]/[programId]/ExecutionResultProblem.tsx @@ -1,12 +1,20 @@ 'use client'; -import { useRef } from 'react'; +import { useEffect, useRef } from 'react'; import { CustomModal } from '../../../../../../components/molecules/CustomModal'; import { SyntaxHighlighter } from '../../../../../../components/organisms/SyntaxHighlighter'; import type { TurtleGraphicsHandle } from '../../../../../../components/organisms/TurtleGraphics'; import { TurtleGraphics } from '../../../../../../components/organisms/TurtleGraphics'; -import { Box, Button, Flex, HStack, useDisclosure, VStack } from '../../../../../../infrastructures/useClient/chakra'; +import { + Box, + Button, + Flex, + HStack, + Tooltip, + useDisclosure, + VStack, +} from '../../../../../../infrastructures/useClient/chakra'; import type { Problem } from '../../../../../../problems/generateProblem'; import type { ProblemType } from '../../../../../../types'; @@ -66,20 +74,51 @@ export const ExecutionResultProblem: React.FC = ({ } }; + useEffect(() => { + const handleKeyDown = (event: KeyboardEvent): void => { + if ((event.ctrlKey || event.metaKey) && event.key === 'Enter') { + event.preventDefault(); + handleClickAnswerButton(); + } + }; + + window.addEventListener('keydown', handleKeyDown); + + return () => { + window.removeEventListener('keydown', handleKeyDown); + }; + }, []); + return ( - - プログラムの実行後の結果を解答してください。 + - + プログラムの実行後の結果を解答してください。 + + + + + + + + + + + + - - ); diff --git a/src/app/(withAuth)/courses/[courseId]/[languageId]/[programId]/StepProblem.tsx b/src/app/(withAuth)/courses/[courseId]/[languageId]/[programId]/StepProblem.tsx index 195a6122..eb4c281f 100644 --- a/src/app/(withAuth)/courses/[courseId]/[languageId]/[programId]/StepProblem.tsx +++ b/src/app/(withAuth)/courses/[courseId]/[languageId]/[programId]/StepProblem.tsx @@ -1,12 +1,20 @@ 'use client'; -import { useRef } from 'react'; +import { useEffect, useRef } from 'react'; import { CustomModal } from '../../../../../../components/molecules/CustomModal'; import { SyntaxHighlighter } from '../../../../../../components/organisms/SyntaxHighlighter'; import type { TurtleGraphicsHandle } from '../../../../../../components/organisms/TurtleGraphics'; import { TurtleGraphics } from '../../../../../../components/organisms/TurtleGraphics'; -import { Box, Button, Flex, HStack, useDisclosure, VStack } from '../../../../../../infrastructures/useClient/chakra'; +import { + Box, + Button, + Flex, + HStack, + Tooltip, + useDisclosure, + VStack, +} from '../../../../../../infrastructures/useClient/chakra'; import type { Problem } from '../../../../../../problems/generateProblem'; import { Variables } from './Variables'; @@ -69,30 +77,64 @@ export const StepProblem: React.FC = ({ } }; + useEffect(() => { + const handleKeyDown = (event: KeyboardEvent): void => { + if ((event.ctrlKey || event.metaKey) && event.key === 'Enter') { + event.preventDefault(); + handleClickAnswerButton(); + } + }; + + window.addEventListener('keydown', handleKeyDown); + + return () => { + window.removeEventListener('keydown', handleKeyDown); + }; + }, []); + return ( - - 赤線で囲まれている行における盤面を作成してください。 - 赤線で囲まれた時点の実行結果 - - - - 青色のハイライト時点の実行結果 - - - + + + 赤色にハイライトされている行における盤面を作成してください。 + + + + + + + + + + 赤線で囲われた時点の実行結果 + + + + + + + 青色のハイライト時点の実行結果 + + + + @@ -128,10 +170,6 @@ export const StepProblem: React.FC = ({ /> - - - - );