Skip to content

Commit 71f432d

Browse files
committed
StudentsRadarChart: улучшения
1 parent 6f1b9a5 commit 71f432d

2 files changed

Lines changed: 25 additions & 22 deletions

File tree

hwproj.front/src/components/Courses/Statistics/StudentStatsChart.tsx

Lines changed: 6 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import {
66
HomeworkViewModel, StatisticsCourseHomeworksModel,
77
StatisticsCourseMatesModel,
88
StatisticsCourseMeasureSolutionModel
9-
} from "../../../api/";
9+
} from "@/api";
1010
import ApiSingleton from "../../../api/ApiSingleton";
1111
import HelpPopoverChartInfo from './HelpPopoverChartInfo';
1212
import StudentCheckboxList from "./StudentCheckboxList";
@@ -15,6 +15,7 @@ import StudentPunctualityChart from './StudentPunctualityChart';
1515
import NameBuilder from "../../Utils/NameBuilder";
1616
import {DotLottieReact} from "@lottiefiles/dotlottie-react";
1717
import { StudentsRadarChart } from "./StudentsRadarChart";
18+
import {appBarStateManager} from "@/components/AppBar";
1819

1920
interface IStudentStatsChartState {
2021
isFound: boolean;
@@ -87,6 +88,8 @@ const StudentStatsChart: React.FC = () => {
8788

8889
useEffect(() => {
8990
setCurrentState()
91+
appBarStateManager.setContextAction({actionName: "К курсу", link: `/courses/${courseId}/stats`})
92+
return () => appBarStateManager.reset()
9093
}, [])
9194

9295
useEffect(() => {
@@ -100,19 +103,6 @@ const StudentStatsChart: React.FC = () => {
100103
return student.name + ' ' + student.surname;
101104
}
102105

103-
const renderGoBackToCoursesStatsLink = () => {
104-
return (
105-
<Link
106-
to={`/courses/${state.course.id}/stats`}
107-
style={{color: '#212529'}}
108-
>
109-
<Typography>
110-
Назад к курсу
111-
</Typography>
112-
</Link>
113-
)
114-
}
115-
116106
const tasks = state.homeworks.flatMap(h => h.tasks ?? [])
117107
const tasksAmount = tasks.length
118108
const tasksWithDeadlineAmount = state.tasksWithDeadline.length
@@ -139,9 +129,6 @@ const StudentStatsChart: React.FC = () => {
139129
<sup style={{color: "#2979ff"}}> бета</sup>
140130
</Typography>
141131
</Grid>
142-
<Grid item>
143-
{isLoggedIn && renderGoBackToCoursesStatsLink()}
144-
</Grid>
145132
</Grid>
146133
{state.isSelectionMode &&
147134
<Grid item>
@@ -161,6 +148,8 @@ const StudentStatsChart: React.FC = () => {
161148
selectedStudents={selectedStudents}
162149
homeworks={state.homeworks}
163150
solutions={state.solutions}
151+
averageStudent={state.averageStudent}
152+
164153
/>
165154
</Grid>}
166155
<Grid xs={12} item>

hwproj.front/src/components/Courses/Statistics/StudentsRadarChart.tsx

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,25 @@
1-
import {HomeworkViewModel, StatisticsCourseMatesModel} from "@/api";
1+
import {HomeworkViewModel, StatisticsCourseMatesModel, StatisticsCourseMeasureSolutionModel} from "@/api";
22
import {Unstable_RadarChart as RadarChart} from '@mui/x-charts/RadarChart';
33
import {FC} from "react";
44
import StudentStatsUtils from "@/services/StudentStatsUtils";
55

66
export const StudentsRadarChart: FC<{
77
selectedStudents: string[],
88
homeworks: HomeworkViewModel[],
9-
solutions: StatisticsCourseMatesModel[]
9+
solutions: StatisticsCourseMatesModel[],
10+
averageStudent: StatisticsCourseMeasureSolutionModel[]
1011
}> = (props) => {
11-
const metrics = props.homeworks
12+
const homeworks = props.homeworks
13+
.filter(h => h.tasks!.length > 0)
14+
15+
const metrics = homeworks
1216
.map(x => ({
1317
name: x.title! + `[id${x.id!}]`,
1418
id: x.id!,
1519
max: x.tasks!
1620
.map(x => x.maxRating!)
1721
.reduce((a, b) => a + b)
1822
}))
19-
.filter(x => x.max > 0)
2023

2124
const series = props.solutions
2225
.filter(x => props.selectedStudents.includes(x.id!))
@@ -30,8 +33,19 @@ export const StudentsRadarChart: FC<{
3033
.reduce((a, b) => a + b))
3134
}))
3235

36+
const averageStudent = {
37+
label: "Средний студент",
38+
fillArea: true,
39+
data: homeworks
40+
.map(h => h.tasks!
41+
.map(t => props.averageStudent.find(y => y.taskId === t.id)?.rating || 0)
42+
.reduce((a, b) => a + b))
43+
}
44+
45+
series.push(averageStudent)
46+
3347
return <RadarChart
34-
height={400}
48+
height={400 + (homeworks.length > 10 ? (homeworks.length - 10) * 10 : 0)}
3549
series={series}
3650
radar={{
3751
metrics,

0 commit comments

Comments
 (0)