Search in sources :

Example 86 with ModelingSubmission

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

the class ModelingSubmissionIntegrationTest method getModelSubmissionWithSimilarElements.

@Test
@WithMockUser(username = "tutor1", roles = "TA")
public void getModelSubmissionWithSimilarElements() throws Exception {
    ModelingSubmission submission = ModelFactory.generateModelingSubmission(validModel, true);
    database.addModelingSubmission(classExercise, submission, "student1");
    ModelingSubmission submission2 = ModelFactory.generateModelingSubmission(validSameModel, true);
    database.addModelingSubmission(classExercise, submission2, "student2");
    database.updateExerciseDueDate(classExercise.getId(), ZonedDateTime.now().minusHours(1));
    compassService.build(classExercise);
    ModelingSubmission storedSubmission = request.get("/api/exercises/" + classExercise.getId() + "/modeling-submission-without-assessment?lock=true", HttpStatus.OK, ModelingSubmission.class);
    assertThat(storedSubmission).as("submission was found").isNotNull();
    assertThat(storedSubmission.getSimilarElements()).as("similarity count is set").isNotNull();
    assertThat(storedSubmission.getSimilarElements()).as("similarity count is set").hasSize(10);
}
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 87 with ModelingSubmission

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

the class ModelingSubmissionIntegrationTest method createModelingSubmission_studentNotInCourse.

@Test
@WithMockUser(username = "student4", roles = "USER")
public void createModelingSubmission_studentNotInCourse() throws Exception {
    ModelingSubmission submission = ModelFactory.generateModelingSubmission(validModel, true);
    request.postWithResponseBody("/api/exercises/" + classExercise.getId() + "/modeling-submissions", submission, ModelingSubmission.class, HttpStatus.FORBIDDEN);
}
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 88 with ModelingSubmission

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

the class LearningGoalIntegrationTest method createParticipationSubmissionAndResult.

private void createParticipationSubmissionAndResult(Long idOfExercise, Participant participant, Double pointsOfExercise, Double bonusPointsOfExercise, long scoreAwarded, boolean rated) {
    Exercise exercise = exerciseRepository.findById(idOfExercise).get();
    if (!exercise.getMaxPoints().equals(pointsOfExercise)) {
        exercise.setMaxPoints(pointsOfExercise);
    }
    if (!exercise.getBonusPoints().equals(bonusPointsOfExercise)) {
        exercise.setBonusPoints(bonusPointsOfExercise);
    }
    exercise = exerciseRepository.save(exercise);
    StudentParticipation studentParticipation = participationService.startExercise(exercise, participant, false);
    Submission submission;
    if (exercise instanceof ProgrammingExercise) {
        submission = new ProgrammingSubmission();
    } else if (exercise instanceof ModelingExercise) {
        submission = new ModelingSubmission();
    } else if (exercise instanceof TextExercise) {
        submission = new TextSubmission();
    } else if (exercise instanceof FileUploadExercise) {
        submission = new FileUploadSubmission();
    } else if (exercise instanceof QuizExercise) {
        submission = new QuizSubmission();
    } else {
        throw new RuntimeException("Unsupported exercise type: " + exercise);
    }
    submission.setType(SubmissionType.MANUAL);
    submission.setParticipation(studentParticipation);
    submission = submissionRepository.save(submission);
    // result
    Result result = ModelFactory.generateResult(rated, scoreAwarded);
    result.setParticipation(studentParticipation);
    result.setCompletionDate(ZonedDateTime.now());
    result = resultRepository.save(result);
    submission.addResult(result);
    result.setSubmission(submission);
    submissionRepository.save(submission);
}
Also used : ModelingSubmission(de.tum.in.www1.artemis.domain.modeling.ModelingSubmission) QuizSubmission(de.tum.in.www1.artemis.domain.quiz.QuizSubmission) 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) QuizExercise(de.tum.in.www1.artemis.domain.quiz.QuizExercise) QuizSubmission(de.tum.in.www1.artemis.domain.quiz.QuizSubmission) QuizExercise(de.tum.in.www1.artemis.domain.quiz.QuizExercise) ModelingExercise(de.tum.in.www1.artemis.domain.modeling.ModelingExercise)

Example 89 with ModelingSubmission

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

the class ResultServiceIntegrationTest method createExampleResult.

@Test
@WithMockUser(username = "instructor1", roles = "INSTRUCTOR")
public void createExampleResult() throws Exception {
    var modelingSubmission = database.addSubmission(modelingExercise, new ModelingSubmission(), "student1");
    var exampleSubmission = ModelFactory.generateExampleSubmission(modelingSubmission, modelingExercise, false);
    exampleSubmission = database.addExampleSubmission(exampleSubmission);
    modelingSubmission.setExampleSubmission(true);
    submissionRepository.save(modelingSubmission);
    request.postWithResponseBody("/api/exercises/" + modelingExercise.getId() + "/example-submissions/" + modelingSubmission.getId() + "/example-results", exampleSubmission, Result.class, HttpStatus.CREATED);
}
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) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 90 with ModelingSubmission

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

the class ResultServiceIntegrationTest method createExampleResult_wrongExerciseId.

@Test
@WithMockUser(username = "instructor1", roles = "INSTRUCTOR")
public void createExampleResult_wrongExerciseId() throws Exception {
    var modelingSubmission = database.addSubmission(modelingExercise, new ModelingSubmission(), "student1");
    var exampleSubmission = ModelFactory.generateExampleSubmission(modelingSubmission, modelingExercise, false);
    exampleSubmission = database.addExampleSubmission(exampleSubmission);
    modelingSubmission.setExampleSubmission(true);
    submissionRepository.save(modelingSubmission);
    long randomId = 1874;
    request.postWithResponseBody("/api/exercises/" + randomId + "/example-submissions/" + modelingSubmission.getId() + "/example-results", exampleSubmission, Result.class, HttpStatus.BAD_REQUEST);
}
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) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

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