use of de.tum.in.www1.artemis.domain.GradingScale in project ArTEMiS by ls1intum.
the class GradingScaleServiceTest method testGradeStepMatchingForRoundingErrors4.
/**
* Test grade step matching for rounding errors
*/
@Test
@WithMockUser(username = "student1", roles = "USER")
public void testGradeStepMatchingForRoundingErrors4() {
double boundary = 60 + 1d / 7d;
GradingScale gradingScale = database.generateGradingScale(2, new double[] { 0, boundary, 100 }, true, 1, Optional.empty());
gradingScaleRepository.save(gradingScale);
Long id = gradingScaleRepository.findAll().get(0).getId();
GradeStep gradeStep = gradingScaleRepository.matchPercentageToGradeStep(60.142857, id);
assertThat(gradeStep.getGradeName()).isEqualTo("Step1");
gradeStep = gradingScaleRepository.matchPercentageToGradeStep(60.1322, id);
assertThat(gradeStep.getGradeName()).isEqualTo("Step0");
}
use of de.tum.in.www1.artemis.domain.GradingScale in project ArTEMiS by ls1intum.
the class GradingScaleServiceTest method testGradeStepMatchingForRoundingErrors8.
/**
* Test grade step matching for rounding errors
*/
@Test
@WithMockUser(username = "student1", roles = "USER")
public void testGradeStepMatchingForRoundingErrors8() {
double boundary = 45 + 5d / 6d;
GradingScale gradingScale = database.generateGradingScale(2, new double[] { 0, boundary, 100 }, true, 1, Optional.empty());
gradingScaleRepository.save(gradingScale);
Long id = gradingScaleRepository.findAll().get(0).getId();
GradeStep gradeStep = gradingScaleRepository.matchPercentageToGradeStep(45.83, id);
assertThat(gradeStep.getGradeName()).isEqualTo("Step1");
gradeStep = gradingScaleRepository.matchPercentageToGradeStep(45.825, id);
assertThat(gradeStep.getGradeName()).isEqualTo("Step1");
}
use of de.tum.in.www1.artemis.domain.GradingScale in project ArTEMiS by ls1intum.
the class GradingScaleServiceTest method testMatchPercentageToGradeStepValidMappingExists.
/**
* Test mapping of a valid grade percentage to a grade step
*/
@Test
@WithMockUser(username = "instructor1", roles = "INSTRUCTOR")
public void testMatchPercentageToGradeStepValidMappingExists() {
GradeStep expectedGradeStep = createCustomGradeStep("Pass", 60, 90);
gradingScaleRepository.save(gradingScale);
Long gradingScaleId = gradingScaleRepository.findAll().get(0).getId();
double percentage = 70;
GradeStep gradeStep = gradingScaleRepository.matchPercentageToGradeStep(percentage, gradingScaleId);
assertThat(gradeStep).usingRecursiveComparison().ignoringFields("gradingScale", "id").isEqualTo(expectedGradeStep);
}
use of de.tum.in.www1.artemis.domain.GradingScale in project ArTEMiS by ls1intum.
the class GradingScaleServiceTest method testGradeStepMatchingForRoundingErrors11.
/**
* Test grade step matching for rounding errors
*/
@Test
@WithMockUser(username = "student1", roles = "USER")
public void testGradeStepMatchingForRoundingErrors11() {
double boundary = 25 + 1d / 12d;
GradingScale gradingScale = database.generateGradingScale(2, new double[] { 0, boundary, 100 }, true, 1, Optional.empty());
gradingScaleRepository.save(gradingScale);
Long id = gradingScaleRepository.findAll().get(0).getId();
GradeStep gradeStep = gradingScaleRepository.matchPercentageToGradeStep(25.08, id);
assertThat(gradeStep.getGradeName()).isEqualTo("Step1");
gradeStep = gradingScaleRepository.matchPercentageToGradeStep(25, id);
assertThat(gradeStep.getGradeName()).isEqualTo("Step0");
}
use of de.tum.in.www1.artemis.domain.GradingScale in project Artemis by ls1intum.
the class GradingScaleServiceTest method createCustomGradeStep.
private GradeStep createCustomGradeStep(String gradeName, double lowerBound, double upperBound) {
GradeStep gradeStep = new GradeStep();
gradeStep.setIsPassingGrade(true);
gradeStep.setGradeName(gradeName);
gradeStep.setLowerBoundPercentage(lowerBound);
gradeStep.setUpperBoundPercentage(upperBound);
gradeStep.setGradingScale(gradingScale);
gradingScale.setGradeSteps(Set.of(gradeStep));
gradingScale.setCourse(course);
return gradeStep;
}
Aggregations