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);
}
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();
}
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);
}
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);
}
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");
}
Aggregations