Skip to content

Commit 7e3cdc1

Browse files
committed
TaskSolutionComponent: возможность показать текст решения без форматирования
1 parent b402b22 commit 7e3cdc1

1 file changed

Lines changed: 25 additions & 4 deletions

File tree

hwproj.front/src/components/Solutions/TaskSolutionComponent.tsx

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@ import StudentStatsUtils from "../../services/StudentStatsUtils";
2626
import {StudentCharacteristics} from "@/components/Students/StudentCharacteristics";
2727
import KeyboardCommandKeyIcon from '@mui/icons-material/KeyboardCommandKey';
2828
import MouseOutlinedIcon from '@mui/icons-material/MouseOutlined';
29+
import HdrStrongIcon from '@mui/icons-material/HdrStrong';
30+
import BlurOnIcon from '@mui/icons-material/BlurOn';
31+
import BlurOffIcon from '@mui/icons-material/BlurOff';
2932

3033
interface ISolutionProps {
3134
courseId: number,
@@ -59,6 +62,7 @@ const TaskSolutionComponent: FC<ISolutionProps> = (props) => {
5962
}
6063

6164
const [state, setState] = useState<ISolutionState>(getDefaultState)
65+
const [showOriginalCommentText, setShowOriginalCommentText] = useState<boolean>(false)
6266
const [achievement, setAchievementState] = useState<number | undefined>(undefined)
6367
const [rateInProgress, setRateInProgressState] = useState<boolean | undefined>(false)
6468
const [solutionActuality, setSolutionActuality] = useState<SolutionActualityDto | undefined>(undefined)
@@ -70,6 +74,7 @@ const TaskSolutionComponent: FC<ISolutionProps> = (props) => {
7074
getAchievementState()
7175
setRateInProgressState(false)
7276
getActuality()
77+
setShowOriginalCommentText(false)
7378
}, [props.student.userId, props.task.id, props.solution?.id, props.solution?.rating])
7479

7580
const [isCtrlPressed, setIsCtrlPressed] = useState(false)
@@ -470,15 +475,31 @@ const TaskSolutionComponent: FC<ISolutionProps> = (props) => {
470475
? renderTestsStatus(solutionActuality.testsActuality)
471476
: <CircularProgress size={12}/>)}
472477
</Stack>
473-
<Typography variant={"caption"} style={{color: "GrayText"}}>
474-
{postedSolutionTime} {solution.isModified && "(отредактировано)"}
475-
</Typography>
478+
<Stack direction={"row"} alignItems={"baseline"} spacing={1}>
479+
<Typography variant={"caption"} style={{color: "GrayText"}}>
480+
{postedSolutionTime} {solution.isModified && "(отредактировано)"}
481+
</Typography>
482+
{solution?.comment &&
483+
<Tooltip arrow placement={"right"}
484+
title={<div>
485+
{showOriginalCommentText ? "Показать отформатированный текст решения" : "Показать оригинальный текст решения"}
486+
</div>}>
487+
<div style={{cursor: "pointer", marginTop: -2}}
488+
onClick={() => setShowOriginalCommentText(!showOriginalCommentText)}>
489+
{showOriginalCommentText
490+
? <BlurOffIcon style={{fontSize: 14}} color={"inherit"}/>
491+
: <BlurOnIcon style={{fontSize: 14}} color={"inherit"}/>}
492+
</div>
493+
</Tooltip>}
494+
</Stack>
476495
</Grid>
477496
</Stack>
478497
</Grid>
479498
{solution.comment &&
480499
<Grid item style={{marginBottom: -16}}>
481-
<MarkdownPreview value={solution.comment}/>
500+
{showOriginalCommentText
501+
? <Typography style={{marginBottom: 15}}>{solution.comment}</Typography>
502+
: <MarkdownPreview value={solution.comment}/>}
482503
</Grid>
483504
}
484505
</Grid>

0 commit comments

Comments
 (0)