use of de.tum.in.www1.artemis.web.rest.dto.ExerciseScoresDTO in project Artemis by ls1intum.
the class ExerciseScoresChartResource method getCourseExerciseScores.
/**
* GET /courses/:courseId/charts/exercise-scores
* <p>
* This call returns the information used for the exercise-scores-chart. It will get the score of
* the requesting user,the average score and the best score in course exercises
* <p>
* Note: Only released course exercises with assessment due date over are considered!
* <p>
*
* @param courseId id of the course for which to get the exercise scores
* @return the ResponseEntity with status 200 (OK) and with the exercise scores in the body
*/
@GetMapping("courses/{courseId}/charts/exercise-scores")
@PreAuthorize("hasRole('USER')")
public ResponseEntity<List<ExerciseScoresDTO>> getCourseExerciseScores(@PathVariable Long courseId) {
log.debug("REST request to get exercise scores for course with id: {}", courseId);
Course course = courseRepository.findByIdWithEagerExercisesElseThrow(courseId);
User user = userRepository.getUserWithGroupsAndAuthorities();
authorizationCheckService.checkHasAtLeastRoleInCourseElseThrow(Role.STUDENT, course, user);
// we only consider exercises in which the student had a chance to earn a score (released and due date over)
List<ExerciseScoresDTO> exerciseScoresDTOList = exerciseScoresChartService.getExerciseScores(filterExercises(course.getExercises()), user);
return ResponseEntity.ok(exerciseScoresDTOList);
}
Aggregations