Search in sources :

Example 26 with ProgrammingSubmission

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

the class JenkinsService method getLatestBuildLogs.

@Override
public List<BuildLogEntry> getLatestBuildLogs(ProgrammingSubmission programmingSubmission) {
    ProgrammingExerciseParticipation programmingExerciseParticipation = (ProgrammingExerciseParticipation) programmingSubmission.getParticipation();
    String projectKey = programmingExerciseParticipation.getProgrammingExercise().getProjectKey();
    String buildPlanId = programmingExerciseParticipation.getBuildPlanId();
    ProgrammingLanguage programmingLanguage = programmingExerciseParticipation.getProgrammingExercise().getProgrammingLanguage();
    try {
        final var build = jenkinsJobService.getJobInFolder(projectKey, buildPlanId).getLastBuild();
        List<BuildLogEntry> buildLogEntries;
        // Attempt to parse pipeline logs
        final String pipelineLogs = build.details().getConsoleOutputText();
        if (pipelineLogs != null && pipelineLogs.contains("[Pipeline] Start of Pipeline")) {
            buildLogEntries = JenkinsBuildLogParseUtils.parseBuildLogsFromJenkinsLogs(List.of(pipelineLogs.split("\n")));
        } else {
            // Fallback to legacy logs
            final var logHtml = Jsoup.parse(build.details().getConsoleOutputHtml()).body();
            buildLogEntries = JenkinsBuildLogParseUtils.parseLogsLegacy(logHtml);
        }
        // Filter and save build logs
        buildLogEntries = filterUnnecessaryLogs(buildLogEntries, programmingLanguage);
        buildLogEntries = buildLogService.saveBuildLogs(buildLogEntries, programmingSubmission);
        programmingSubmission.setBuildLogEntries(buildLogEntries);
        programmingSubmissionRepository.save(programmingSubmission);
        return buildLogEntries;
    } catch (IOException e) {
        log.error(e.getMessage(), e);
        throw new JenkinsException(e.getMessage(), e);
    }
}
Also used : ProgrammingExerciseParticipation(de.tum.in.www1.artemis.domain.participation.ProgrammingExerciseParticipation) JenkinsException(de.tum.in.www1.artemis.exception.JenkinsException) ProgrammingLanguage(de.tum.in.www1.artemis.domain.enumeration.ProgrammingLanguage) IOException(java.io.IOException)

Example 27 with ProgrammingSubmission

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

the class ComplaintResource method filterOutUselessDataFromComplaint.

private void filterOutUselessDataFromComplaint(Complaint complaint) {
    if (complaint.getResult() == null) {
        return;
    }
    StudentParticipation originalParticipation = (StudentParticipation) complaint.getResult().getParticipation();
    if (originalParticipation != null && originalParticipation.getExercise() != null) {
        Exercise exerciseWithOnlyTitle = originalParticipation.getExercise();
        if (exerciseWithOnlyTitle instanceof TextExercise) {
            exerciseWithOnlyTitle = new TextExercise();
        } else if (exerciseWithOnlyTitle instanceof ModelingExercise) {
            exerciseWithOnlyTitle = new ModelingExercise();
        } else if (exerciseWithOnlyTitle instanceof FileUploadExercise) {
            exerciseWithOnlyTitle = new FileUploadExercise();
        } else if (exerciseWithOnlyTitle instanceof ProgrammingExercise) {
            exerciseWithOnlyTitle = new ProgrammingExercise();
        }
        exerciseWithOnlyTitle.setTitle(originalParticipation.getExercise().getTitle());
        exerciseWithOnlyTitle.setId(originalParticipation.getExercise().getId());
        originalParticipation.setExercise(exerciseWithOnlyTitle);
    }
    Submission originalSubmission = complaint.getResult().getSubmission();
    if (originalSubmission != null) {
        Submission submissionWithOnlyId;
        if (originalSubmission instanceof TextSubmission) {
            submissionWithOnlyId = new TextSubmission();
        } else if (originalSubmission instanceof ModelingSubmission) {
            submissionWithOnlyId = new ModelingSubmission();
        } else if (originalSubmission instanceof FileUploadSubmission) {
            submissionWithOnlyId = new FileUploadSubmission();
        } else if (originalSubmission instanceof ProgrammingSubmission) {
            submissionWithOnlyId = new ProgrammingSubmission();
        } else {
            return;
        }
        submissionWithOnlyId.setId(originalSubmission.getId());
        complaint.getResult().setSubmission(submissionWithOnlyId);
    }
}
Also used : ModelingExercise(de.tum.in.www1.artemis.domain.modeling.ModelingExercise) 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) StudentParticipation(de.tum.in.www1.artemis.domain.participation.StudentParticipation)

