Search in sources :

Example 21 with Participation

use of de.tum.in.www1.artemis.domain.participation.Participation in project ArTEMiS by ls1intum.

the class DatabaseUtilService method addAssessmentToExercise.

/**
 * Adds a result to all submissions of an exercise
 *
 * @param exercise - the exercise of which the submissions are assessed
 * @param assessor - the assessor which is set for the results of the submission
 */
public void addAssessmentToExercise(Exercise exercise, User assessor) {
    var participations = studentParticipationRepo.findByExerciseIdWithEagerSubmissionsResultAssessor(exercise.getId());
    participations.forEach(participation -> {
        Submission submission = submissionRepository.findAllByParticipationId(participation.getId()).get(0);
        submission = submissionRepository.findOneWithEagerResultAndFeedback(submission.getId());
        participation = studentParticipationRepo.findWithEagerResultsById(participation.getId()).orElseThrow();
        Result result = generateResult(submission, assessor);
        submission.addResult(result);
        participation.addResult(result);
        studentParticipationRepo.save(participation);
        submissionRepository.save(submission);
    });
}
Also used : ModelingSubmission(de.tum.in.www1.artemis.domain.modeling.ModelingSubmission) TextPlagiarismResult(de.tum.in.www1.artemis.domain.plagiarism.text.TextPlagiarismResult) ModelingPlagiarismResult(de.tum.in.www1.artemis.domain.plagiarism.modeling.ModelingPlagiarismResult)

Example 22 with Participation

use of de.tum.in.www1.artemis.domain.participation.Participation in project ArTEMiS by ls1intum.

the class DatabaseUtilService method addModelingSubmissionWithResultAndAssessor.

public ModelingSubmission addModelingSubmissionWithResultAndAssessor(ModelingExercise exercise, ModelingSubmission submission, String login, String assessorLogin) {
    StudentParticipation participation = createAndSaveParticipationForExercise(exercise, login);
    participation.addSubmission(submission);
    submission = modelingSubmissionRepo.save(submission);
    Result result = new Result();
    result.setAssessor(getUserByLogin(assessorLogin));
    result.setAssessmentType(AssessmentType.MANUAL);
    result = resultRepo.save(result);
    submission = modelingSubmissionRepo.save(submission);
    studentParticipationRepo.save(participation);
    result = resultRepo.save(result);
    result.setSubmission(submission);
    submission.setParticipation(participation);
    submission.addResult(result);
    submission.getParticipation().addResult(result);
    submission = modelingSubmissionRepo.save(submission);
    studentParticipationRepo.save(participation);
    return submission;
}
Also used : TextPlagiarismResult(de.tum.in.www1.artemis.domain.plagiarism.text.TextPlagiarismResult) ModelingPlagiarismResult(de.tum.in.www1.artemis.domain.plagiarism.modeling.ModelingPlagiarismResult)

Example 23 with Participation

use of de.tum.in.www1.artemis.domain.participation.Participation in project ArTEMiS by ls1intum.

the class DatabaseUtilService method addAutomaticAssessmentToExercise.

/**
 * Adds an automatic assessment to all submissions of an exercise
 *
 * @param exercise - the exercise of which the submissions are assessed
 */
public void addAutomaticAssessmentToExercise(Exercise exercise) {
    var participations = studentParticipationRepo.findByExerciseIdWithEagerSubmissionsResultAssessor(exercise.getId());
    participations.forEach(participation -> {
        Submission submission = submissionRepository.findAllByParticipationId(participation.getId()).get(0);
        submission = submissionRepository.findOneWithEagerResultAndFeedback(submission.getId());
        participation = studentParticipationRepo.findWithEagerResultsById(participation.getId()).orElseThrow();
        Result result = generateResult(submission, null);
        result.setAssessmentType(AssessmentType.AUTOMATIC);
        submission.addResult(result);
        participation.addResult(result);
        studentParticipationRepo.save(participation);
        submissionRepository.save(submission);
    });
}
Also used : ModelingSubmission(de.tum.in.www1.artemis.domain.modeling.ModelingSubmission) TextPlagiarismResult(de.tum.in.www1.artemis.domain.plagiarism.text.TextPlagiarismResult) ModelingPlagiarismResult(de.tum.in.www1.artemis.domain.plagiarism.modeling.ModelingPlagiarismResult)

