Search in sources :

Example 66 with ModelingSubmission

use of de.tum.in.www1.artemis.domain.modeling.ModelingSubmission in project Artemis by ls1intum.

the class ComplaintResource method filterOutUselessDataFromComplaint.

private void filterOutUselessDataFromComplaint(Complaint complaint) {
    if (complaint.getResult() == null) {
        return;
    }
    StudentParticipation originalParticipation = (StudentParticipation) complaint.getResult().getParticipation();
    if (originalParticipation != null && originalParticipation.getExercise() != null) {
        Exercise exerciseWithOnlyTitle = originalParticipation.getExercise();
        if (exerciseWithOnlyTitle instanceof TextExercise) {
            exerciseWithOnlyTitle = new TextExercise();
        } else if (exerciseWithOnlyTitle instanceof ModelingExercise) {
            exerciseWithOnlyTitle = new ModelingExercise();
        } else if (exerciseWithOnlyTitle instanceof FileUploadExercise) {
            exerciseWithOnlyTitle = new FileUploadExercise();
        } else if (exerciseWithOnlyTitle instanceof ProgrammingExercise) {
            exerciseWithOnlyTitle = new ProgrammingExercise();
        }
        exerciseWithOnlyTitle.setTitle(originalParticipation.getExercise().getTitle());
        exerciseWithOnlyTitle.setId(originalParticipation.getExercise().getId());
        originalParticipation.setExercise(exerciseWithOnlyTitle);
    }
    Submission originalSubmission = complaint.getResult().getSubmission();
    if (originalSubmission != null) {
        Submission submissionWithOnlyId;
        if (originalSubmission instanceof TextSubmission) {
            submissionWithOnlyId = new TextSubmission();
        } else if (originalSubmission instanceof ModelingSubmission) {
            submissionWithOnlyId = new ModelingSubmission();
        } else if (originalSubmission instanceof FileUploadSubmission) {
            submissionWithOnlyId = new FileUploadSubmission();
        } else if (originalSubmission instanceof ProgrammingSubmission) {
            submissionWithOnlyId = new ProgrammingSubmission();
        } else {
            return;
        }
        submissionWithOnlyId.setId(originalSubmission.getId());
        complaint.getResult().setSubmission(submissionWithOnlyId);
    }
}
Also used : ModelingExercise(de.tum.in.www1.artemis.domain.modeling.ModelingExercise) ModelingSubmission(de.tum.in.www1.artemis.domain.modeling.ModelingSubmission) ModelingSubmission(de.tum.in.www1.artemis.domain.modeling.ModelingSubmission) ModelingExercise(de.tum.in.www1.artemis.domain.modeling.ModelingExercise) StudentParticipation(de.tum.in.www1.artemis.domain.participation.StudentParticipation)

Example 67 with ModelingSubmission

use of de.tum.in.www1.artemis.domain.modeling.ModelingSubmission in project Artemis by ls1intum.

the class ModelingSubmissionIntegrationTest method getAllSubmissionsOfExercise.

@Test
@WithMockUser(username = "instructor1", roles = "INSTRUCTOR")
public void getAllSubmissionsOfExercise() throws Exception {
    ModelingSubmission submission1 = database.addModelingSubmission(classExercise, submittedSubmission, "student1");
    ModelingSubmission submission2 = database.addModelingSubmission(classExercise, unsubmittedSubmission, "student2");
    List<ModelingSubmission> submissions = request.getList("/api/exercises/" + classExercise.getId() + "/modeling-submissions", HttpStatus.OK, ModelingSubmission.class);
    assertThat(submissions).as("contains both submissions").containsExactlyInAnyOrder(submission1, submission2);
}
Also used : ModelingSubmission(de.tum.in.www1.artemis.domain.modeling.ModelingSubmission) WithMockUser(org.springframework.security.test.context.support.WithMockUser) Test(org.junit.jupiter.api.Test)

Example 68 with ModelingSubmission

use of de.tum.in.www1.artemis.domain.modeling.ModelingSubmission in project Artemis by ls1intum.

the class ModelingSubmissionIntegrationTest method saveExercise_afterDueDateWithParticipationStartAfterDueDate.

@Test
@WithMockUser(username = "student3", roles = "USER")
public void saveExercise_afterDueDateWithParticipationStartAfterDueDate() throws Exception {
    database.updateExerciseDueDate(classExercise.getId(), ZonedDateTime.now().minusHours(1));
    afterDueDateParticipation.setInitializationDate(ZonedDateTime.now());
    studentParticipationRepository.saveAndFlush(afterDueDateParticipation);
    ModelingSubmission storedSubmission = request.postWithResponseBody("/api/exercises/" + classExercise.getId() + "/modeling-submissions", unsubmittedSubmission, ModelingSubmission.class, HttpStatus.OK);
    assertThat(storedSubmission.isSubmitted()).isFalse();
}
Also used : ModelingSubmission(de.tum.in.www1.artemis.domain.modeling.ModelingSubmission) WithMockUser(org.springframework.security.test.context.support.WithMockUser) Test(org.junit.jupiter.api.Test)

Example 69 with ModelingSubmission

use of de.tum.in.www1.artemis.domain.modeling.ModelingSubmission in project Artemis by ls1intum.

the class ModelingSubmissionIntegrationTest method saveAndSubmitModelingSubmission_objectDiagram.

