Skip to content

Commit 686f6f6

Browse files
committed
fix: gray cell instead of red cross
1 parent 3a42690 commit 686f6f6

1 file changed

Lines changed: 9 additions & 23 deletions

File tree

hwproj.front/src/components/Tasks/StudentStatsCell.tsx

Lines changed: 9 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -24,27 +24,16 @@ const StudentStatsCell: FC<ITaskStudentCellProps & { borderLeftColor?: string }>
2424
const navigate = useNavigate()
2525
const {solutions, taskMaxRating, forMentor} = props
2626

27-
const cellState = StudentStatsUtils.calculateLastRatedSolutionInfo(solutions!, taskMaxRating)
27+
const cellState = StudentStatsUtils.calculateLastRatedSolutionInfo(solutions!, taskMaxRating, props.disabled)
2828

2929
const {ratedSolutionsCount, solutionsDescription} = cellState;
3030

31-
const buildTitle = (): string => {
32-
if (props.disabled) {
33-
return "Задача недоступна для этого студента";
34-
}
35-
36-
if (ratedSolutionsCount === 0) {
37-
return solutionsDescription;
38-
}
39-
40-
const bestSolutionNote = props.isBestSolution
41-
? "\n Первое решение с лучшей оценкой"
42-
: "";
31+
const tooltipTitle = ratedSolutionsCount === 0
32+
? solutionsDescription
33+
: solutionsDescription
34+
+ (props.isBestSolution ? "\n Первое решение с лучшей оценкой" : "")
35+
+ `\n\n${Utils.pluralizeHelper(["Проверена", "Проверены", "Проверено"], ratedSolutionsCount)} ${ratedSolutionsCount} ${Utils.pluralizeHelper(["попытка", "попытки", "попыток"], ratedSolutionsCount)}`;
4336

44-
const attemptsInfo = `\n\n${Utils.pluralizeHelper(["Проверена", "Проверены", "Проверено"], ratedSolutionsCount)} ${ratedSolutionsCount} ${Utils.pluralizeHelper(["попытка", "попытки", "попыток"], ratedSolutionsCount)}`;
45-
46-
return solutionsDescription + bestSolutionNote + attemptsInfo;
47-
};
4837

4938
const result = cellState.lastRatedSolution === undefined
5039
? ""
@@ -55,6 +44,7 @@ const StudentStatsCell: FC<ITaskStudentCellProps & { borderLeftColor?: string }>
5544

5645
const handleCellClick = (e: React.MouseEvent) => {
5746
if(props.disabled) return;
47+
5848
// Формируем URL
5949
const url = forMentor
6050
? `/task/${props.taskId}/${props.studentId}`
@@ -73,7 +63,7 @@ const StudentStatsCell: FC<ITaskStudentCellProps & { borderLeftColor?: string }>
7363

7464
return (
7565
<Tooltip arrow disableInteractive enterDelay={100}
76-
title={<span style={{whiteSpace: 'pre-line'}}>{buildTitle()}</span>}>
66+
title={<span style={{whiteSpace: 'pre-line'}}>{tooltipTitle}</span>}>
7767
<TableCell
7868
onClick={handleCellClick}
7969
className={props.isBestSolution ? "glow-cell" : ""}
@@ -87,11 +77,7 @@ const StudentStatsCell: FC<ITaskStudentCellProps & { borderLeftColor?: string }>
8777
borderLeft: `1px solid ${props.borderLeftColor || grey[300]}`,
8878
cursor: props.disabled ? "default" : "pointer",
8979
}}>
90-
{props.disabled
91-
? <div className="disabled-cell">
92-
<span className="red-cross"></span>
93-
</div>
94-
: result}
80+
{result}
9581
</TableCell>
9682
</Tooltip>
9783
);

0 commit comments

Comments
 (0)