use of de.tum.in.www1.artemis.domain.exam.Exam in project ArTEMiS by ls1intum.
the class GradeStepIntegrationTest method testGetGradeStepByPercentageForExam.
/**
* Test get request for a single grade by grade percentage
*
* @throws Exception
*/
@Test
@WithMockUser(username = "student1", roles = "USER")
public void testGetGradeStepByPercentageForExam() throws Exception {
GradeStep gradeStep = new GradeStep();
gradeStep.setGradeName("Test grade");
gradeStep.setLowerBoundPercentage(0);
gradeStep.setUpperBoundPercentage(40);
gradeStep.setIsPassingGrade(false);
gradeStep.setGradingScale(examGradingScale);
gradeSteps = Set.of(gradeStep);
examGradingScale.setGradeSteps(gradeSteps);
examGradingScale.setGradeType(GradeType.BONUS);
gradingScaleRepository.save(examGradingScale);
exam.setPublishResultsDate(ZonedDateTime.now());
examRepository.save(exam);
GradeDTO foundGrade = request.get("/api/courses/" + course.getId() + "/exams/" + exam.getId() + "/grading-scale/match-grade-step?gradePercentage=35", HttpStatus.OK, GradeDTO.class);
assertThat(foundGrade.gradeName).isEqualTo("Test grade");
assertThat(foundGrade.gradeType).isEqualTo(GradeType.BONUS);
assertThat(foundGrade.isPassingGrade).isFalse();
}
use of de.tum.in.www1.artemis.domain.exam.Exam 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.domain.exam.Exam in project ArTEMiS by ls1intum.
the class GradingScaleIntegrationTest method testGetGradingScaleForCourse.
/**
* Test get request for grading scale
*
* @throws Exception
*/
@Test
@WithMockUser(username = "instructor1", roles = "INSTRUCTOR")
public void testGetGradingScaleForCourse() throws Exception {
courseGradingScale.setGradeSteps(Set.of());
gradingScaleRepository.save(courseGradingScale);
GradingScale foundGradingScale = request.get("/api/courses/" + course.getId() + "/grading-scale", HttpStatus.OK, GradingScale.class);
assertThat(foundGradingScale).usingRecursiveComparison().ignoringFields("id", "course", "exam").isEqualTo(courseGradingScale);
}
use of de.tum.in.www1.artemis.domain.exam.Exam in project ArTEMiS by ls1intum.
the class GradingScaleIntegrationTest method init.
/**
* Initialize variables
*/
@BeforeEach
public void init() {
database.addUsers(0, 0, 0, 1);
course = database.addEmptyCourse();
exam = database.addExamWithExerciseGroup(course, true);
courseGradingScale = new GradingScale();
courseGradingScale.setCourse(course);
examGradingScale = new GradingScale();
examGradingScale.setExam(exam);
gradeSteps = new HashSet<>();
courseGradingScale.setGradeSteps(gradeSteps);
examGradingScale.setGradeSteps(gradeSteps);
}
use of de.tum.in.www1.artemis.domain.exam.Exam in project ArTEMiS by ls1intum.
the class GradingScaleIntegrationTest method testSaveGradingScaleForCourse.
/**
* Test post request for grading scale
*
* @throws Exception
*/
@Test
@WithMockUser(username = "instructor1", roles = "INSTRUCTOR")
public void testSaveGradingScaleForCourse() throws Exception {
gradeSteps = database.generateGradeStepSet(courseGradingScale, true);
courseGradingScale.setGradeSteps(gradeSteps);
GradingScale savedGradingScale = request.postWithResponseBody("/api/courses/" + course.getId() + "/grading-scale", courseGradingScale, GradingScale.class, HttpStatus.CREATED);
assertThat(savedGradingScale.getGradeSteps()).hasSameSizeAs(courseGradingScale.getGradeSteps());
assertThat(savedGradingScale.getGradeSteps()).allMatch(gradeStep -> isGradeStepInSet(courseGradingScale.getGradeSteps(), gradeStep));
assertThat(savedGradingScale).usingRecursiveComparison().ignoringFields("id", "exam", "course", "gradeSteps").ignoringCollectionOrder().isEqualTo(courseGradingScale);
}
Aggregations