Example 24 with Participation

use of de.tum.in.www1.artemis.domain.participation.Participation in project ArTEMiS by ls1intum.

the class GitServiceIntTest method testGetOrCheckoutRepositoryForExistingRepo.

@Test
public void testGetOrCheckoutRepositoryForExistingRepo() throws IOException, GitAPIException {
    Participation participation = new Participation();
    participation.setRepositoryUrl(remoteTestRepo);
    Repository repo = gitService.getOrCheckoutRepository(participation);
    Repository repo2 = gitService.getOrCheckoutRepository(participation);
    assertThat(repo.getDirectory()).isEqualTo(repo2.getDirectory());
    assertThat(repo2.getBranch()).isEqualTo("master");
    assertThat(repo2.getDirectory()).exists();
    gitService.deleteLocalRepository(repo2);
}
Also used : Participation(de.tum.in.www1.artemis.domain.Participation) Repository(de.tum.in.www1.artemis.domain.Repository) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 25 with Participation

use of de.tum.in.www1.artemis.domain.participation.Participation in project ArTEMiS by ls1intum.

the class GitServiceIntTest method testDeleteLocalRepository.

@Test
public void testDeleteLocalRepository() throws IOException, GitAPIException {
    Participation participation = new Participation();
    participation.setRepositoryUrl(remoteTestRepo);
    Repository repo = gitService.getOrCheckoutRepository(participation);
    assertThat(repo.getDirectory()).exists();
    gitService.deleteLocalRepository(repo);
    assertThat(repo.getDirectory()).doesNotExist();
}
Also used : Participation(de.tum.in.www1.artemis.domain.Participation) Repository(de.tum.in.www1.artemis.domain.Repository) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Aggregations

StudentParticipation (de.tum.in.www1.artemis.domain.participation.StudentParticipation)181 WithMockUser (org.springframework.security.test.context.support.WithMockUser)138 Test (org.junit.jupiter.api.Test)124 ProgrammingExerciseStudentParticipation (de.tum.in.www1.artemis.domain.participation.ProgrammingExerciseStudentParticipation)70 Participation (de.tum.in.www1.artemis.domain.participation.Participation)54 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)50 ZonedDateTime (java.time.ZonedDateTime)47 ModelingSubmission (de.tum.in.www1.artemis.domain.modeling.ModelingSubmission)44 PreAuthorize (org.springframework.security.access.prepost.PreAuthorize)44 ModelingExercise (de.tum.in.www1.artemis.domain.modeling.ModelingExercise)42 EntityNotFoundException (de.tum.in.www1.artemis.web.rest.errors.EntityNotFoundException)42 AbstractSpringIntegrationBambooBitbucketJiraTest (de.tum.in.www1.artemis.AbstractSpringIntegrationBambooBitbucketJiraTest)38 QuizExercise (de.tum.in.www1.artemis.domain.quiz.QuizExercise)38 TextPlagiarismResult (de.tum.in.www1.artemis.domain.plagiarism.text.TextPlagiarismResult)34 Collectors (java.util.stream.Collectors)34 HttpHeaders (org.springframework.http.HttpHeaders)34 de.tum.in.www1.artemis.domain (de.tum.in.www1.artemis.domain)33 Result (de.tum.in.www1.artemis.domain.Result)33 Exam (de.tum.in.www1.artemis.domain.exam.Exam)32 ModelingPlagiarismResult (de.tum.in.www1.artemis.domain.plagiarism.modeling.ModelingPlagiarismResult)32