use of de.tum.in.www1.artemis.domain.modeling.ModelingExercise in project ArTEMiS by ls1intum.
the class ModelingExerciseIntegrationTest method testReEvaluateAndUpdateModelingExercise_shouldDeleteFeedbacks.
@Test
@WithMockUser(username = "instructor1", roles = "INSTRUCTOR")
public void testReEvaluateAndUpdateModelingExercise_shouldDeleteFeedbacks() throws Exception {
List<GradingCriterion> gradingCriteria = database.addGradingInstructionsToExercise(classExercise);
gradingCriterionRepository.saveAll(gradingCriteria);
database.addAssessmentWithFeedbackWithGradingInstructionsForExercise(classExercise, "instructor1");
// remove instruction which is associated with feedbacks
gradingCriteria.remove(1);
gradingCriteria.remove(0);
classExercise.setGradingCriteria(gradingCriteria);
ModelingExercise updatedModelingExercise = request.putWithResponseBody("/api/modeling-exercises/" + classExercise.getId() + "/re-evaluate" + "?deleteFeedback=true", classExercise, ModelingExercise.class, HttpStatus.OK);
List<Result> updatedResults = database.getResultsForExercise(updatedModelingExercise);
assertThat(updatedModelingExercise.getGradingCriteria()).hasSize(1);
assertThat(updatedResults.get(0).getScore()).isZero();
assertThat(updatedResults.get(0).getFeedbacks()).isEmpty();
}
use of de.tum.in.www1.artemis.domain.modeling.ModelingExercise in project ArTEMiS by ls1intum.
the class ModelingExerciseIntegrationTest method testUpdateModelingExercise_updatingCourseId_conflict.
@Test
@WithMockUser(username = "instructor1", roles = "INSTRUCTOR")
public void testUpdateModelingExercise_updatingCourseId_conflict() throws Exception {
// Create a modeling exercise.
ModelingExercise createdModelingExercise = classExercise;
Long oldCourseId = createdModelingExercise.getCourseViaExerciseGroupOrCourseMember().getId();
// Create a new course with different id.
Long newCourseId = oldCourseId + 1;
Course newCourse = database.createCourse(newCourseId);
// Assign new course to the modeling exercise.
createdModelingExercise.setCourse(newCourse);
// Modeling exercise update with the new course should fail.
ModelingExercise returnedModelingExercise = request.putWithResponseBody("/api/modeling-exercises", createdModelingExercise, ModelingExercise.class, HttpStatus.CONFLICT);
assertThat(returnedModelingExercise).isNull();
}
use of de.tum.in.www1.artemis.domain.modeling.ModelingExercise in project ArTEMiS by ls1intum.
the class ModelingExerciseIntegrationTest method testImportModelingExercise_setGradingInstructionForCopiedFeedback.
@Test
@WithMockUser(username = "instructor1", roles = "INSTRUCTOR")
public void testImportModelingExercise_setGradingInstructionForCopiedFeedback() throws Exception {
var now = ZonedDateTime.now();
Course course1 = database.addEmptyCourse();
Course course2 = database.addEmptyCourse();
ModelingExercise modelingExercise = ModelFactory.generateModelingExercise(now.minusDays(1), now.minusHours(2), now.minusHours(1), DiagramType.ClassDiagram, course1);
modelingExercise = modelingExerciseRepository.save(modelingExercise);
List<GradingCriterion> gradingCriteria = database.addGradingInstructionsToExercise(modelingExercise);
gradingCriterionRepository.saveAll(gradingCriteria);
GradingInstruction gradingInstruction = gradingCriteria.get(0).getStructuredGradingInstructions().get(0);
assertThat(gradingInstruction.getFeedback()).as("Test feedback should have student readable feedback").isNotEmpty();
// Create example submission
var exampleSubmission = database.generateExampleSubmission("model", modelingExercise, true);
exampleSubmission = database.addExampleSubmission(exampleSubmission);
database.addResultToSubmission(exampleSubmission.getSubmission(), AssessmentType.MANUAL);
var submission = submissionRepository.findWithEagerResultAndFeedbackById(exampleSubmission.getSubmission().getId()).get();
Feedback feedback = ModelFactory.generateFeedback().get(0);
feedback.setGradingInstruction(gradingInstruction);
database.addFeedbackToResult(feedback, Objects.requireNonNull(submission.getLatestResult()));
modelingExercise.setCourse(course2);
var importedModelingExercise = request.postWithResponseBody("/api/modeling-exercises/import/" + modelingExercise.getId(), modelingExercise, ModelingExercise.class, HttpStatus.CREATED);
assertThat(modelingExerciseRepository.findById(importedModelingExercise.getId())).isPresent();
var importedExampleSubmission = importedModelingExercise.getExampleSubmissions().stream().findFirst().get();
GradingInstruction importedFeedbackGradingInstruction = importedExampleSubmission.getSubmission().getLatestResult().getFeedbacks().get(0).getGradingInstruction();
assertThat(importedFeedbackGradingInstruction).isNotNull();
// Copy and original should have the same data but not the same ids.
assertThat(importedFeedbackGradingInstruction.getId()).isNotEqualTo(gradingInstruction.getId());
// To avoid infinite recursion when serializing to JSON.
assertThat(importedFeedbackGradingInstruction.getGradingCriterion()).isNull();
assertThat(importedFeedbackGradingInstruction.getFeedback()).isEqualTo(gradingInstruction.getFeedback());
assertThat(importedFeedbackGradingInstruction.getGradingScale()).isEqualTo(gradingInstruction.getGradingScale());
assertThat(importedFeedbackGradingInstruction.getInstructionDescription()).isEqualTo(gradingInstruction.getInstructionDescription());
assertThat(importedFeedbackGradingInstruction.getCredits()).isEqualTo(gradingInstruction.getCredits());
assertThat(importedFeedbackGradingInstruction.getUsageCount()).isEqualTo(gradingInstruction.getUsageCount());
var importedModelingExerciseFromDb = modelingExerciseRepository.findByIdWithExampleSubmissionsAndResults(importedModelingExercise.getId()).get();
var importedFeedbackGradingInstructionFromDb = importedModelingExerciseFromDb.getExampleSubmissions().stream().findFirst().get().getSubmission().getLatestResult().getFeedbacks().get(0).getGradingInstruction();
assertThat(importedFeedbackGradingInstructionFromDb.getGradingCriterion().getId()).isNotEqualTo(gradingInstruction.getGradingCriterion().getId());
}
use of de.tum.in.www1.artemis.domain.modeling.ModelingExercise in project ArTEMiS by ls1intum.
the class ModelingExerciseIntegrationTest method testUpdateModelingExerciseForExam_invalidExercise_dates.
@ParameterizedTest(name = "{displayName} [{index}] {argumentsWithNames}")
@ArgumentsSource(InvalidExamExerciseDatesArgumentProvider.class)
@WithMockUser(username = "instructor1", roles = "INSTRUCTOR")
public void testUpdateModelingExerciseForExam_invalidExercise_dates(InvalidExamExerciseDateConfiguration invalidDates) throws Exception {
ExerciseGroup exerciseGroup = database.addExerciseGroupWithExamAndCourse(true);
ModelingExercise modelingExercise = ModelFactory.generateModelingExerciseForExam(DiagramType.ClassDiagram, exerciseGroup);
modelingExerciseRepository.save(modelingExercise);
request.postWithResponseBody("/api/modeling-exercises/", invalidDates.applyTo(modelingExercise), ProgrammingExercise.class, HttpStatus.BAD_REQUEST);
}
use of de.tum.in.www1.artemis.domain.modeling.ModelingExercise in project ArTEMiS by ls1intum.
the class ModelingExerciseIntegrationTest method testGetPlagiarismResultWithoutResult.
@Test
@WithMockUser(username = "instructor1", roles = "INSTRUCTOR")
public void testGetPlagiarismResultWithoutResult() throws Exception {
final Course course = database.addCourseWithOneModelingExercise();
ModelingExercise modelingExercise = modelingExerciseRepository.findByCourseIdWithCategories(course.getId()).get(0);
var result = request.get("/api/modeling-exercises/" + modelingExercise.getId() + "/plagiarism-result", HttpStatus.OK, String.class);
assertThat(result).isNullOrEmpty();
}
Aggregations