1111using HwProj . Models . CoursesService . ViewModels ;
1212using HwProj . Models . Roles ;
1313using HwProj . Models . SolutionsService ;
14- using HwProj . Models . StatisticsService ;
1514using HwProj . SolutionsService . Client ;
1615using Microsoft . AspNetCore . Authorization ;
1716using Microsoft . AspNetCore . Mvc ;
@@ -136,47 +135,6 @@ public async Task<IActionResult> GetTaskSolutionsPageData(long taskId)
136135 return Ok ( result ) ;
137136 }
138137
139- [ Authorize ]
140- [ HttpGet ( "tasks/{taskId}" ) ]
141- [ ProducesResponseType ( typeof ( TaskSolutionStatisticsPageData ) , ( int ) HttpStatusCode . OK ) ]
142- public async Task < IActionResult > GetTaskSolutionsPageData ( long taskId )
143- {
144- var course = await _coursesServiceClient . GetCourseByTask ( taskId ) ;
145- //TODO: CourseMentorOnlyAttribute
146- if ( course == null || ! course . MentorIds . Contains ( UserId ) ) return Forbid ( ) ;
147-
148- var studentIds = course . CourseMates
149- . Where ( t => t . IsAccepted )
150- . Select ( t => t . StudentId )
151- . ToArray ( ) ;
152-
153- var getStudentsDataTask = AuthServiceClient . GetAccountsData ( studentIds ) ;
154- var getStatisticsTask = _solutionsClient . GetTaskSolutionStatistics ( taskId ) ;
155-
156- await Task . WhenAll ( getStudentsDataTask , getStatisticsTask ) ;
157-
158- var usersData = getStudentsDataTask . Result ;
159- var statistics = getStatisticsTask . Result ;
160- var statisticsDict = statistics . ToDictionary ( t => t . StudentId ) ;
161-
162- var result = new TaskSolutionStatisticsPageData ( )
163- {
164- CourseId = course . Id ,
165- StudentsSolutions = studentIds . Zip ( usersData , ( studentId , accountData ) => new UserTaskSolutions
166- {
167- Solutions = statisticsDict . TryGetValue ( studentId , out var studentSolutions )
168- ? studentSolutions . Solutions
169- : Array . Empty < Solution > ( ) ,
170- User = accountData
171- } )
172- . OrderBy ( t => t . User . Surname )
173- . ThenBy ( t => t . User . Name )
174- . ToArray ( )
175- } ;
176-
177- return Ok ( result ) ;
178- }
179-
180138 [ HttpPost ( "{taskId}" ) ]
181139 [ Authorize ( Roles = Roles . StudentRole ) ]
182140 [ ProducesResponseType ( typeof ( long ) , ( int ) HttpStatusCode . OK ) ]
@@ -232,19 +190,6 @@ public async Task<IActionResult> PostEmptySolutionWithRate(long taskId, Solution
232190 return Ok ( ) ;
233191 }
234192
235- [ HttpPost ( "rateEmptySolution/{taskId}" ) ]
236- [ Authorize ( Roles = Roles . LecturerRole ) ]
237- public async Task < IActionResult > PostEmptySolutionWithRate ( long taskId , SolutionViewModel model )
238- {
239- var course = await _coursesServiceClient . GetCourseByTask ( taskId ) ;
240- if ( course == null || ! course . MentorIds . Contains ( UserId ) ) return Forbid ( ) ;
241- if ( course . CourseMates . All ( t => t . StudentId != model . StudentId ) )
242- return BadRequest ( $ "Студента с id { model . StudentId } не существует") ;
243-
244- await _solutionsClient . PostEmptySolutionWithRate ( taskId , model ) ;
245- return Ok ( ) ;
246- }
247-
248193 [ HttpPost ( "rateSolution/{solutionId}/{newRating}" ) ]
249194 [ Authorize ( Roles = Roles . LecturerRole ) ]
250195 public async Task < IActionResult > RateSolution ( long solutionId , int newRating ,
@@ -328,4 +273,4 @@ public async Task<UnratedSolutionPreviews> GetUnratedSolutions(long? taskId)
328273 }
329274 }
330275 }
331- }
276+ }
0 commit comments