diff --git a/frontend/src/App.tsx b/frontend/src/App.tsx index 5ebe479..a73642f 100644 --- a/frontend/src/App.tsx +++ b/frontend/src/App.tsx @@ -6,6 +6,7 @@ import { BrowserRouter, Route, Routes } from 'react-router-dom' import AttemptResult from './pages/AttemptResult' import TestCreate from './pages/TestCreate' import TestDetail from './pages/TestDetail' +import TestEdit from './pages/TestEdit' import TestList from './pages/TestList' import TestTake from './pages/TestTake' @@ -20,6 +21,7 @@ export default function App() { } /> } /> } /> + } /> } /> } /> diff --git a/frontend/src/pages/TestDetail/index.tsx b/frontend/src/pages/TestDetail/index.tsx index 61dde1a..306b8ab 100644 --- a/frontend/src/pages/TestDetail/index.tsx +++ b/frontend/src/pages/TestDetail/index.tsx @@ -1,4 +1,4 @@ -import { ArrowLeftOutlined, CheckCircleTwoTone, CloseCircleTwoTone, PlayCircleOutlined } from '@ant-design/icons' +import { ArrowLeftOutlined, PlayCircleOutlined } from '@ant-design/icons' import { useQuery } from '@tanstack/react-query' import { Button, Card, Descriptions, List, Space, Spin, Tag, Typography } from 'antd' import { useNavigate, useParams } from 'react-router-dom' @@ -78,14 +78,7 @@ export default function TestDetail() { dataSource={question.answers} renderItem={(answer: Answer) => ( - - {answer.is_correct ? ( - - ) : ( - - )} - {answer.text} - + {answer.text} )} /> diff --git a/frontend/src/pages/TestEdit/index.tsx b/frontend/src/pages/TestEdit/index.tsx new file mode 100644 index 0000000..af03f13 --- /dev/null +++ b/frontend/src/pages/TestEdit/index.tsx @@ -0,0 +1,118 @@ +import { + ArrowLeftOutlined, + CheckCircleTwoTone, + CloseCircleTwoTone, + EditOutlined, + PlayCircleOutlined, +} from '@ant-design/icons' +import { useQuery } from '@tanstack/react-query' +import { Alert, Button, Card, Descriptions, List, Space, Spin, Tag, Typography } from 'antd' +import { useNavigate, useParams } from 'react-router-dom' + +import { Answer, testsApi } from '../../api/tests' + +const { Title, Text } = Typography + +export default function TestEdit() { + const { id } = useParams<{ id: string }>() + const navigate = useNavigate() + + const { data: test, isLoading } = useQuery({ + queryKey: ['tests', id], + queryFn: () => testsApi.get(Number(id)).then((r) => r.data), + }) + + if (isLoading) { + return + } + + if (!test) return null + + return ( +
+ + + + + + + + + + + {test.title} + + {test.description && ( + + {test.description} + + )} + + + + {test.questions.length} + {test.passing_score}% + + {test.time_limit ? `${test.time_limit} мин` : 'Без ограничений'} + + + {test.allow_navigation_back ? ( + Разрешён + ) : ( + Запрещён + )} + + {test.version} + + {new Date(test.created_at).toLocaleDateString('ru-RU')} + + + + + Вопросы ({test.questions.length}) + + {test.questions.map((question, index) => ( + + + {index + 1}. {question.text} + + ( + + + {answer.is_correct ? ( + + ) : ( + + )} + {answer.text} + + + )} + /> + + ))} +
+ ) +} diff --git a/frontend/src/pages/TestList/index.tsx b/frontend/src/pages/TestList/index.tsx index 4658647..39cfcb0 100644 --- a/frontend/src/pages/TestList/index.tsx +++ b/frontend/src/pages/TestList/index.tsx @@ -1,4 +1,4 @@ -import { PlayCircleOutlined, PlusOutlined } from '@ant-design/icons' +import { EditOutlined, PlayCircleOutlined, PlusOutlined } from '@ant-design/icons' import { useQuery } from '@tanstack/react-query' import { Button, Space, Spin, Table, Tag, Typography } from 'antd' import type { ColumnsType } from 'antd/es/table' @@ -64,6 +64,13 @@ export default function TestList() { +