Search in sources :

Example 51 with Exam

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();
}
Also used : GradeDTO(de.tum.in.www1.artemis.web.rest.dto.GradeDTO) WithMockUser(org.springframework.security.test.context.support.WithMockUser) Test(org.junit.jupiter.api.Test)

Example 52 with Exam

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);
}
Also used : GradeStepsDTO(de.tum.in.www1.artemis.web.rest.dto.GradeStepsDTO) WithMockUser(org.springframework.security.test.context.support.WithMockUser) Test(org.junit.jupiter.api.Test)

Example 53 with Exam

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

Example 54 with Exam

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);
}
Also used : GradingScale(de.tum.in.www1.artemis.domain.GradingScale) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 55 with Exam

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

Aggregations

Exam (de.tum.in.www1.artemis.domain.exam.Exam)228 StudentExam (de.tum.in.www1.artemis.domain.exam.StudentExam)180 WithMockUser (org.springframework.security.test.context.support.WithMockUser)164 Test (org.junit.jupiter.api.Test)158 ExerciseGroup (de.tum.in.www1.artemis.domain.exam.ExerciseGroup)92 PreAuthorize (org.springframework.security.access.prepost.PreAuthorize)75 ModelingExercise (de.tum.in.www1.artemis.domain.modeling.ModelingExercise)52 EntityNotFoundException (de.tum.in.www1.artemis.web.rest.errors.EntityNotFoundException)48 AbstractSpringIntegrationBambooBitbucketJiraTest (de.tum.in.www1.artemis.AbstractSpringIntegrationBambooBitbucketJiraTest)46 StudentParticipation (de.tum.in.www1.artemis.domain.participation.StudentParticipation)46 QuizExercise (de.tum.in.www1.artemis.domain.quiz.QuizExercise)42 ZonedDateTime (java.time.ZonedDateTime)40 BadRequestAlertException (de.tum.in.www1.artemis.web.rest.errors.BadRequestAlertException)38 Course (de.tum.in.www1.artemis.domain.Course)36 GradingScale (de.tum.in.www1.artemis.domain.GradingScale)34 BeforeEach (org.junit.jupiter.api.BeforeEach)30 User (de.tum.in.www1.artemis.domain.User)27 Collectors (java.util.stream.Collectors)26 ModelingSubmission (de.tum.in.www1.artemis.domain.modeling.ModelingSubmission)24 de.tum.in.www1.artemis.repository (de.tum.in.www1.artemis.repository)24