@@ -3,12 +3,14 @@ import TableCell from "@material-ui/core/TableCell";
33import { Redirect } from "react-router-dom" ;
44import { Solution , StatisticsCourseSolutionsModel } from "api" ;
55import { Chip , Stack } from "@mui/material" ;
6+ import { colorBetween } from "../../services/JsUtils" ;
67
78interface ITaskStudentCellProps {
89 studentId : string ;
910 taskId : number ;
1011 forMentor : boolean ;
1112 userId : string ;
13+ taskMaxRating : number ;
1214 solutions ?: StatisticsCourseSolutionsModel [ ] ;
1315}
1416
@@ -89,18 +91,19 @@ export default class StudentStatsCell extends React.Component<ITaskStudentCellPr
8991 this . setState ( { redirectForStudent : true } ) ;
9092 }
9193
92- getCellBackgroundColor = ( state : Solution . StateEnum | undefined , isFirstTry : boolean ) : string => {
94+
95+ getCellBackgroundColor = ( state : Solution . StateEnum | undefined ,
96+ rating : number | undefined , maxRating : number ,
97+ isFirstTry : boolean ) : string => {
9398 if ( state == Solution . StateEnum . NUMBER_0 )
94- return isFirstTry ? "#d0fcc7" : "#ffeb99"
95- if ( state == Solution . StateEnum . NUMBER_1 )
96- return "#ffc346"
97- if ( state == Solution . StateEnum . NUMBER_2 )
98- return "#7ad67a"
99- return "#ffffff"
99+ return isFirstTry ? "#d0fcc7" : "#afeeee"
100+ return rating !== undefined
101+ ? colorBetween ( 0xff0000 , 0x2cba00 , rating / maxRating * 100 )
102+ : "#ffffff"
100103 }
101104
102105 async componentDidMount ( ) {
103- const solutions = this . props . solutions
106+ const { solutions, taskMaxRating } = this . props
104107 const ratedSolutions = solutions ! . filter ( x => x . state != Solution . StateEnum . NUMBER_0 )
105108 const ratedSolutionsCount = ratedSolutions . length
106109 const isFirstUnratedTry = ratedSolutionsCount === 0
@@ -116,7 +119,7 @@ export default class StudentStatsCell extends React.Component<ITaskStudentCellPr
116119 return
117120 }
118121 this . setState ( {
119- color : this . getCellBackgroundColor ( lastSolution . state , isFirstUnratedTry ) ,
122+ color : this . getCellBackgroundColor ( lastSolution . state , lastSolution . rating , taskMaxRating , isFirstUnratedTry ) ,
120123 isLoaded : true ,
121124 lastRatedSolution : lastRatedSolution ,
122125 ratedSolutionsCount : ratedSolutions . length
0 commit comments