Search in sources :

Example 26 with GradingScale

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");
}
Also used : GradingScale(de.tum.in.www1.artemis.domain.GradingScale) GradeStep(de.tum.in.www1.artemis.domain.GradeStep) WithMockUser(org.springframework.security.test.context.support.WithMockUser) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) AbstractSpringIntegrationBambooBitbucketJiraTest(de.tum.in.www1.artemis.AbstractSpringIntegrationBambooBitbucketJiraTest)

Example 27 with GradingScale

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");
}
Also used : GradingScale(de.tum.in.www1.artemis.domain.GradingScale) GradeStep(de.tum.in.www1.artemis.domain.GradeStep) WithMockUser(org.springframework.security.test.context.support.WithMockUser) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) AbstractSpringIntegrationBambooBitbucketJiraTest(de.tum.in.www1.artemis.AbstractSpringIntegrationBambooBitbucketJiraTest)

Example 28 with GradingScale

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);
}
Also used : GradeStep(de.tum.in.www1.artemis.domain.GradeStep) WithMockUser(org.springframework.security.test.context.support.WithMockUser) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) AbstractSpringIntegrationBambooBitbucketJiraTest(de.tum.in.www1.artemis.AbstractSpringIntegrationBambooBitbucketJiraTest)

Example 29 with GradingScale

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");
}
Also used : GradingScale(de.tum.in.www1.artemis.domain.GradingScale) GradeStep(de.tum.in.www1.artemis.domain.GradeStep) WithMockUser(org.springframework.security.test.context.support.WithMockUser) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) AbstractSpringIntegrationBambooBitbucketJiraTest(de.tum.in.www1.artemis.AbstractSpringIntegrationBambooBitbucketJiraTest)

Example 30 with GradingScale

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;
}
Also used : GradeStep(de.tum.in.www1.artemis.domain.GradeStep)

Aggregations

GradingScale (de.tum.in.www1.artemis.domain.GradingScale)72 WithMockUser (org.springframework.security.test.context.support.WithMockUser)62 Test (org.junit.jupiter.api.Test)60 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)44 AbstractSpringIntegrationBambooBitbucketJiraTest (de.tum.in.www1.artemis.AbstractSpringIntegrationBambooBitbucketJiraTest)42 GradeStep (de.tum.in.www1.artemis.domain.GradeStep)38 Course (de.tum.in.www1.artemis.domain.Course)28 PreAuthorize (org.springframework.security.access.prepost.PreAuthorize)24 Exam (de.tum.in.www1.artemis.domain.exam.Exam)14 BadRequestAlertException (de.tum.in.www1.artemis.web.rest.errors.BadRequestAlertException)10 GradeStepsDTO (de.tum.in.www1.artemis.web.rest.dto.GradeStepsDTO)8 EntityNotFoundException (de.tum.in.www1.artemis.web.rest.errors.EntityNotFoundException)6 BeforeEach (org.junit.jupiter.api.BeforeEach)6 de.tum.in.www1.artemis.domain (de.tum.in.www1.artemis.domain)4 User (de.tum.in.www1.artemis.domain.User)4 ExerciseGroup (de.tum.in.www1.artemis.domain.exam.ExerciseGroup)4 StudentExam (de.tum.in.www1.artemis.domain.exam.StudentExam)4 ModelingExercise (de.tum.in.www1.artemis.domain.modeling.ModelingExercise)4 ModelingSubmission (de.tum.in.www1.artemis.domain.modeling.ModelingSubmission)4 StudentParticipation (de.tum.in.www1.artemis.domain.participation.StudentParticipation)4