Search in sources :

Example 61 with ModelingSubmission

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

the class ParticipationTeamWebsocketService method updateSubmission.

/**
 * Updates a modeling or text submission
 *
 * @param participationId id of participation
 * @param submission      updated modeling text submission
 * @param principal       principal of user who wants to update the submission
 * @param topicPath       path of websocket destination topic where to send the new submission
 */
private void updateSubmission(@DestinationVariable Long participationId, @Payload Submission submission, Principal principal, String topicPath) {
    // Without this, custom jpa repository methods don't work in websocket channel.
    SecurityUtils.setAuthorizationObject();
    final StudentParticipation participation = studentParticipationRepository.findByIdElseThrow(participationId);
    // user must belong to the team who owns the participation in order to update a submission
    if (!participation.isOwnedBy(principal.getName())) {
        return;
    }
    final User user = userRepository.getUserWithGroupsAndAuthorities(principal.getName());
    final Exercise exercise = exerciseRepository.findByIdElseThrow(participation.getExercise().getId());
    if (submission instanceof ModelingSubmission && exercise instanceof ModelingExercise) {
        submission = modelingSubmissionService.save((ModelingSubmission) submission, (ModelingExercise) exercise, principal.getName());
        modelingSubmissionService.hideDetails(submission, user);
    } else if (submission instanceof TextSubmission && exercise instanceof TextExercise) {
        submission = textSubmissionService.handleTextSubmission((TextSubmission) submission, (TextExercise) exercise, principal);
        textSubmissionService.hideDetails(submission, user);
    } else {
        throw new IllegalArgumentException("Submission type '" + submission.getType() + "' not allowed.");
    }
    // update the last action date for the user and send out list of team members
    updateValue(lastActionTracker, participationId, principal.getName());
    sendOnlineTeamStudents(participationId);
    SubmissionSyncPayload payload = new SubmissionSyncPayload(submission, user);
    messagingTemplate.convertAndSend(getDestination(participationId, topicPath), payload);
}
Also used : ModelingExercise(de.tum.in.www1.artemis.domain.modeling.ModelingExercise) SubmissionSyncPayload(de.tum.in.www1.artemis.web.websocket.dto.SubmissionSyncPayload) 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 62 with ModelingSubmission

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

the class ProgrammingSubmissionIntegrationTest method triggerFailedBuildSubmissionNotFound.

@Test
@WithMockUser(username = "student1", roles = "USER")
void triggerFailedBuildSubmissionNotFound() throws Exception {
    String login = "student1";
    Course course = database.addCourseWithDifferentModelingExercises();
    ModelingExercise classExercise = database.findModelingExerciseWithTitle(course.getExercises(), "ClassDiagram");
    ModelingSubmission modelingSubmission = ModelFactory.generateModelingSubmission(FileUtils.loadFileFromResources("test-data/model-submission/empty-class-diagram.json"), true);
    modelingSubmission = database.addModelingSubmission(classExercise, modelingSubmission, login);
    String url = "/api/programming-submissions/" + modelingSubmission.getParticipation().getId() + "/trigger-failed-build";
    request.postWithoutLocation(url, null, HttpStatus.NOT_FOUND, new HttpHeaders());
}
Also used : HttpHeaders(org.springframework.http.HttpHeaders) ModelingSubmission(de.tum.in.www1.artemis.domain.modeling.ModelingSubmission) ModelingExercise(de.tum.in.www1.artemis.domain.modeling.ModelingExercise) WithMockUser(org.springframework.security.test.context.support.WithMockUser) AbstractSpringIntegrationBambooBitbucketJiraTest(de.tum.in.www1.artemis.AbstractSpringIntegrationBambooBitbucketJiraTest) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 63 with ModelingSubmission

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

the class AssessmentServiceTest method createModelingExerciseSubmissionAndCalculateScore.

