Search in sources :

Example 11 with Participation

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

the class DatabaseUtilService method addModelingSubmissionWithEmptyResult.

/**
 * Stores for the given model a submission of the user and initiates the corresponding Result
 *
 * @param exercise exercise the submission belongs to
 * @param model    ModelingSubmission json as string contained in the submission
 * @param login    of the user the submission belongs to
 * @return submission stored in the modelingSubmissionRepository
 */
public ModelingSubmission addModelingSubmissionWithEmptyResult(ModelingExercise exercise, String model, String login) {
    StudentParticipation participation = createAndSaveParticipationForExercise(exercise, login);
    ModelingSubmission submission = ModelFactory.generateModelingSubmission(model, true);
    submission = modelSubmissionService.save(submission, exercise, login);
    Result result = new Result();
    result = resultRepo.save(result);
    result.setSubmission(submission);
    submission.addResult(result);
    participation.addResult(result);
    studentParticipationRepo.save(participation);
    modelingSubmissionRepo.save(submission);
    resultRepo.save(result);
    return 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 12 with Participation

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

the class DatabaseUtilService method saveTextSubmissionWithResultAndAssessor.

private TextSubmission saveTextSubmissionWithResultAndAssessor(TextExercise exercise, TextSubmission submission, String studentLogin, Long teamId, String assessorLogin) {
    StudentParticipation participation = Optional.ofNullable(studentLogin).map(login -> createAndSaveParticipationForExercise(exercise, login)).orElseGet(() -> addTeamParticipationForExercise(exercise, teamId));
    submissionRepository.save(submission);
    participation.addSubmission(submission);
    Result result = new Result();
    result.setAssessor(getUserByLogin(assessorLogin));
    result.setScore(100D);
    if (exercise.getReleaseDate() != null) {
        result.setCompletionDate(exercise.getReleaseDate());
    } else {
        // exam exercises do not have a release date
        result.setCompletionDate(ZonedDateTime.now());
    }
    result = resultRepo.save(result);
    result.setSubmission(submission);
    submission.setParticipation(participation);
    submission.addResult(result);
    submission.getParticipation().addResult(result);
    submission = textSubmissionRepo.save(submission);
    resultRepo.save(result);
    studentParticipationRepo.save(participation);
    submission = textSubmissionRepo.save(submission);
    return submission;
}
Also used : JsonObject(com.google.gson.JsonObject) TypeToken(com.google.gson.reflect.TypeToken) de.tum.in.www1.artemis.repository(de.tum.in.www1.artemis.repository) URL(java.net.URL) AnswerPost(de.tum.in.www1.artemis.domain.metis.AnswerPost) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) ZonedDateTime(java.time.ZonedDateTime) ExerciseHintRepository(de.tum.in.www1.artemis.repository.hestia.ExerciseHintRepository) Autowired(org.springframework.beans.factory.annotation.Autowired) TextAssessmentEvent(de.tum.in.www1.artemis.domain.analytics.TextAssessmentEvent) StudentExam(de.tum.in.www1.artemis.domain.exam.StudentExam) PageableSearchDTO(de.tum.in.www1.artemis.web.rest.dto.PageableSearchDTO) PostRepository(de.tum.in.www1.artemis.repository.metis.PostRepository) TestSecurityContextHolder(org.springframework.security.test.context.TestSecurityContextHolder) ExerciseGroup(de.tum.in.www1.artemis.domain.exam.ExerciseGroup) Gson(com.google.gson.Gson) Duration(java.time.Duration) CourseWideContext(de.tum.in.www1.artemis.domain.metis.CourseWideContext) Post(de.tum.in.www1.artemis.domain.metis.Post) SecurityContextHolder(org.springframework.security.core.context.SecurityContextHolder) Path(java.nio.file.Path) SubmissionPolicy(de.tum.in.www1.artemis.domain.submissionpolicy.SubmissionPolicy) NotNull(javax.validation.constraints.NotNull) Role(de.tum.in.www1.artemis.security.Role) Collectors(java.util.stream.Collectors) StandardCharsets(java.nio.charset.StandardCharsets) ZoneId(java.time.ZoneId) de.tum.in.www1.artemis.domain.participation(de.tum.in.www1.artemis.domain.participation) GrantedAuthority(org.springframework.security.core.GrantedAuthority) Assertions.fail(org.assertj.core.api.Assertions.fail) de.tum.in.www1.artemis.domain(de.tum.in.www1.artemis.domain) SecurityContext(org.springframework.security.core.context.SecurityContext) UsernamePasswordAuthenticationToken(org.springframework.security.authentication.UsernamePasswordAuthenticationToken) Authentication(org.springframework.security.core.Authentication) ModelingExercise(de.tum.in.www1.artemis.domain.modeling.ModelingExercise) java.util(java.util) PasswordService(de.tum.in.www1.artemis.service.user.PasswordService) AnswerPostRepository(de.tum.in.www1.artemis.repository.metis.AnswerPostRepository) CSVReader(com.opencsv.CSVReader) SimpleGrantedAuthority(org.springframework.security.core.authority.SimpleGrantedAuthority) TextPlagiarismResult(de.tum.in.www1.artemis.domain.plagiarism.text.TextPlagiarismResult) Value(org.springframework.beans.factory.annotation.Value) de.tum.in.www1.artemis.domain.lecture(de.tum.in.www1.artemis.domain.lecture) Service(org.springframework.stereotype.Service) ThreadLocalRandom(java.util.concurrent.ThreadLocalRandom) ModelingSubmission(de.tum.in.www1.artemis.domain.modeling.ModelingSubmission) Exam(de.tum.in.www1.artemis.domain.exam.Exam) de.tum.in.www1.artemis.service(de.tum.in.www1.artemis.service) ModelingPlagiarismResult(de.tum.in.www1.artemis.domain.plagiarism.modeling.ModelingPlagiarismResult) JsonParser.parseString(com.google.gson.JsonParser.parseString) Files(java.nio.file.Files) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) IOException(java.io.IOException) de.tum.in.www1.artemis.domain.quiz(de.tum.in.www1.artemis.domain.quiz) ResourceUtils(org.springframework.util.ResourceUtils) ExerciseHint(de.tum.in.www1.artemis.domain.hestia.ExerciseHint) FileReader(java.io.FileReader) LinkedMultiValueMap(org.springframework.util.LinkedMultiValueMap) de.tum.in.www1.artemis.domain.enumeration(de.tum.in.www1.artemis.domain.enumeration) TextPlagiarismResult(de.tum.in.www1.artemis.domain.plagiarism.text.TextPlagiarismResult) ModelingPlagiarismResult(de.tum.in.www1.artemis.domain.plagiarism.modeling.ModelingPlagiarismResult)

