Search in sources :

Example 51 with ModelingExercise

use of de.tum.in.www1.artemis.domain.modeling.ModelingExercise in project ArTEMiS by ls1intum.

the class LearningGoalIntegrationTest method creatingLectureUnitsOfLectureOne.

private void creatingLectureUnitsOfLectureOne() {
    // creating lecture units for lecture one
    TextUnit textUnit = new TextUnit();
    textUnit.setName("TextUnitOfLectureOne");
    textUnit = textUnitRepository.save(textUnit);
    idOfTextUnitOfLectureOne = textUnit.getId();
    Exercise textExercise = exerciseRepository.findById(idOfTextExercise).get();
    ExerciseUnit textExerciseUnit = new ExerciseUnit();
    textExerciseUnit.setExercise(textExercise);
    textExerciseUnit = exerciseUnitRepository.save(textExerciseUnit);
    idOfExerciseUnitTextOfLectureOne = textExerciseUnit.getId();
    Exercise modelingExercise = exerciseRepository.findById(idOfModelingExercise).get();
    ExerciseUnit modelingExerciseUnit = new ExerciseUnit();
    modelingExerciseUnit.setExercise(modelingExercise);
    modelingExerciseUnit = exerciseUnitRepository.save(modelingExerciseUnit);
    idOfExerciseUnitModelingOfLectureOne = modelingExerciseUnit.getId();
    Exercise textTeamExercise = exerciseRepository.findById(idOfTeamTextExercise).get();
    ExerciseUnit teamTextExerciseUnit = new ExerciseUnit();
    teamTextExerciseUnit.setExercise(textTeamExercise);
    teamTextExerciseUnit = exerciseUnitRepository.save(teamTextExerciseUnit);
    List<LectureUnit> lectureUnitsOfLectureOne = List.of(textUnit, textExerciseUnit, modelingExerciseUnit, teamTextExerciseUnit);
    Lecture lectureOne = lectureRepository.findByIdWithPostsAndLectureUnitsAndLearningGoals(idOfLectureOne).get();
    for (LectureUnit lectureUnit : lectureUnitsOfLectureOne) {
        lectureOne.addLectureUnit(lectureUnit);
    }
    lectureRepository.save(lectureOne);
}
Also used : QuizExercise(de.tum.in.www1.artemis.domain.quiz.QuizExercise) ModelingExercise(de.tum.in.www1.artemis.domain.modeling.ModelingExercise) ExerciseUnit(de.tum.in.www1.artemis.domain.lecture.ExerciseUnit) LectureUnit(de.tum.in.www1.artemis.domain.lecture.LectureUnit) TextUnit(de.tum.in.www1.artemis.domain.lecture.TextUnit)

Example 52 with ModelingExercise

use of de.tum.in.www1.artemis.domain.modeling.ModelingExercise in project ArTEMiS by ls1intum.

the class ModelingExerciseIntegrationTest method testUpdateModelingExerciseInstructions_asInstructor.

@Test
@WithMockUser(username = "instructor1", roles = "INSTRUCTOR")
public void testUpdateModelingExerciseInstructions_asInstructor() throws Exception {
    ModelingExercise modelingExercise = modelingExerciseUtilService.createModelingExercise(classExercise.getCourseViaExerciseGroupOrCourseMember().getId());
    gradingCriteria = database.addGradingInstructionsToExercise(modelingExercise);
    var currentInstructionsSize = modelingExercise.getGradingCriteria().get(1).getStructuredGradingInstructions().size();
    var newInstruction = new GradingInstruction();
    newInstruction.setInstructionDescription("New Instruction");
    modelingExercise.getGradingCriteria().get(1).addStructuredGradingInstructions(newInstruction);
    ModelingExercise createdModelingExercise = request.postWithResponseBody("/api/modeling-exercises", modelingExercise, ModelingExercise.class, HttpStatus.CREATED);
    assertThat(createdModelingExercise.getGradingCriteria().get(1).getStructuredGradingInstructions()).hasSize(currentInstructionsSize + 1);
    modelingExercise.getGradingCriteria().get(1).getStructuredGradingInstructions().get(0).setInstructionDescription("UPDATE");
    createdModelingExercise = request.postWithResponseBody("/api/modeling-exercises", modelingExercise, ModelingExercise.class, HttpStatus.CREATED);
    assertThat(createdModelingExercise.getGradingCriteria().get(1).getStructuredGradingInstructions().get(0).getInstructionDescription()).isEqualTo("UPDATE");
    modelingExercise.getGradingCriteria().get(1).setStructuredGradingInstructions(null);
    createdModelingExercise = request.postWithResponseBody("/api/modeling-exercises", modelingExercise, ModelingExercise.class, HttpStatus.CREATED);
    assertThat(createdModelingExercise.getGradingCriteria()).isNotEmpty();
    assertThat(createdModelingExercise.getGradingCriteria().get(1).getStructuredGradingInstructions()).isNullOrEmpty();
}
Also used : ModelingExercise(de.tum.in.www1.artemis.domain.modeling.ModelingExercise) WithMockUser(org.springframework.security.test.context.support.WithMockUser) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 53 with ModelingExercise

use of de.tum.in.www1.artemis.domain.modeling.ModelingExercise in project ArTEMiS by ls1intum.

the class ModelingExerciseIntegrationTest method testUpdateModelingExercise_asInstructor.

