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, ZonedDateTime visibleDate, ZonedDateTime startDate, ZonedDateTime endDate) {
Exam exam = ModelFactory.generateExam(course);
exam.setVisibleDate(visibleDate);
exam.setStartDate(startDate);
exam.setEndDate(endDate);
exam.setGracePeriod(180);
examRepository.save(exam);
return exam;
}
use of de.tum.in.www1.artemis.domain.exam.Exam in project ArTEMiS by ls1intum.
the class DatabaseUtilService method generateTestRunForInstructor.
public StudentExam generateTestRunForInstructor(Exam exam, User instructor, List<Exercise> exercises) {
var testRun = ModelFactory.generateExamTestRun(exam);
testRun.setUser(instructor);
examRepository.findWithExerciseGroupsAndExercisesById(exam.getId()).get();
for (final var exercise : exercises) {
testRun.addExercise(exercise);
assertThat(exercise.isExamExercise()).isTrue();
Submission submission;
if (exercise instanceof ModelingExercise) {
submission = addModelingSubmission((ModelingExercise) exercise, ModelFactory.generateModelingSubmission("", false), instructor.getLogin());
} else if (exercise instanceof TextExercise) {
submission = saveTextSubmission((TextExercise) exercise, ModelFactory.generateTextSubmission("", null, false), instructor.getLogin());
} else {
submission = new ProgrammingSubmission().submitted(true);
addProgrammingSubmission((ProgrammingExercise) exercise, (ProgrammingSubmission) submission, instructor.getLogin());
submission = submissionRepository.save(submission);
}
var studentParticipation = (StudentParticipation) submission.getParticipation();
studentParticipation.setTestRun(true);
studentParticipationRepo.save(studentParticipation);
}
return testRun;
}
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, ZonedDateTime visible, ZonedDateTime start, ZonedDateTime end) {
Course course = createCourse();
Exam exam = addExam(course, user, visible, start, end);
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 addActiveExamWithRegisteredUser.
public Exam addActiveExamWithRegisteredUser(Course course, User user) {
Exam exam = ModelFactory.generateExam(course);
exam.setStartDate(ZonedDateTime.now().minusHours(1));
exam.setEndDate(ZonedDateTime.now().plusHours(1));
exam.addRegisteredUser(user);
examRepository.save(exam);
var studentExam = new StudentExam();
studentExam.setExam(exam);
studentExam.setTestRun(false);
studentExam.setUser(user);
studentExam.setWorkingTime((int) Duration.between(exam.getStartDate(), exam.getEndDate()).toSeconds());
studentExamRepository.save(studentExam);
return exam;
}
use of de.tum.in.www1.artemis.domain.exam.Exam in project ArTEMiS by ls1intum.
the class ResultService method getFeedbacksForResult.
/**
* Returns a list of feedbacks that is filtered for students depending on the settings and the time.
*
* @param result the result for which the feedback elements should be returned
* @return the list of filtered feedbacks
*/
public List<Feedback> getFeedbacksForResult(Result result) {
Exercise exercise = result.getParticipation().getExercise();
boolean filterForStudent = !authCheckService.isAtLeastTeachingAssistantForExercise(exercise);
List<Feedback> feedbacks = result.getFeedbacks();
if (filterForStudent) {
if (exercise.isExamExercise()) {
Exam exam = exercise.getExerciseGroup().getExam();
result.filterSensitiveFeedbacks(!exam.resultsPublished());
} else {
boolean applyFilter = exerciseDateService.isBeforeDueDate(result.getParticipation()) || (AssessmentType.AUTOMATIC.equals(result.getAssessmentType()) && exerciseDateService.isBeforeLatestDueDate(exercise));
result.filterSensitiveFeedbacks(applyFilter);
}
feedbacks = result.getFeedbacks();
boolean resultSetAndNonAutomatic = result.getAssessmentType() != null && result.getAssessmentType() != AssessmentType.AUTOMATIC;
boolean dueDateNotSetOrNotOver = exercise.getAssessmentDueDate() != null && ZonedDateTime.now().isBefore(exercise.getAssessmentDueDate());
// A tutor is allowed to access all feedback, but filter for a student the manual feedback if the assessment due date is not over yet
if (!exercise.isExamExercise() && resultSetAndNonAutomatic && dueDateNotSetOrNotOver) {
// filter all non-automatic feedbacks
feedbacks = feedbacks.stream().filter(feedback -> feedback.getType() != null && feedback.getType() == FeedbackType.AUTOMATIC).toList();
}
}
// remove unnecessary data to keep the json payload smaller
for (Feedback feedback : feedbacks) {
if (feedback.getResult() != null) {
feedback.getResult().setSubmission(null);
feedback.getResult().setParticipation(null);
}
}
return feedbacks;
}
Aggregations