Search in sources :

Example 21 with Submission

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

the class LearningGoalService method calculateLearningGoalCourseProgress.

/**
 * Calculate the progress in a learning goal for a whole course
 *
 * @param useParticipantScoreTable use the participant score table instead of going through participation -> submission -> result
 * @param learningGoal             learning goal to get the progress for
 * @return progress of the course in the learning goal
 */
public CourseLearningGoalProgress calculateLearningGoalCourseProgress(LearningGoal learningGoal, boolean useParticipantScoreTable) {
    CourseLearningGoalProgress courseLearningGoalProgress = new CourseLearningGoalProgress();
    courseLearningGoalProgress.courseId = learningGoal.getCourse().getId();
    courseLearningGoalProgress.learningGoalId = learningGoal.getId();
    courseLearningGoalProgress.learningGoalTitle = learningGoal.getTitle();
    courseLearningGoalProgress.totalPointsAchievableByStudentsInLearningGoal = 0.0;
    courseLearningGoalProgress.averagePointsAchievedByStudentInLearningGoal = 0.0;
    // The progress will be calculated from a subset of the connected lecture units (currently only from released exerciseUnits)
    List<ExerciseUnit> exerciseUnitsUsableForProgressCalculation = learningGoal.getLectureUnits().parallelStream().filter(LectureUnit::isVisibleToStudents).filter(lectureUnit -> lectureUnit instanceof ExerciseUnit).map(lectureUnit -> (ExerciseUnit) lectureUnit).collect(Collectors.toList());
    Set<CourseLearningGoalProgress.CourseLectureUnitProgress> progressInLectureUnits = this.calculateExerciseUnitsProgressForCourse(exerciseUnitsUsableForProgressCalculation, useParticipantScoreTable);
    // updating learningGoalPerformance by summing up the points of the individual lecture unit progress
    courseLearningGoalProgress.totalPointsAchievableByStudentsInLearningGoal = progressInLectureUnits.stream().map(lectureUnitProgress -> lectureUnitProgress.totalPointsAchievableByStudentsInLectureUnit).reduce(0.0, Double::sum);
    courseLearningGoalProgress.averagePointsAchievedByStudentInLearningGoal = progressInLectureUnits.stream().map(lectureUnitProgress -> (lectureUnitProgress.averageScoreAchievedByStudentInLectureUnit / 100.0) * lectureUnitProgress.totalPointsAchievableByStudentsInLectureUnit).reduce(0.0, Double::sum);
    courseLearningGoalProgress.progressInLectureUnits = new ArrayList<>(progressInLectureUnits);
    return courseLearningGoalProgress;
}
Also used : java.util(java.util) TeamScore(de.tum.in.www1.artemis.domain.scores.TeamScore) de.tum.in.www1.artemis.repository(de.tum.in.www1.artemis.repository) StudentScore(de.tum.in.www1.artemis.domain.scores.StudentScore) Collectors(java.util.stream.Collectors) CourseLearningGoalProgress(de.tum.in.www1.artemis.web.rest.dto.CourseLearningGoalProgress) Stream(java.util.stream.Stream) de.tum.in.www1.artemis.domain(de.tum.in.www1.artemis.domain) LectureUnit(de.tum.in.www1.artemis.domain.lecture.LectureUnit) Service(org.springframework.stereotype.Service) ExerciseUnit(de.tum.in.www1.artemis.domain.lecture.ExerciseUnit) CourseExerciseStatisticsDTO(de.tum.in.www1.artemis.web.rest.dto.CourseExerciseStatisticsDTO) StudentParticipation(de.tum.in.www1.artemis.domain.participation.StudentParticipation) ParticipantScore(de.tum.in.www1.artemis.domain.scores.ParticipantScore) IndividualLearningGoalProgress(de.tum.in.www1.artemis.web.rest.dto.IndividualLearningGoalProgress) CourseLearningGoalProgress(de.tum.in.www1.artemis.web.rest.dto.CourseLearningGoalProgress) ExerciseUnit(de.tum.in.www1.artemis.domain.lecture.ExerciseUnit)

Example 22 with Submission

use of de.tum.in.www1.artemis.domain.Submission 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 #copyExampleResult(Result, Submission)} respectively.
 *
 * @param originalSubmission The original submission to be copied.
 * @return The cloned submission
 */
@Override
Submission copySubmission(Submission originalSubmission) {
    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));
        }
        newSubmission = submissionRepository.saveAndFlush(newSubmission);
    }
    return newSubmission;
}
Also used : ModelingSubmission(de.tum.in.www1.artemis.domain.modeling.ModelingSubmission)

Example 23 with Submission

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

the class JenkinsService method onBuildCompleted.

