use of de.tum.in.www1.artemis.domain.exam.Exam in project Artemis by ls1intum.
the class DatabaseUtilService method createCourseWithExamAndExerciseGroupAndExercises.
public Course createCourseWithExamAndExerciseGroupAndExercises(User user) {
Course course = createCourse();
Exam exam = addExam(course, user, ZonedDateTime.now().minusMinutes(1), ZonedDateTime.now(), ZonedDateTime.now().plusMinutes(1));
course.addExam(exam);
addExerciseGroupsAndExercisesToExam(exam, false);
return courseRepo.save(course);
}
use of de.tum.in.www1.artemis.domain.exam.Exam in project Artemis by ls1intum.
the class DatabaseUtilService method addExam.
public Exam addExam(Course course, User user, ZonedDateTime visibleDate, ZonedDateTime startDate, ZonedDateTime endDate) {
Exam exam = ModelFactory.generateExam(course);
exam.addRegisteredUser(user);
exam.setVisibleDate(visibleDate);
exam.setStartDate(startDate);
exam.setEndDate(endDate);
exam.setNumberOfCorrectionRoundsInExam(1);
examRepository.save(exam);
return exam;
}
use of de.tum.in.www1.artemis.domain.exam.Exam 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;
}
use of de.tum.in.www1.artemis.domain.exam.Exam in project Artemis by ls1intum.
the class DatabaseUtilService method addExerciseGroupWithExamWithReviewDatesAndCourse.
public ExerciseGroup addExerciseGroupWithExamWithReviewDatesAndCourse(boolean mandatory) {
Course course = ModelFactory.generateCourse(null, pastTimestamp, futureFutureTimestamp, new HashSet<>(), "tumuser", "tutor", "editor", "instructor");
Exam exam = ModelFactory.generateExamWithStudentReviewDates(course);
ExerciseGroup exerciseGroup = ModelFactory.generateExerciseGroup(mandatory, exam);
final var courseNrBefore = courseRepo.count();
final var examNrBefore = examRepository.count();
final var exerciseGroupNrBefore = exerciseGroupRepository.count();
courseRepo.save(course);
examRepository.save(exam);
assertThat(courseNrBefore + 1).as("a course got stored").isEqualTo(courseRepo.count());
assertThat(examNrBefore + 1).as("an exam got stored").isEqualTo(examRepository.count());
assertThat(exerciseGroupNrBefore + 1).as("an exerciseGroup got stored").isEqualTo(exerciseGroupRepository.count());
Optional<Course> optionalCourse = courseRepo.findById(course.getId());
assertThat(optionalCourse).as("course can be retrieved").isPresent();
Course courseDB = optionalCourse.get();
Optional<Exam> optionalExam = examRepository.findById(exam.getId());
assertThat(optionalCourse).as("exam can be retrieved").isPresent();
Exam examDB = optionalExam.get();
Optional<ExerciseGroup> optionalExerciseGroup = exerciseGroupRepository.findById(exerciseGroup.getId());
assertThat(optionalExerciseGroup).as("exerciseGroup can be retrieved").isPresent();
ExerciseGroup exerciseGroupDB = optionalExerciseGroup.get();
assertThat(examDB.getCourse().getId()).as("exam and course are linked correctly").isEqualTo(courseDB.getId());
assertThat(exerciseGroupDB.getExam().getId()).as("exerciseGroup and exam are linked correctly").isEqualTo(examDB.getId());
return exerciseGroup;
}
use of de.tum.in.www1.artemis.domain.exam.Exam in project Artemis by ls1intum.
the class DatabaseUtilService method createCourseWithExamAndExercises.
public Course createCourseWithExamAndExercises() throws IOException {
Course course = courseRepo.save(addEmptyCourse());
// Create a file upload exercise with a dummy submission file
var exerciseGroup1 = exerciseGroupRepository.save(new ExerciseGroup());
var fileUploadExercise = ModelFactory.generateFileUploadExerciseForExam(".png", exerciseGroup1);
fileUploadExercise = exerciseRepo.save(fileUploadExercise);
createFileUploadSubmissionWithFile(fileUploadExercise, "uploaded-file.png");
exerciseGroup1.addExercise(fileUploadExercise);
exerciseGroup1 = exerciseGroupRepository.save(exerciseGroup1);
// Create a text exercise with a dummy submission file
var exerciseGroup2 = exerciseGroupRepository.save(new ExerciseGroup());
var textExercise = ModelFactory.generateTextExerciseForExam(exerciseGroup2);
textExercise = exerciseRepo.save(textExercise);
var textSubmission = ModelFactory.generateTextSubmission("example text", Language.ENGLISH, true);
saveTextSubmission(textExercise, textSubmission, "student1");
exerciseGroup2.addExercise(textExercise);
exerciseGroup2 = exerciseGroupRepository.save(exerciseGroup2);
// Create a modeling exercise with a dummy submission file
var exerciseGroup3 = exerciseGroupRepository.save(new ExerciseGroup());
var modelingExercise = ModelFactory.generateModelingExerciseForExam(DiagramType.ClassDiagram, exerciseGroup2);
modelingExercise = exerciseRepo.save(modelingExercise);
String emptyActivityModel = FileUtils.loadFileFromResources("test-data/model-submission/empty-activity-diagram.json");
var modelingSubmission = ModelFactory.generateModelingSubmission(emptyActivityModel, true);
addSubmission(modelingExercise, modelingSubmission, "student1");
exerciseGroup3.addExercise(modelingExercise);
exerciseGroupRepository.save(exerciseGroup3);
Exam exam = addExam(course);
exam.setEndDate(ZonedDateTime.now().minusMinutes(5));
exam.addExerciseGroup(exerciseGroup1);
exam.addExerciseGroup(exerciseGroup2);
examRepository.save(exam);
return course;
}
Aggregations