@Test
@WithMockUser(username = "instructor1", roles = "INSTRUCTOR")
public void createModelingExerciseSubmissionAndCalculateScore() {
    ModelingExercise exercise = createModelingExerciseWithSGI(course1);
    Submission submissionWithoutResult = new ModelingSubmission();
    submissionWithoutResult.setSubmissionDate(pastTimestamp.plusMinutes(3L));
    submissionWithoutResult = database.addSubmission(exercise, submissionWithoutResult, "student1");
    database.addSubmission((StudentParticipation) submissionWithoutResult.getParticipation(), submissionWithoutResult);
    List<Feedback> feedbacks = createFeedback(exercise);
    var result = new Result();
    result.setSubmission(submissionWithoutResult);
    result.setFeedbacks(feedbacks);
    result.setParticipation(submissionWithoutResult.getParticipation());
    submissionWithoutResult.addResult(result);
    resultRepository.submitResult(result, exercise, exerciseDateService.getDueDate(result.getParticipation()));
    resultRepository.save(result);
    assertThat(result.getResultString()).isEqualTo("6 of 7 points");
}
Also used : 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) WithMockUser(org.springframework.security.test.context.support.WithMockUser) AbstractSpringIntegrationBambooBitbucketJiraTest(de.tum.in.www1.artemis.AbstractSpringIntegrationBambooBitbucketJiraTest) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 64 with ModelingSubmission

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

the class ModelingExerciseImportService method copySubmission.

/**
 * This helper function does a hard copy of the {@code originalSubmission} and stores the values in {@code newSubmission}.
 * To copy the submission results this function calls {@link ExerciseImportService#copyExampleResult(Result, Submission, Map)} respectively.
 *
 * @param originalSubmission  The original submission to be copied.
 * @param gradingInstructionCopyTracker  The mapping from original GradingInstruction Ids to new GradingInstruction instances.
 * @return The cloned submission
 */
Submission copySubmission(Submission originalSubmission, Map<Long, GradingInstruction> gradingInstructionCopyTracker) {
    ModelingSubmission newSubmission = new ModelingSubmission();
    if (originalSubmission != null) {
        log.debug("Copying the Submission to new ExampleSubmission: {}", newSubmission);
        newSubmission.setExampleSubmission(true);
        newSubmission.setSubmissionDate(originalSubmission.getSubmissionDate());
        newSubmission.setType(originalSubmission.getType());
        newSubmission.setParticipation(originalSubmission.getParticipation());
        newSubmission.setExplanationText(((ModelingSubmission) originalSubmission).getExplanationText());
        newSubmission.setModel(((ModelingSubmission) originalSubmission).getModel());
        newSubmission = submissionRepository.saveAndFlush(newSubmission);
        if (originalSubmission.getLatestResult() != null) {
            newSubmission.addResult(copyExampleResult(originalSubmission.getLatestResult(), newSubmission, gradingInstructionCopyTracker));
        }
        newSubmission = submissionRepository.saveAndFlush(newSubmission);
    }
    return newSubmission;
}
Also used : ModelingSubmission(de.tum.in.www1.artemis.domain.modeling.ModelingSubmission)

Example 65 with ModelingSubmission

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

the class ModelingSubmissionService method findRandomSubmissionWithoutExistingAssessment.

/**
 * retrieves a modeling submission without assessment for the specified correction round and potentially locks the submission
 *
 * In case Compass is supported (and activated), this method also assigns a result with feedback suggestions to the submission
 *
 * @param lockSubmission whether the submission should be locked
 * @param correctionRound the correction round (0 = first correction, 1 = second correction
 * @param modelingExercise the modeling exercise for which a
 * @param isExamMode whether the exercise belongs to an exam
 * @return a random modeling submission (potentially based on compass)
 */
public ModelingSubmission findRandomSubmissionWithoutExistingAssessment(boolean lockSubmission, int correctionRound, ModelingExercise modelingExercise, boolean isExamMode) {
    var submissionWithoutResult = super.getRandomSubmissionEligibleForNewAssessment(modelingExercise, isExamMode, correctionRound).orElseThrow(() -> new EntityNotFoundException("Modeling submission for exercise " + modelingExercise.getId() + " could not be found"));
    ModelingSubmission modelingSubmission = (ModelingSubmission) submissionWithoutResult;
    if (lockSubmission) {
        if (compassService.isSupported(modelingExercise) && correctionRound == 0L) {
            modelingSubmission = assignResultWithFeedbackSuggestionsToSubmission(modelingSubmission, modelingExercise);
            setNumberOfAffectedSubmissionsPerElement(modelingSubmission);
        }
        lockSubmission(modelingSubmission, correctionRound);
    }
    return modelingSubmission;
}
Also used : ModelingSubmission(de.tum.in.www1.artemis.domain.modeling.ModelingSubmission) EntityNotFoundException(de.tum.in.www1.artemis.web.rest.errors.EntityNotFoundException)

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