@Override
public Result onBuildCompleted(ProgrammingExerciseParticipation participation, Object requestBody) {
    final var buildResult = TestResultsDTO.convert(requestBody);
    var newResult = createResultFromBuildResult(buildResult, participation);
    // Fetch submission or create a fallback
    var latestSubmission = super.getSubmissionForBuildResult(participation.getId(), buildResult).orElseGet(() -> createAndSaveFallbackSubmission(participation, buildResult));
    latestSubmission.setBuildFailed("No tests found".equals(newResult.getResultString()));
    // Parse, filter, and save the build logs if they exist
    if (buildResult.getLogs() != null) {
        ProgrammingLanguage programmingLanguage = participation.getProgrammingExercise().getProgrammingLanguage();
        List<BuildLogEntry> buildLogEntries = JenkinsBuildLogParseUtils.parseBuildLogsFromJenkinsLogs(buildResult.getLogs());
        buildLogEntries = filterUnnecessaryLogs(buildLogEntries, programmingLanguage);
        buildLogEntries = buildLogService.saveBuildLogs(buildLogEntries, latestSubmission);
        // Set the received logs in order to avoid duplicate entries (this removes existing logs)
        latestSubmission.setBuildLogEntries(buildLogEntries);
    }
    // Note: we only set one side of the relationship because we don't know yet whether the result will actually be saved
    newResult.setSubmission(latestSubmission);
    newResult.setRatedIfNotExceeded(exerciseDateService.getDueDate(participation).orElse(null), latestSubmission);
    return newResult;
}
Also used : ProgrammingLanguage(de.tum.in.www1.artemis.domain.enumeration.ProgrammingLanguage)

Example 24 with Submission

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

the class DatabaseUtilService method addModelingAssessmentForSubmission.

public Result addModelingAssessmentForSubmission(ModelingExercise exercise, ModelingSubmission submission, String path, String login, boolean submit) throws Exception {
    List<Feedback> feedbackList = loadAssessmentFomResources(path);
    Result result = assessmentService.saveManualAssessment(submission, feedbackList, null);
    result.setParticipation(submission.getParticipation().results(null));
    result.setAssessor(getUserByLogin(login));
    resultRepo.save(result);
    if (submit) {
        assessmentService.submitManualAssessment(result.getId(), exercise, submission.getSubmissionDate());
    }
    return resultRepo.findWithEagerSubmissionAndFeedbackAndAssessorById(result.getId()).get();
}
Also used : TextPlagiarismResult(de.tum.in.www1.artemis.domain.plagiarism.text.TextPlagiarismResult) ModelingPlagiarismResult(de.tum.in.www1.artemis.domain.plagiarism.modeling.ModelingPlagiarismResult)

Example 25 with Submission

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

the class DatabaseUtilService method addResultToParticipation.

public Result addResultToParticipation(Participation participation, Submission submission) {
    Result result = new Result().participation(participation).resultString("x of y passed").successful(true).score(100D);
    result = resultRepo.save(result);
    result.setSubmission(submission);
    submission.addResult(result);
    submission.setParticipation(participation);
    submissionRepository.save(submission);
    return result;
}
Also used : TextPlagiarismResult(de.tum.in.www1.artemis.domain.plagiarism.text.TextPlagiarismResult) ModelingPlagiarismResult(de.tum.in.www1.artemis.domain.plagiarism.modeling.ModelingPlagiarismResult)

Aggregations

Test (org.junit.jupiter.api.Test)226 WithMockUser (org.springframework.security.test.context.support.WithMockUser)216 ModelingSubmission (de.tum.in.www1.artemis.domain.modeling.ModelingSubmission)178 StudentParticipation (de.tum.in.www1.artemis.domain.participation.StudentParticipation)153 ModelingExercise (de.tum.in.www1.artemis.domain.modeling.ModelingExercise)72 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)56 EntityNotFoundException (de.tum.in.www1.artemis.web.rest.errors.EntityNotFoundException)52 PreAuthorize (org.springframework.security.access.prepost.PreAuthorize)48 ModelingPlagiarismResult (de.tum.in.www1.artemis.domain.plagiarism.modeling.ModelingPlagiarismResult)44 Collectors (java.util.stream.Collectors)42 TextPlagiarismResult (de.tum.in.www1.artemis.domain.plagiarism.text.TextPlagiarismResult)40 ZonedDateTime (java.time.ZonedDateTime)40 java.util (java.util)40 HttpHeaders (org.springframework.http.HttpHeaders)40 LinkedMultiValueMap (org.springframework.util.LinkedMultiValueMap)40 Participation (de.tum.in.www1.artemis.domain.participation.Participation)38 de.tum.in.www1.artemis.domain (de.tum.in.www1.artemis.domain)34 BadRequestAlertException (de.tum.in.www1.artemis.web.rest.errors.BadRequestAlertException)34 ProgrammingExerciseStudentParticipation (de.tum.in.www1.artemis.domain.participation.ProgrammingExerciseStudentParticipation)32 de.tum.in.www1.artemis.repository (de.tum.in.www1.artemis.repository)30