Example 28 with ProgrammingSubmission

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

the class LearningGoalIntegrationTest method createParticipationSubmissionAndResult.

private void createParticipationSubmissionAndResult(Long idOfExercise, Participant participant, Double pointsOfExercise, Double bonusPointsOfExercise, long scoreAwarded, boolean rated) {
    Exercise exercise = exerciseRepository.findById(idOfExercise).get();
    if (!exercise.getMaxPoints().equals(pointsOfExercise)) {
        exercise.setMaxPoints(pointsOfExercise);
    }
    if (!exercise.getBonusPoints().equals(bonusPointsOfExercise)) {
        exercise.setBonusPoints(bonusPointsOfExercise);
    }
    exercise = exerciseRepository.save(exercise);
    StudentParticipation studentParticipation = participationService.startExercise(exercise, participant, false);
    Submission submission;
    if (exercise instanceof ProgrammingExercise) {
        submission = new ProgrammingSubmission();
    } else if (exercise instanceof ModelingExercise) {
        submission = new ModelingSubmission();
    } else if (exercise instanceof TextExercise) {
        submission = new TextSubmission();
    } else if (exercise instanceof FileUploadExercise) {
        submission = new FileUploadSubmission();
    } else if (exercise instanceof QuizExercise) {
        submission = new QuizSubmission();
    } else {
        throw new RuntimeException("Unsupported exercise type: " + exercise);
    }
    submission.setType(SubmissionType.MANUAL);
    submission.setParticipation(studentParticipation);
    submission = submissionRepository.save(submission);
    // result
    Result result = ModelFactory.generateResult(rated, scoreAwarded);
    result.setParticipation(studentParticipation);
    result.setCompletionDate(ZonedDateTime.now());
    result = resultRepository.save(result);
    submission.addResult(result);
    result.setSubmission(submission);
    submissionRepository.save(submission);
}
Also used : ModelingSubmission(de.tum.in.www1.artemis.domain.modeling.ModelingSubmission) QuizSubmission(de.tum.in.www1.artemis.domain.quiz.QuizSubmission) 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) QuizExercise(de.tum.in.www1.artemis.domain.quiz.QuizExercise) QuizSubmission(de.tum.in.www1.artemis.domain.quiz.QuizSubmission) QuizExercise(de.tum.in.www1.artemis.domain.quiz.QuizExercise) ModelingExercise(de.tum.in.www1.artemis.domain.modeling.ModelingExercise)

Example 29 with ProgrammingSubmission

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

the class ResultServiceIntegrationTest method testGetAssessmentCountByCorrectionRoundForProgrammingExercise.

