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