use of de.tum.in.www1.artemis.domain.participation.StudentParticipation in project ArTEMiS by ls1intum.
the class ProgrammingExerciseScheduleServiceTest method verifyLockStudentRepositoryOperation.
private void verifyLockStudentRepositoryOperation(boolean wasCalled, Iterable<StudentParticipation> studentParticipations, long timeoutInMs) {
int callCount = wasCalled ? 1 : 0;
for (StudentParticipation studentParticipation : studentParticipations) {
ProgrammingExerciseStudentParticipation programmingExerciseStudentParticipation = (ProgrammingExerciseStudentParticipation) studentParticipation;
verify(versionControlService, timeout(timeoutInMs).times(callCount)).setRepositoryPermissionsToReadOnly(programmingExerciseStudentParticipation.getVcsRepositoryUrl(), programmingExercise.getProjectKey(), programmingExerciseStudentParticipation.getStudents());
}
}
use of de.tum.in.www1.artemis.domain.participation.StudentParticipation in project ArTEMiS by ls1intum.
the class TextExerciseUtilService method createSampleTextExerciseWithSubmissions.
public TextExercise createSampleTextExerciseWithSubmissions(Course course, List<TextBlock> textBlocks, int submissionCount, int submissionSize) {
if (textBlocks.size() != submissionCount * submissionSize) {
throw new IllegalArgumentException("number of textBlocks must be eqaul to submissionCount * submissionSize");
}
TextExercise textExercise = new TextExercise();
textExercise.setCourse(course);
textExercise.setTitle("Title");
textExercise.setShortName("Shortname");
textExercise.setAssessmentType(AssessmentType.SEMI_AUTOMATIC);
textExercise = textExerciseRepository.save(textExercise);
// submissions.length must be equal to studentParticipations.length;
for (int i = 0; i < submissionCount; i++) {
TextSubmission submission = new TextSubmission();
StudentParticipation studentParticipation = new StudentParticipation();
studentParticipation.setExercise(textExercise);
studentParticipation = participationRepository.save(studentParticipation);
submission.setParticipation(studentParticipation);
submission.setLanguage(Language.ENGLISH);
submission.setText("Test123");
submission.setBlocks(new HashSet<>(textBlocks.subList(i * submissionSize, (i + 1) * submissionSize)));
submission.setSubmitted(true);
submission.setSubmissionDate(ZonedDateTime.now());
textBlocks.subList(i * submissionSize, (i + 1) * submissionSize).forEach(textBlock -> textBlock.setSubmission(submission));
studentParticipation.addSubmission(submission);
textSubmissionRepository.save(submission);
}
return textExercise;
}
use of de.tum.in.www1.artemis.domain.participation.StudentParticipation in project ArTEMiS by ls1intum.
the class CourseServiceTest method testGetActiveStudents_UTCConversion.
@Test
public void testGetActiveStudents_UTCConversion() {
ZonedDateTime date = ZonedDateTime.of(2022, 1, 2, 0, 0, 0, 0, ZonedDateTime.now().getZone());
SecurityUtils.setAuthorizationObject();
var course = database.addEmptyCourse();
var exercise = ModelFactory.generateTextExercise(date, date, date, course);
course.addExercises(exercise);
exercise = exerciseRepo.save(exercise);
var users = database.addUsers(2, 0, 0, 0);
var student1 = users.get(0);
var participation1 = new StudentParticipation();
participation1.setParticipant(student1);
participation1.exercise(exercise);
studentParticipationRepo.save(participation1);
var submission1 = new TextSubmission();
submission1.text("text of text submission1");
submission1.setLanguage(Language.ENGLISH);
submission1.setSubmitted(true);
submission1.setParticipation(participation1);
submission1.setSubmissionDate(date.plusDays(1).plusMinutes(59).plusSeconds(59).plusNanos(59));
submissionRepository.save(submission1);
var exerciseList = new HashSet<Long>();
exerciseList.add(exercise.getId());
var activeStudents = courseService.getActiveStudents(exerciseList, 0, 4, ZonedDateTime.of(2022, 1, 25, 0, 0, 0, 0, ZoneId.systemDefault()));
assertThat(activeStudents).hasSize(4).containsExactly(1, 0, 0, 0);
}
use of de.tum.in.www1.artemis.domain.participation.StudentParticipation in project ArTEMiS by ls1intum.
the class ExamQuizServiceTest method evaluateQuizWithNoSubmissions.
@Test
@WithMockUser(username = "instructor1", roles = "INSTRUCTOR")
public void evaluateQuizWithNoSubmissions() throws Exception {
for (int i = 0; i < numberOfParticipants; i++) {
exam.addRegisteredUser(users.get(i));
}
exam = examRepository.save(exam);
exerciseGroup.setExam(exam);
exerciseGroup = exerciseGroupRepository.save(exerciseGroup);
exam.setExerciseGroups(List.of(exerciseGroup));
quizExercise.setExerciseGroup(exerciseGroup);
quizExercise = quizExerciseService.save(quizExercise);
exerciseGroup.setExercises(Set.of(quizExercise));
assertThat(studentExamRepository.generateStudentExams(exam)).hasSize(numberOfParticipants);
assertThat(studentExamRepository.findByExamId(exam.getId())).hasSize(numberOfParticipants);
// add participations with no submissions
for (int i = 0; i < numberOfParticipants; i++) {
final var user = database.getUserByLogin("student" + (i + 1));
var participation = new StudentParticipation();
participation.setExercise(quizExercise);
participation.setParticipant(user);
participation.setInitializationDate(ZonedDateTime.now());
participation.setInitializationState(InitializationState.INITIALIZED);
studentParticipationRepository.save(participation);
}
database.changeUser("instructor1");
// All exams should be over before evaluation
for (StudentExam studentExam : studentExamRepository.findByExamId(exam.getId())) {
studentExam.setWorkingTime(0);
studentExamRepository.save(studentExam);
}
Integer numberOfEvaluatedExercises = request.postWithResponseBody("/api/courses/" + course.getId() + "/exams/" + exam.getId() + "/student-exams/evaluate-quiz-exercises", Optional.empty(), Integer.class, HttpStatus.OK);
assertThat(numberOfEvaluatedExercises).isEqualTo(1);
studentExamRepository.deleteAll();
// Make sure delete also works if so many objects have been created before
request.delete("/api/courses/" + course.getId() + "/exams/" + exam.getId(), HttpStatus.OK);
userRepository.deleteAll();
}
use of de.tum.in.www1.artemis.domain.participation.StudentParticipation in project ArTEMiS by ls1intum.
the class ExamQuizServiceTest method evaluateQuizWithMultipleSubmissions.
@Test
@WithMockUser(username = "instructor1", roles = "INSTRUCTOR")
public void evaluateQuizWithMultipleSubmissions() throws Exception {
for (int i = 0; i < numberOfParticipants; i++) {
exam.addRegisteredUser(users.get(i));
}
exam = examRepository.save(exam);
exerciseGroup.setExam(exam);
exerciseGroup = exerciseGroupRepository.save(exerciseGroup);
exam.setExerciseGroups(List.of(exerciseGroup));
quizExercise.setExerciseGroup(exerciseGroup);
quizExercise = quizExerciseService.save(quizExercise);
exerciseGroup.setExercises(Set.of(quizExercise));
assertThat(studentExamRepository.generateStudentExams(exam)).hasSize(numberOfParticipants);
assertThat(studentExamRepository.findByExamId(exam.getId())).hasSize(numberOfParticipants);
assertThat(studentExamService.startExercises(exam.getId())).isEqualTo(numberOfParticipants);
for (int i = 0; i < numberOfParticipants; i++) {
final var user = database.getUserByLogin("student" + (i + 1));
database.changeUser(user.getLogin());
QuizSubmission quizSubmission = database.generateSubmissionForThreeQuestions(quizExercise, i + 1, true, ZonedDateTime.now());
request.put("/api/exercises/" + quizExercise.getId() + "/submissions/exam", quizSubmission, HttpStatus.OK);
// add another submission manually to trigger multiple submission branch of evaluateQuizSubmission
final var studentParticipation = studentParticipationRepository.findWithEagerLegalSubmissionsByExerciseIdAndStudentLogin(quizExercise.getId(), user.getLogin()).get();
QuizSubmission quizSubmission2 = database.generateSubmissionForThreeQuestions(quizExercise, i + 1, true, ZonedDateTime.now());
quizSubmission2.setParticipation(studentParticipation);
quizSubmissionRepository.save(quizSubmission2);
}
database.changeUser("instructor1");
// All exams should be over before evaluation
for (StudentExam studentExam : studentExamRepository.findByExamId(exam.getId())) {
studentExam.setWorkingTime(0);
studentExamRepository.save(studentExam);
}
Integer numberOfEvaluatedExercises = request.postWithResponseBody("/api/courses/" + course.getId() + "/exams/" + exam.getId() + "/student-exams/evaluate-quiz-exercises", Optional.empty(), Integer.class, HttpStatus.OK);
assertThat(numberOfEvaluatedExercises).isEqualTo(1);
checkStatistics(quizExercise);
studentExamRepository.deleteAll();
// Make sure delete also works if so many objects have been created before
request.delete("/api/courses/" + course.getId() + "/exams/" + exam.getId(), HttpStatus.OK);
userRepository.deleteAll();
}
Aggregations