use of de.tum.in.www1.artemis.web.rest.dto.GradeStepsDTO in project ArTEMiS by ls1intum.
the class GradeStepIntegrationTest method testGetAllGradeStepsForCourse.
/**
* Test get request for all grade steps
*
* @throws Exception
*/
@Test
@WithMockUser(username = "student1", roles = "USER")
public void testGetAllGradeStepsForCourse() throws Exception {
createGradeScale();
GradeStepsDTO gradeStepsDTO = request.get("/api/courses/" + course.getId() + "/grading-scale/grade-steps", HttpStatus.OK, GradeStepsDTO.class);
assertThat(gradeStepsDTO.gradeType).isEqualTo(GradeType.GRADE);
assertThat(gradeStepsDTO.title).isEqualTo(course.getTitle());
assertThat(gradeStepsDTO.gradeSteps).usingRecursiveComparison().ignoringFields("gradingScale", "id").ignoringCollectionOrder().isEqualTo(gradeSteps);
}
use of de.tum.in.www1.artemis.web.rest.dto.GradeStepsDTO in project ArTEMiS by ls1intum.
the class GradeStepIntegrationTest method testGetAllGradeStepsForExam.
/**
* Test get request for all grade steps
*
* @throws Exception
*/
@Test
@WithMockUser(username = "student1", roles = "USER")
public void testGetAllGradeStepsForExam() throws Exception {
exam.setPublishResultsDate(ZonedDateTime.now());
examRepository.save(exam);
GradeStep gradeStep1 = new GradeStep();
GradeStep gradeStep2 = new GradeStep();
gradeStep1.setGradeName("Name1");
gradeStep2.setGradeName("Name2");
gradeStep1.setLowerBoundPercentage(0);
gradeStep1.setUpperBoundPercentage(60);
gradeStep2.setUpperBoundInclusive(true);
gradeStep2.setLowerBoundPercentage(60);
gradeStep2.setUpperBoundPercentage(100);
gradeStep1.setGradingScale(examGradingScale);
gradeStep2.setGradingScale(examGradingScale);
gradeSteps = Set.of(gradeStep1, gradeStep2);
examGradingScale.setGradeSteps(gradeSteps);
examGradingScale.setGradeType(GradeType.BONUS);
gradingScaleRepository.save(examGradingScale);
GradeStepsDTO gradeStepsDTO = request.get("/api/courses/" + course.getId() + "/exams/" + exam.getId() + "/grading-scale/grade-steps", HttpStatus.OK, GradeStepsDTO.class);
assertThat(gradeStepsDTO.gradeType).isEqualTo(GradeType.BONUS);
assertThat(gradeStepsDTO.title).isEqualTo(exam.getTitle());
assertThat(gradeStepsDTO.gradeSteps).usingRecursiveComparison().ignoringFields("gradingScale", "id").ignoringCollectionOrder().isEqualTo(gradeSteps);
}
use of de.tum.in.www1.artemis.web.rest.dto.GradeStepsDTO in project Artemis by ls1intum.
the class GradeStepIntegrationTest method testGetAllGradeStepsForExam.
/**
* Test get request for all grade steps
*
* @throws Exception
*/
@Test
@WithMockUser(username = "student1", roles = "USER")
public void testGetAllGradeStepsForExam() throws Exception {
exam.setPublishResultsDate(ZonedDateTime.now());
examRepository.save(exam);
GradeStep gradeStep1 = new GradeStep();
GradeStep gradeStep2 = new GradeStep();
gradeStep1.setGradeName("Name1");
gradeStep2.setGradeName("Name2");
gradeStep1.setLowerBoundPercentage(0);
gradeStep1.setUpperBoundPercentage(60);
gradeStep2.setUpperBoundInclusive(true);
gradeStep2.setLowerBoundPercentage(60);
gradeStep2.setUpperBoundPercentage(100);
gradeStep1.setGradingScale(examGradingScale);
gradeStep2.setGradingScale(examGradingScale);
gradeSteps = Set.of(gradeStep1, gradeStep2);
examGradingScale.setGradeSteps(gradeSteps);
examGradingScale.setGradeType(GradeType.BONUS);
gradingScaleRepository.save(examGradingScale);
GradeStepsDTO gradeStepsDTO = request.get("/api/courses/" + course.getId() + "/exams/" + exam.getId() + "/grading-scale/grade-steps", HttpStatus.OK, GradeStepsDTO.class);
assertThat(gradeStepsDTO.gradeType).isEqualTo(GradeType.BONUS);
assertThat(gradeStepsDTO.title).isEqualTo(exam.getTitle());
assertThat(gradeStepsDTO.gradeSteps).usingRecursiveComparison().ignoringFields("gradingScale", "id").ignoringCollectionOrder().isEqualTo(gradeSteps);
}
use of de.tum.in.www1.artemis.web.rest.dto.GradeStepsDTO in project Artemis by ls1intum.
the class GradeStepIntegrationTest method testGetAllGradeStepsForCourse.
/**
* Test get request for all grade steps
*
* @throws Exception
*/
@Test
@WithMockUser(username = "student1", roles = "USER")
public void testGetAllGradeStepsForCourse() throws Exception {
createGradeScale();
GradeStepsDTO gradeStepsDTO = request.get("/api/courses/" + course.getId() + "/grading-scale/grade-steps", HttpStatus.OK, GradeStepsDTO.class);
assertThat(gradeStepsDTO.gradeType).isEqualTo(GradeType.GRADE);
assertThat(gradeStepsDTO.title).isEqualTo(course.getTitle());
assertThat(gradeStepsDTO.gradeSteps).usingRecursiveComparison().ignoringFields("gradingScale", "id").ignoringCollectionOrder().isEqualTo(gradeSteps);
}
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);
}
Aggregations