@Test
@WithMockUser(username = "student1")
public void saveAndSubmitModelingSubmission_objectDiagram() throws Exception {
    database.createAndSaveParticipationForExercise(objectExercise, "student1");
    String emptyObjectModel = FileUtils.loadFileFromResources("test-data/model-submission/empty-object-diagram.json");
    ModelingSubmission submission = ModelFactory.generateModelingSubmission(emptyObjectModel, false);
    ModelingSubmission returnedSubmission = performInitialModelSubmission(objectExercise.getId(), submission);
    database.checkModelingSubmissionCorrectlyStored(returnedSubmission.getId(), emptyObjectModel);
    checkDetailsHidden(returnedSubmission, true);
    String validObjectModel = FileUtils.loadFileFromResources("test-data/model-submission/object-model.json");
    returnedSubmission.setModel(validObjectModel);
    returnedSubmission.setSubmitted(true);
    returnedSubmission = performUpdateOnModelSubmission(objectExercise.getId(), returnedSubmission);
    database.checkModelingSubmissionCorrectlyStored(returnedSubmission.getId(), validObjectModel);
    checkDetailsHidden(returnedSubmission, true);
}
Also used : ModelingSubmission(de.tum.in.www1.artemis.domain.modeling.ModelingSubmission) WithMockUser(org.springframework.security.test.context.support.WithMockUser) Test(org.junit.jupiter.api.Test)

Example 70 with ModelingSubmission

use of de.tum.in.www1.artemis.domain.modeling.ModelingSubmission in project Artemis by ls1intum.

the class ModelingSubmissionIntegrationTest method createNineLockedSubmissionsForDifferentExercisesAndUsers.

private void createNineLockedSubmissionsForDifferentExercisesAndUsers(String assessor) {
    ModelingSubmission submission = ModelFactory.generateModelingSubmission(validModel, true);
    database.addModelingSubmissionWithResultAndAssessor(classExercise, submission, "student1", assessor);
    submission = ModelFactory.generateModelingSubmission(validModel, true);
    database.addModelingSubmissionWithResultAndAssessor(classExercise, submission, "student2", assessor);
    submission = ModelFactory.generateModelingSubmission(validModel, true);
    database.addModelingSubmissionWithResultAndAssessor(classExercise, submission, "student3", assessor);
    submission = ModelFactory.generateModelingSubmission(validModel, true);
    database.addModelingSubmissionWithResultAndAssessor(activityExercise, submission, "student1", assessor);
    submission = ModelFactory.generateModelingSubmission(validModel, true);
    database.addModelingSubmissionWithResultAndAssessor(activityExercise, submission, "student2", assessor);
    submission = ModelFactory.generateModelingSubmission(validModel, true);
    database.addModelingSubmissionWithResultAndAssessor(activityExercise, submission, "student3", assessor);
    submission = ModelFactory.generateModelingSubmission(validModel, true);
    database.addModelingSubmissionWithResultAndAssessor(objectExercise, submission, "student1", assessor);
    submission = ModelFactory.generateModelingSubmission(validModel, true);
    database.addModelingSubmissionWithResultAndAssessor(objectExercise, submission, "student2", assessor);
    submission = ModelFactory.generateModelingSubmission(validModel, true);
    database.addModelingSubmissionWithResultAndAssessor(objectExercise, submission, "student3", assessor);
}
Also used : ModelingSubmission(de.tum.in.www1.artemis.domain.modeling.ModelingSubmission)

Aggregations

ModelingSubmission (de.tum.in.www1.artemis.domain.modeling.ModelingSubmission)160 Test (org.junit.jupiter.api.Test)108 WithMockUser (org.springframework.security.test.context.support.WithMockUser)106 ModelingExercise (de.tum.in.www1.artemis.domain.modeling.ModelingExercise)36 StudentParticipation (de.tum.in.www1.artemis.domain.participation.StudentParticipation)22 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)20 AbstractSpringIntegrationBambooBitbucketJiraTest (de.tum.in.www1.artemis.AbstractSpringIntegrationBambooBitbucketJiraTest)16 ModelingPlagiarismResult (de.tum.in.www1.artemis.domain.plagiarism.modeling.ModelingPlagiarismResult)16 TextPlagiarismResult (de.tum.in.www1.artemis.domain.plagiarism.text.TextPlagiarismResult)12 JsonParser.parseString (com.google.gson.JsonParser.parseString)8 ModelCluster (de.tum.in.www1.artemis.domain.modeling.ModelCluster)8 ModelingSubmission (de.tum.in.www1.artemis.domain.ModelingSubmission)6 Result (de.tum.in.www1.artemis.domain.Result)6 ModelElement (de.tum.in.www1.artemis.domain.modeling.ModelElement)6 ModelClusterFactory (de.tum.in.www1.artemis.service.compass.controller.ModelClusterFactory)6 StudentExam (de.tum.in.www1.artemis.domain.exam.StudentExam)4 ExerciseHint (de.tum.in.www1.artemis.domain.hestia.ExerciseHint)4 Participation (de.tum.in.www1.artemis.domain.participation.Participation)4 PlagiarismComparison (de.tum.in.www1.artemis.domain.plagiarism.PlagiarismComparison)4 PlagiarismSubmission (de.tum.in.www1.artemis.domain.plagiarism.PlagiarismSubmission)4