Example 13 with Participation

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

the class DatabaseUtilService method saveFileUploadSubmissionWithResultAndAssessorFeedback.

public FileUploadSubmission saveFileUploadSubmissionWithResultAndAssessorFeedback(FileUploadExercise exercise, FileUploadSubmission fileUploadSubmission, String login, String assessorLogin, List<Feedback> feedbacks) {
    StudentParticipation participation = createAndSaveParticipationForExercise(exercise, login);
    submissionRepository.save(fileUploadSubmission);
    participation.addSubmission(fileUploadSubmission);
    Result result = new Result();
    result.setAssessor(getUserByLogin(assessorLogin));
    result.setScore(100D);
    result.setParticipation(participation);
    result.setResultString(exercise.getMaxPoints(), exercise.getMaxPoints());
    if (exercise.getReleaseDate() != null) {
        result.setCompletionDate(exercise.getReleaseDate());
    } else {
        // exam exercises do not have a release date
        result.setCompletionDate(ZonedDateTime.now());
    }
    result.setFeedbacks(feedbacks);
    result = resultRepo.save(result);
    for (Feedback feedback : feedbacks) {
        feedback.setResult(result);
    }
    result = resultRepo.save(result);
    result.setSubmission(fileUploadSubmission);
    fileUploadSubmission.setParticipation(participation);
    fileUploadSubmission.addResult(result);
    fileUploadSubmission.getParticipation().addResult(result);
    fileUploadSubmission = fileUploadSubmissionRepo.save(fileUploadSubmission);
    studentParticipationRepo.save(participation);
    return fileUploadSubmission;
}
Also used : TextPlagiarismResult(de.tum.in.www1.artemis.domain.plagiarism.text.TextPlagiarismResult) ModelingPlagiarismResult(de.tum.in.www1.artemis.domain.plagiarism.modeling.ModelingPlagiarismResult)

Example 14 with Participation

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

the class DatabaseUtilService method addComplaints.

public void addComplaints(String studentLogin, Participation participation, int numberOfComplaints, ComplaintType complaintType) {
    for (int i = 0; i < numberOfComplaints; i++) {
        Result dummyResult = new Result().participation(participation);
        dummyResult = resultRepo.save(dummyResult);
        Complaint complaint = new Complaint().participant(getUserByLogin(studentLogin)).result(dummyResult).complaintType(complaintType);
        complaintRepo.save(complaint);
    }
}
Also used : ExerciseHint(de.tum.in.www1.artemis.domain.hestia.ExerciseHint) TextPlagiarismResult(de.tum.in.www1.artemis.domain.plagiarism.text.TextPlagiarismResult) ModelingPlagiarismResult(de.tum.in.www1.artemis.domain.plagiarism.modeling.ModelingPlagiarismResult)

Example 15 with Participation

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

the class RepositoryResource method pullChanges.

/**
 * Pull into the participation repository.
 *
 * @param domainId that serves as an abstract identifier for retrieving the repository.
 * @return ResponseEntity with appropriate status (e.g. ok or forbidden).
 */
public ResponseEntity<Void> pullChanges(Long domainId) {
    log.debug("REST request to commit Repository for domainId : {}", domainId);
    return executeAndCheckForExceptions(() -> {
        Repository repository = getRepository(domainId, RepositoryActionType.READ, true);
        repositoryService.pullChanges(repository);
        return new ResponseEntity<>(HttpStatus.OK);
    });
}
Also used : UserRepository(de.tum.in.www1.artemis.repository.UserRepository) ProgrammingExerciseRepository(de.tum.in.www1.artemis.repository.ProgrammingExerciseRepository) ResponseEntity(org.springframework.http.ResponseEntity)

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