@@ -14,20 +14,19 @@ interface ITaskStudentCellProps {
1414
1515interface ITaskStudentCellState {
1616 isLoaded : boolean ;
17- solution ?: StatisticsCourseSolutionsModel ;
17+ lastRatedSolution ?: StatisticsCourseSolutionsModel ;
1818 redirectForMentor : boolean ;
1919 redirectForStudent : boolean ;
2020 color : string ;
2121 ratedSolutionsCount : number ;
2222}
2323
24- export default class TaskStudentCell extends React . Component < ITaskStudentCellProps ,
25- ITaskStudentCellState > {
24+ export default class StudentStatsCell extends React . Component < ITaskStudentCellProps , ITaskStudentCellState > {
2625 constructor ( props : ITaskStudentCellProps ) {
2726 super ( props ) ;
2827 this . state = {
2928 isLoaded : false ,
30- solution : { } ,
29+ lastRatedSolution : { } ,
3130 redirectForMentor : false ,
3231 redirectForStudent : false ,
3332 color : "" ,
@@ -59,10 +58,10 @@ export default class TaskStudentCell extends React.Component<ITaskStudentCellPro
5958 : this . props . userId === this . props . studentId
6059 ? ( ) => this . onStudentCellClick ( )
6160 : ( ) => 0 ;
62- const result = this . state . solution === undefined || this . state . solution . state ! === Solution . StateEnum . NUMBER_0
61+ const result = this . state . lastRatedSolution === undefined
6362 ? ""
6463 : < Stack direction = "row" spacing = { 0.3 } justifyContent = { "center" } alignItems = { "center" } >
65- < div > { this . state . solution . rating ! } </ div >
64+ < div > { this . state . lastRatedSolution . rating ! } </ div >
6665 < Chip color = { "default" } size = { "small" } label = { this . state . ratedSolutionsCount } />
6766 </ Stack >
6867 return (
@@ -102,22 +101,25 @@ export default class TaskStudentCell extends React.Component<ITaskStudentCellPro
102101
103102 async componentDidMount ( ) {
104103 const solutions = this . props . solutions
105- const ratedSolutionsCount = solutions ! . filter ( x => x . state != Solution . StateEnum . NUMBER_0 ) . length
104+ const ratedSolutions = solutions ! . filter ( x => x . state != Solution . StateEnum . NUMBER_0 )
105+ const ratedSolutionsCount = ratedSolutions . length
106106 const isFirstUnratedTry = ratedSolutionsCount === 0
107107 const lastSolution = solutions ! . slice ( - 1 ) [ 0 ]
108+ const lastRatedSolution = ratedSolutions . slice ( - 1 ) [ 0 ]
109+
108110 if ( lastSolution === undefined ) {
109111 this . setState ( {
110112 color : "" ,
111113 isLoaded : true ,
112- solution : undefined
114+ lastRatedSolution : undefined
113115 } )
114116 return
115117 }
116118 this . setState ( {
117119 color : this . getCellBackgroundColor ( lastSolution . state , isFirstUnratedTry ) ,
118120 isLoaded : true ,
119- solution : lastSolution ,
120- ratedSolutionsCount : ratedSolutionsCount
121+ lastRatedSolution : lastRatedSolution ,
122+ ratedSolutionsCount : ratedSolutions . length
121123 } )
122124 }
123125}
0 commit comments