|
| 1 | +import { FC } from "react"; |
| 2 | +import { useNavigate } from "react-router-dom"; |
| 3 | +import { |
| 4 | + Box, |
| 5 | + Typography, |
| 6 | + Card, |
| 7 | + CardContent, |
| 8 | + Button, |
| 9 | + Chip, |
| 10 | + Stack, |
| 11 | + Alert, |
| 12 | +} from "@mui/material"; |
| 13 | +import { |
| 14 | + Quiz as QuizIcon, |
| 15 | + PlayArrow as PlayIcon, |
| 16 | + EmojiEvents as TrophyIcon, |
| 17 | +} from "@mui/icons-material"; |
| 18 | + |
| 19 | +import { TestGroupDto } from "api/graphql/generated/graphql"; |
| 20 | + |
| 21 | +interface LectureTestSectionProps { |
| 22 | + testGroup: TestGroupDto; |
| 23 | + trainingId?: string; |
| 24 | + lectureId?: string; |
| 25 | +} |
| 26 | + |
| 27 | +const LectureTestSection: FC<LectureTestSectionProps> = ({ |
| 28 | + testGroup, |
| 29 | + trainingId, |
| 30 | + lectureId, |
| 31 | +}) => { |
| 32 | + const navigate = useNavigate(); |
| 33 | + |
| 34 | + const handleStartTest = () => { |
| 35 | + // Проверяем наличие всех необходимых параметров |
| 36 | + if (!testGroup?.id || !trainingId || !lectureId) { |
| 37 | + console.error("Missing required parameters for test navigation:", { |
| 38 | + testId: testGroup?.id, |
| 39 | + trainingId, |
| 40 | + lectureId, |
| 41 | + }); |
| 42 | + return; |
| 43 | + } |
| 44 | + |
| 45 | + // Переходим на страницу теста с параметрами |
| 46 | + navigate(`/test/${testGroup.id}/${trainingId}/${lectureId}`); |
| 47 | + }; |
| 48 | + |
| 49 | + return ( |
| 50 | + <Box sx={{ my: 4 }}> |
| 51 | + <Typography |
| 52 | + variant="h4" |
| 53 | + gutterBottom |
| 54 | + sx={{ display: "flex", alignItems: "center", gap: 1 }} |
| 55 | + > |
| 56 | + <QuizIcon color="primary" /> |
| 57 | + Тест по лекции |
| 58 | + </Typography> |
| 59 | + |
| 60 | + <Card elevation={3}> |
| 61 | + <CardContent> |
| 62 | + <Box sx={{ mb: 3 }}> |
| 63 | + <Typography variant="h5" gutterBottom> |
| 64 | + {testGroup.testName} |
| 65 | + </Typography> |
| 66 | + |
| 67 | + <Stack direction="row" spacing={2} sx={{ mb: 2 }}> |
| 68 | + <Chip |
| 69 | + icon={<TrophyIcon />} |
| 70 | + label={`Проходной балл: ${testGroup.successThreshold}%`} |
| 71 | + color="primary" |
| 72 | + variant="outlined" |
| 73 | + /> |
| 74 | + <Chip |
| 75 | + label={`Вопросов: ${testGroup.testQuestions?.length || 0}`} |
| 76 | + variant="outlined" |
| 77 | + /> |
| 78 | + </Stack> |
| 79 | + </Box> |
| 80 | + |
| 81 | + <Alert severity="info" sx={{ mb: 3 }}> |
| 82 | + <Typography variant="body2"> |
| 83 | + Пройдите тест, чтобы закрепить изученный материал. Для успешного |
| 84 | + прохождения необходимо набрать минимум{" "} |
| 85 | + {testGroup.successThreshold}% правильных ответов. |
| 86 | + </Typography> |
| 87 | + </Alert> |
| 88 | + |
| 89 | + <Box sx={{ display: "flex", justifyContent: "center" }}> |
| 90 | + <Button |
| 91 | + variant="contained" |
| 92 | + size="large" |
| 93 | + startIcon={<PlayIcon />} |
| 94 | + onClick={handleStartTest} |
| 95 | + sx={{ |
| 96 | + py: 1.5, |
| 97 | + px: 4, |
| 98 | + fontSize: "1.1rem", |
| 99 | + }} |
| 100 | + > |
| 101 | + Начать тестирование |
| 102 | + </Button> |
| 103 | + </Box> |
| 104 | + </CardContent> |
| 105 | + </Card> |
| 106 | + </Box> |
| 107 | + ); |
| 108 | +}; |
| 109 | + |
| 110 | +export default LectureTestSection; |
0 commit comments