Skip to content

Commit e1aa2f0

Browse files
committed
wip
1 parent 03b1cf9 commit e1aa2f0

1 file changed

Lines changed: 26 additions & 8 deletions

File tree

hwproj.front/src/components/Courses/StudentStats.tsx

Lines changed: 26 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import {CourseViewModel, GroupViewModel, HomeworkViewModel, StatisticsCourseMate
33
import {useNavigate, useParams} from 'react-router-dom';
44
import {LinearProgress, Table, TableBody, TableCell, TableContainer, TableHead, TableRow} from "@material-ui/core";
55
import StudentStatsCell from "../Tasks/StudentStatsCell";
6-
import {Alert, Button, Chip, IconButton, Typography} from "@mui/material";
6+
import {Alert, Button, Chip, IconButton, Stack, Typography} from "@mui/material";
77
import {grey} from "@material-ui/core/colors";
88
import StudentStatsUtils from "../../services/StudentStatsUtils";
99
import ShowChartIcon from "@mui/icons-material/ShowChart";
@@ -12,6 +12,7 @@ import Lodash from "lodash"
1212
import ApiSingleton from "@/api/ApiSingleton";
1313
import FullscreenIcon from '@mui/icons-material/Fullscreen';
1414
import FullscreenExitIcon from '@mui/icons-material/FullscreenExit';
15+
import GroupIcon from '@mui/icons-material/Group';
1516

1617
interface IStudentStatsProps {
1718
course: CourseViewModel;
@@ -116,7 +117,7 @@ const StudentStats: React.FC<IStudentStatsProps> = (props) => {
116117
const testsMaxSum = testGroups
117118
.map(h => h[0])
118119
.flatMap(homework => homework.tasks)
119-
.reduce((sum, task) =>
120+
.reduce((sum, task) =>
120121
sum + (task!.tags!.includes(BonusTag) ? 0 : (task!.maxRating || 0)), 0)
121122

122123
const hasHomeworks = !!notTests
@@ -257,12 +258,12 @@ const StudentStats: React.FC<IStudentStatsProps> = (props) => {
257258
)
258259
.reduce((sum, rating) => sum + rating, 0)
259260
const homeworksMaxSum = notTests
260-
.filter(h => !h.tags!.includes(BonusTag) &&
261-
(props.groups.find(g => g.id === h.groupId)?.studentsIds?.includes(cm.id!) || !h.groupId))
262-
.flatMap(homework => homework.tasks)
263-
.reduce((sum, task) => {
264-
return sum + (task!.tags!.includes(BonusTag) ? 0 : (task!.maxRating || 0));
265-
}, 0)
261+
.filter(h => !h.tags!.includes(BonusTag) &&
262+
(props.groups.find(g => g.id === h.groupId)?.studentsIds?.includes(cm.id!) || !h.groupId))
263+
.flatMap(homework => homework.tasks)
264+
.reduce((sum, task) => {
265+
return sum + (task!.tags!.includes(BonusTag) ? 0 : (task!.maxRating || 0));
266+
}, 0)
266267

267268
const testsSum = testGroups
268269
.map(group => {
@@ -285,6 +286,8 @@ const StudentStats: React.FC<IStudentStatsProps> = (props) => {
285286
.filter(x => x === cm.id)
286287
.toArray().length
287288

289+
const studentGroups = props.groups.filter(x => x.studentsIds!.includes(cm.id!))
290+
288291
return (
289292
<TableRow key={index} hover style={{height: 50}}>
290293
<TableCell
@@ -296,6 +299,21 @@ const StudentStats: React.FC<IStudentStatsProps> = (props) => {
296299
variant={"head"}
297300
>
298301
{cm.surname} {cm.name}
302+
{studentGroups.length > 0 && <Typography
303+
gutterBottom
304+
style={{
305+
color: "GrayText",
306+
fontSize: "12px",
307+
lineHeight: '1.2'
308+
}}
309+
>
310+
<Stack direction="row" spacing={1}>
311+
<GroupIcon style={{fontSize: "12px"}}/>
312+
<div>{studentGroups
313+
.map(r => r.name)
314+
.join(', ')}</div>
315+
</Stack>
316+
</Typography>}
299317
<Typography
300318
style={{
301319
color: "GrayText",

0 commit comments

Comments
 (0)