@Test
@WithMockUser(username = "instructor1", roles = "INSTRUCTOR")
public void testGetAssessmentCountByCorrectionRoundForProgrammingExercise() {
    // exercise
    Course course = database.createCourse();
    ProgrammingExercise programmingExercise = database.addProgrammingExerciseToCourse(course, false);
    programmingExercise.setDueDate(null);
    programmingExerciseRepository.save(programmingExercise);
    // participation
    ProgrammingExerciseStudentParticipation programmingExerciseStudentParticipation = new ProgrammingExerciseStudentParticipation();
    programmingExerciseStudentParticipation.setExercise(programmingExercise);
    programmingExerciseStudentParticipationRepository.save(programmingExerciseStudentParticipation);
    // submission
    ProgrammingSubmission programmingSubmission = new ProgrammingSubmission();
    programmingSubmission.setParticipation(programmingExerciseStudentParticipation);
    programmingSubmission.setSubmitted(true);
    programmingSubmission.setBuildArtifact(true);
    programmingSubmission = submissionRepository.save(programmingSubmission);
    // result 1
    Result r1 = database.addResultToParticipation(AssessmentType.MANUAL, ZonedDateTime.now(), programmingExerciseStudentParticipation, "text result string 1", "instructor1", new ArrayList<>());
    r1.setRated(true);
    r1 = database.addFeedbackToResults(r1);
    r1.setSubmission(programmingSubmission);
    // result 2
    Result r2 = database.addResultToParticipation(AssessmentType.MANUAL, ZonedDateTime.now(), programmingExerciseStudentParticipation, "text result string 2", "tutor1", new ArrayList<>());
    r2.setRated(true);
    r2 = database.addFeedbackToResults(r2);
    r2.setSubmission(programmingSubmission);
    programmingSubmission.addResult(r1);
    programmingSubmission = submissionRepository.save(programmingSubmission);
    programmingSubmission.addResult(r2);
    submissionRepository.save(programmingSubmission);
    var assessments = resultRepository.countNumberOfFinishedAssessmentsForExamExerciseForCorrectionRounds(programmingExercise, 2);
    // correction round 1
    assertThat(assessments[0].inTime()).isEqualTo(1);
    // correction round 2
    assertThat(assessments[1].inTime()).isEqualTo(1);
}
Also used : ProgrammingExerciseStudentParticipation(de.tum.in.www1.artemis.domain.participation.ProgrammingExerciseStudentParticipation) WithMockUser(org.springframework.security.test.context.support.WithMockUser) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 30 with ProgrammingSubmission

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

the class SubmissionServiceTest method queryTestingBasics.

private void queryTestingBasics(Exercise exercise) {
    Exam exam = exercise.getExerciseGroup().getExam();
    exam.setNumberOfCorrectionRoundsInExam(2);
    examRepository.save(exam);
    if (submission1 != null && submission2 != null) {
        submission1.submitted(true);
        submission2.submitted(true);
        if (exercise instanceof ProgrammingExercise) {
            database.addProgrammingSubmission(examProgrammingExercise, (ProgrammingSubmission) submission1, "student1");
            database.addProgrammingSubmission(examProgrammingExercise, (ProgrammingSubmission) submission2, "student1");
        } else {
            database.addSubmission(exercise, submission1, "student1");
            database.addSubmission(exercise, submission2, "student2");
        }
    }
}
Also used : Exam(de.tum.in.www1.artemis.domain.exam.Exam)

Aggregations

ProgrammingSubmission (de.tum.in.www1.artemis.domain.ProgrammingSubmission)30 WithMockUser (org.springframework.security.test.context.support.WithMockUser)26 Test (org.junit.jupiter.api.Test)24 ModelingExercise (de.tum.in.www1.artemis.domain.modeling.ModelingExercise)16 ModelingSubmission (de.tum.in.www1.artemis.domain.modeling.ModelingSubmission)16 ProgrammingExerciseStudentParticipation (de.tum.in.www1.artemis.domain.participation.ProgrammingExerciseStudentParticipation)16 StudentParticipation (de.tum.in.www1.artemis.domain.participation.StudentParticipation)16 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)14 HttpHeaders (org.springframework.http.HttpHeaders)10 AbstractSpringIntegrationBambooBitbucketJiraTest (de.tum.in.www1.artemis.AbstractSpringIntegrationBambooBitbucketJiraTest)8 ProgrammingExercise (de.tum.in.www1.artemis.domain.ProgrammingExercise)8 ModelingPlagiarismResult (de.tum.in.www1.artemis.domain.plagiarism.modeling.ModelingPlagiarismResult)8 TextPlagiarismResult (de.tum.in.www1.artemis.domain.plagiarism.text.TextPlagiarismResult)8 ArrayList (java.util.ArrayList)8 AbstractSpringIntegrationJenkinsGitlabTest (de.tum.in.www1.artemis.AbstractSpringIntegrationJenkinsGitlabTest)6 ProgrammingExerciseParticipation (de.tum.in.www1.artemis.domain.participation.ProgrammingExerciseParticipation)6 EntityNotFoundException (de.tum.in.www1.artemis.web.rest.errors.EntityNotFoundException)6 Path (java.nio.file.Path)6 BeforeEach (org.junit.jupiter.api.BeforeEach)5 AbstractSpringDevelopmentTest (de.tum.in.www1.artemis.AbstractSpringDevelopmentTest)4