Search in sources :

Example 56 with ModelingExercise

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

Example 57 with ModelingExercise

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();
}
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 58 with ModelingExercise

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());
}
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 59 with ModelingExercise

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);
}
Also used : ModelingExercise(de.tum.in.www1.artemis.domain.modeling.ModelingExercise) ExerciseGroup(de.tum.in.www1.artemis.domain.exam.ExerciseGroup) WithMockUser(org.springframework.security.test.context.support.WithMockUser) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) ArgumentsSource(org.junit.jupiter.params.provider.ArgumentsSource)

Example 60 with ModelingExercise

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