use of de.tum.in.www1.artemis.web.rest.dto.GradeStepsDTO in project ArTEMiS by ls1intum.
the class GradeStepResource method getAllGradeStepsForExam.
/**
* GET /courses/{courseId}/exams/{examId}/grading-scale/grade-steps : Find all grade steps for the grading scale of an exam
*
* @param courseId the course to which the exam belongs
* @param examId the exam to which the grading scale belongs
* @return ResponseEntity with status 200 (Ok) with body a list of grade steps if the grading scale exists and 404 (Not found) otherwise
*/
@GetMapping("/courses/{courseId}/exams/{examId}/grading-scale/grade-steps")
@PreAuthorize("hasRole('USER')")
public ResponseEntity<GradeStepsDTO> getAllGradeStepsForExam(@PathVariable Long courseId, @PathVariable Long examId) {
log.debug("REST request to get all grade steps for exam: {}", examId);
User user = userRepository.getUserWithGroupsAndAuthorities();
Course course = courseRepository.findByIdElseThrow(courseId);
Exam exam = examRepository.findByIdElseThrow(examId);
authCheckService.checkHasAtLeastRoleInCourseElseThrow(Role.STUDENT, course, user);
GradingScale gradingScale = gradingScaleRepository.findByExamIdOrElseThrow(examId);
boolean isInstructor = authCheckService.isAtLeastInstructorInCourse(course, user);
if (!isInstructor && !exam.resultsPublished()) {
throw new AccessForbiddenException();
}
GradeStepsDTO gradeStepsDTO = prepareGradeStepsDTO(gradingScale, exam.getMaxPoints(), exam.getTitle());
return ResponseEntity.ok(gradeStepsDTO);
}
use of de.tum.in.www1.artemis.web.rest.dto.GradeStepsDTO in project Artemis by ls1intum.
the class GradeStepResource method getAllGradeStepsForCourse.
/**
* GET /courses/{courseId}/grading-scale/grade-steps : Find all grade steps for the grading scale of a course
*
* @param courseId the course to which the grading scale belongs
* @return ResponseEntity with status 200 (Ok) with body a list of grade steps if the grading scale exists and 404 (Not found) otherwise
*/
@GetMapping("/courses/{courseId}/grading-scale/grade-steps")
@PreAuthorize("hasRole('USER')")
public ResponseEntity<GradeStepsDTO> getAllGradeStepsForCourse(@PathVariable Long courseId) {
log.debug("REST request to get all grade steps for course: {}", courseId);
Course course = courseRepository.findByIdElseThrow(courseId);
GradingScale gradingScale = gradingScaleRepository.findByCourseIdOrElseThrow(courseId);
authCheckService.checkHasAtLeastRoleInCourseElseThrow(Role.STUDENT, course, null);
GradeStepsDTO gradeStepsDTO = prepareGradeStepsDTO(gradingScale, course.getMaxPoints(), course.getTitle());
return ResponseEntity.ok(gradeStepsDTO);
}
use of de.tum.in.www1.artemis.web.rest.dto.GradeStepsDTO in project Artemis by ls1intum.
the class GradeStepResource method getAllGradeStepsForExam.
/**
* GET /courses/{courseId}/exams/{examId}/grading-scale/grade-steps : Find all grade steps for the grading scale of an exam
*
* @param courseId the course to which the exam belongs
* @param examId the exam to which the grading scale belongs
* @return ResponseEntity with status 200 (Ok) with body a list of grade steps if the grading scale exists and 404 (Not found) otherwise
*/
@GetMapping("/courses/{courseId}/exams/{examId}/grading-scale/grade-steps")
@PreAuthorize("hasRole('USER')")
public ResponseEntity<GradeStepsDTO> getAllGradeStepsForExam(@PathVariable Long courseId, @PathVariable Long examId) {
log.debug("REST request to get all grade steps for exam: {}", examId);
User user = userRepository.getUserWithGroupsAndAuthorities();
Course course = courseRepository.findByIdElseThrow(courseId);
Exam exam = examRepository.findByIdElseThrow(examId);
authCheckService.checkHasAtLeastRoleInCourseElseThrow(Role.STUDENT, course, user);
GradingScale gradingScale = gradingScaleRepository.findByExamIdOrElseThrow(examId);
boolean isInstructor = authCheckService.isAtLeastInstructorInCourse(course, user);
if (!isInstructor && !exam.resultsPublished()) {
throw new AccessForbiddenException();
}
GradeStepsDTO gradeStepsDTO = prepareGradeStepsDTO(gradingScale, exam.getMaxPoints(), exam.getTitle());
return ResponseEntity.ok(gradeStepsDTO);
}
Aggregations