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