@Test
@WithMockUser(username = "instructor1", roles = "INSTRUCTOR")
public void testUpdateModelingExercise_asInstructor() throws Exception {
    ModelingExercise modelingExercise = modelingExerciseUtilService.createModelingExercise(classExercise.getCourseViaExerciseGroupOrCourseMember().getId());
    ModelingExercise createdModelingExercise = request.postWithResponseBody("/api/modeling-exercises", modelingExercise, ModelingExercise.class, HttpStatus.CREATED);
    gradingCriteria = database.addGradingInstructionsToExercise(modelingExercise);
    createdModelingExercise.setGradingCriteria(gradingCriteria);
    var params = new LinkedMultiValueMap<String, String>();
    var notificationText = "notified!";
    params.add("notificationText", notificationText);
    ModelingExercise returnedModelingExercise = request.putWithResponseBodyAndParams("/api/modeling-exercises", createdModelingExercise, ModelingExercise.class, HttpStatus.OK, params);
    assertThat(returnedModelingExercise.getGradingCriteria()).hasSameSizeAs(gradingCriteria);
    verify(groupNotificationService).notifyStudentAndEditorAndInstructorGroupAboutExerciseUpdate(returnedModelingExercise, notificationText);
    // use an arbitrary course id that was not yet stored on the server to get a bad request in the PUT call
    modelingExercise = modelingExerciseUtilService.createModelingExercise(Long.MAX_VALUE, classExercise.getId());
    request.put("/api/modeling-exercises", modelingExercise, HttpStatus.CONFLICT);
}
Also used : LinkedMultiValueMap(org.springframework.util.LinkedMultiValueMap) ModelingExercise(de.tum.in.www1.artemis.domain.modeling.ModelingExercise) WithMockUser(org.springframework.security.test.context.support.WithMockUser) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 54 with ModelingExercise

use of de.tum.in.www1.artemis.domain.modeling.ModelingExercise in project ArTEMiS by ls1intum.

the class ModelingExerciseIntegrationTest method createModelingExercise_IncludedAsBonusInvalidBonusPoints.

@Test
@WithMockUser(username = "instructor1", roles = "INSTRUCTOR")
public void createModelingExercise_IncludedAsBonusInvalidBonusPoints() throws Exception {
    ModelingExercise modelingExercise = modelingExerciseUtilService.createModelingExercise(classExercise.getCourseViaExerciseGroupOrCourseMember().getId());
    modelingExercise.setMaxPoints(10.0);
    modelingExercise.setBonusPoints(1.0);
    modelingExercise.setIncludedInOverallScore(IncludedInOverallScore.INCLUDED_AS_BONUS);
    request.postWithResponseBody("/api/modeling-exercises", modelingExercise, ModelingExercise.class, HttpStatus.BAD_REQUEST);
}
Also used : ModelingExercise(de.tum.in.www1.artemis.domain.modeling.ModelingExercise) WithMockUser(org.springframework.security.test.context.support.WithMockUser) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 55 with ModelingExercise

use of de.tum.in.www1.artemis.domain.modeling.ModelingExercise in project ArTEMiS by ls1intum.

the class ModelingExerciseIntegrationTest method testGetModelingExercise_asTA.

@Test
@WithMockUser(username = "tutor1", roles = "TA")
public void testGetModelingExercise_asTA() throws Exception {
    ModelingExercise receivedModelingExercise = request.get("/api/modeling-exercises/" + classExercise.getId(), HttpStatus.OK, ModelingExercise.class);
    gradingCriteria = database.addGradingInstructionsToExercise(receivedModelingExercise);
    assertThat(receivedModelingExercise.getGradingCriteria().get(0).getTitle()).isNull();
    assertThat(receivedModelingExercise.getGradingCriteria().get(1).getTitle()).isEqualTo("test title");
    assertThat(gradingCriteria.get(0).getStructuredGradingInstructions()).hasSize(1);
    assertThat(gradingCriteria.get(1).getStructuredGradingInstructions()).hasSize(3);
    assertThat(gradingCriteria.get(0).getStructuredGradingInstructions().get(0).getInstructionDescription()).isEqualTo("created first instruction with empty criteria for testing");
}
Also used : ModelingExercise(de.tum.in.www1.artemis.domain.modeling.ModelingExercise) WithMockUser(org.springframework.security.test.context.support.WithMockUser) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Aggregations

ModelingExercise (de.tum.in.www1.artemis.domain.modeling.ModelingExercise)196 WithMockUser (org.springframework.security.test.context.support.WithMockUser)132 Test (org.junit.jupiter.api.Test)126 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)96 ModelingSubmission (de.tum.in.www1.artemis.domain.modeling.ModelingSubmission)72 ModelingPlagiarismResult (de.tum.in.www1.artemis.domain.plagiarism.modeling.ModelingPlagiarismResult)28 ExerciseGroup (de.tum.in.www1.artemis.domain.exam.ExerciseGroup)26 StudentParticipation (de.tum.in.www1.artemis.domain.participation.StudentParticipation)20 AbstractSpringIntegrationBambooBitbucketJiraTest (de.tum.in.www1.artemis.AbstractSpringIntegrationBambooBitbucketJiraTest)16 TextPlagiarismResult (de.tum.in.www1.artemis.domain.plagiarism.text.TextPlagiarismResult)16 BeforeEach (org.junit.jupiter.api.BeforeEach)16 Course (de.tum.in.www1.artemis.domain.Course)14 PreAuthorize (org.springframework.security.access.prepost.PreAuthorize)14 ZonedDateTime (java.time.ZonedDateTime)12 Exam (de.tum.in.www1.artemis.domain.exam.Exam)10 QuizExercise (de.tum.in.www1.artemis.domain.quiz.QuizExercise)10 TeamAssignmentPayload (de.tum.in.www1.artemis.web.websocket.dto.TeamAssignmentPayload)9 JsonParser.parseString (com.google.gson.JsonParser.parseString)8 StudentExam (de.tum.in.www1.artemis.domain.exam.StudentExam)8 ModelCluster (de.tum.in.www1.artemis.domain.modeling.ModelCluster)8