use of de.tum.in.www1.artemis.domain.Team in project Artemis by ls1intum.
the class TeamImportIntegrationTest method testImportTeamsIntoExerciseWithNoConflictsUsingPurgeExistingStrategy.
private void testImportTeamsIntoExerciseWithNoConflictsUsingPurgeExistingStrategy(ImportType type, List<Team> body, List<Team> addedTeams) throws Exception {
TeamImportStrategyType strategyType = TeamImportStrategyType.PURGE_EXISTING;
database.addTeamsForExercise(destinationExercise, 4, tutor);
testImportTeamsIntoExercise(type, strategyType, body, addedTeams);
}
use of de.tum.in.www1.artemis.domain.Team in project Artemis by ls1intum.
the class TeamIntegrationTest method testSearchUsersInCourse.
@Test
@WithMockUser(username = "tutor1", roles = "TA")
public void testSearchUsersInCourse() throws Exception {
// Check that all students from course are found (since their logins are all prefixed by "student")
List<TeamSearchUserDTO> users1 = request.getList(resourceUrlSearchUsersInCourse("student"), HttpStatus.OK, TeamSearchUserDTO.class);
assertThat(users1).as("All users of course with 'student' in login were found").hasSize(numberOfStudentsInCourse);
// Check that a student is found by his login and that he is NOT marked as "assignedToTeam" yet
List<TeamSearchUserDTO> users2 = request.getList(resourceUrlSearchUsersInCourse("student1"), HttpStatus.OK, TeamSearchUserDTO.class);
assertThat(users2).as("Only user with login 'student1' was found").hasSize(1);
assertThat(users2.get(0).getAssignedTeamId()).as("User was correctly marked as not being assigned to a team yet").isNull();
// Check that no student is returned for non-existing login/name
List<TeamSearchUserDTO> users3 = request.getList(resourceUrlSearchUsersInCourse("chuckNorris"), HttpStatus.OK, TeamSearchUserDTO.class);
assertThat(users3).as("No user was found as expected").isEmpty();
// Check whether a student from a team is found but marked as "assignedToTeam"
Team team = database.addTeamForExercise(exercise, tutor);
User teamStudent = team.getStudents().iterator().next();
List<TeamSearchUserDTO> users4 = request.getList(resourceUrlSearchUsersInCourse(teamStudent.getLogin()), HttpStatus.OK, TeamSearchUserDTO.class);
assertThat(users4).as("User from team was found").hasSize(1);
assertThat(users4.get(0).getAssignedTeamId()).as("User from team was correctly marked as being assigned to a team already").isEqualTo(team.getId());
}
use of de.tum.in.www1.artemis.domain.Team in project Artemis by ls1intum.
the class TeamIntegrationTest method testAssignedTeamIdOnExerciseForCurrentUser.
@Test
@WithMockUser(username = "student1", roles = "USER")
public void testAssignedTeamIdOnExerciseForCurrentUser() throws Exception {
// Create team that contains student "student1" (Team shortName needs to be empty since it is used as a prefix for the generated student logins)
Team team = new Team().name("Team").shortName("team").exercise(exercise).students(userRepo.findOneByLogin("student1").map(Set::of).orElseThrow());
team = teamRepo.save(team);
// Check for endpoint: @GetMapping("/courses/for-dashboard")
List<Course> courses = request.getList("/api/courses/for-dashboard", HttpStatus.OK, Course.class);
Exercise serverExercise = courses.stream().filter(c -> c.getId().equals(course.getId())).findAny().flatMap(c -> c.getExercises().stream().filter(e -> e.getId().equals(exercise.getId())).findAny()).orElseThrow();
assertThat(serverExercise.getStudentAssignedTeamId()).as("Assigned team id on exercise from dashboard is correct for student.").isEqualTo(team.getId());
assertThat(serverExercise.isStudentAssignedTeamIdComputed()).as("Assigned team id on exercise was computed.").isTrue();
// Check for endpoint: @GetMapping("/exercises/{exerciseId}/details")
Exercise exerciseWithDetails = request.get("/api/exercises/" + exercise.getId() + "/details", HttpStatus.OK, Exercise.class);
assertThat(exerciseWithDetails.getStudentAssignedTeamId()).as("Assigned team id on exercise from details is correct for student.").isEqualTo(team.getId());
assertThat(serverExercise.isStudentAssignedTeamIdComputed()).as("Assigned team id on exercise was computed.").isTrue();
}
use of de.tum.in.www1.artemis.domain.Team in project Artemis by ls1intum.
the class LearningGoalIntegrationTest method getLearningGoalCourseProgressTeamsTest_asInstructorOne.
@Test
@WithMockUser(username = "instructor1", roles = "INSTRUCTOR")
public void getLearningGoalCourseProgressTeamsTest_asInstructorOne() throws Exception {
cleanUpInitialParticipations();
// will be ignored in favor of last submission from team
createParticipationSubmissionAndResult(idOfTeamTextExercise, teams.get(0), 10.0, 0.0, 100, true);
createParticipationSubmissionAndResult(idOfTeamTextExercise, teams.get(0), 10.0, 0.0, 50, false);
// will be ignored in favor of last submission from team
// will be ignored in favor of last submission from team
createParticipationSubmissionAndResult(idOfTeamTextExercise, teams.get(1), 10.0, 0.0, 100, true);
createParticipationSubmissionAndResult(idOfTeamTextExercise, teams.get(1), 10.0, 0.0, 10, false);
createParticipationSubmissionAndResult(idOfTeamTextExercise, teams.get(2), 10.0, 0.0, 10, true);
createParticipationSubmissionAndResult(idOfTeamTextExercise, teams.get(3), 10.0, 0.0, 50, true);
CourseLearningGoalProgress courseLearningGoalProgress = request.get("/api/courses/" + idOfCourse + "/goals/" + idOfLearningGoal + "/course-progress", HttpStatus.OK, CourseLearningGoalProgress.class);
assertThat(courseLearningGoalProgress.totalPointsAchievableByStudentsInLearningGoal).isEqualTo(30.0);
assertThat(courseLearningGoalProgress.averagePointsAchievedByStudentInLearningGoal).isEqualTo(3.0);
assertThatSpecificCourseLectureUnitProgressExists(courseLearningGoalProgress, 80.0, 4, 30);
}
use of de.tum.in.www1.artemis.domain.Team in project Artemis by ls1intum.
the class ParticipantScoreIntegrationTest method setupTestScenario.
@BeforeEach
public void setupTestScenario() {
ZonedDateTime pastTimestamp = ZonedDateTime.now().minusDays(5);
// creating the users student1-student5, tutor1-tutor10 and instructors1-instructor10
this.database.addUsers(5, 10, 0, 10);
// creating course
Course course = this.database.createCourse();
Lecture lecture = new Lecture();
lecture.setTitle("ExampleLecture");
lecture.setCourse(course);
lecture = lectureRepository.saveAndFlush(lecture);
idOfCourse = course.getId();
TextExercise textExercise = database.createIndividualTextExercise(course, pastTimestamp, pastTimestamp, pastTimestamp);
ExerciseUnit exerciseUnit = database.createExerciseUnit(textExercise);
database.addLectureUnitsToLecture(lecture, Set.of(exerciseUnit));
lecture = lectureRepository.findByIdWithPostsAndLectureUnitsAndLearningGoals(lecture.getId()).get();
exerciseUnit = (ExerciseUnit) lecture.getLectureUnits().get(0);
idOfExerciseUnit = exerciseUnit.getId();
LearningGoal learningGoal = new LearningGoal();
learningGoal.setTitle("ExampleLearningGoal");
learningGoal.setCourse(course);
learningGoal.addLectureUnit(exerciseUnit);
learningGoalRepository.saveAndFlush(learningGoal);
idOfIndividualTextExercise = textExercise.getId();
Exercise teamExercise = database.createTeamTextExercise(course, pastTimestamp, pastTimestamp, pastTimestamp);
idOfTeamTextExercise = teamExercise.getId();
User student1 = userRepository.findOneByLogin("student1").get();
idOfStudent1 = student1.getId();
User tutor1 = userRepository.findOneByLogin("tutor1").get();
idOfTeam1 = database.createTeam(Set.of(student1), tutor1, teamExercise, "team1").getId();
// Creating result for student1
database.createParticipationSubmissionAndResult(idOfIndividualTextExercise, student1, 10.0, 10.0, 50, true);
// Creating result for team1
Team team = teamRepository.findById(idOfTeam1).get();
database.createParticipationSubmissionAndResult(idOfTeamTextExercise, team, 10.0, 10.0, 50, true);
// setting up exam
Exam exam = ModelFactory.generateExam(course);
ModelFactory.generateExerciseGroup(true, exam);
exam.addRegisteredUser(student1);
exam = examRepository.save(exam);
idOfExam = exam.getId();
createIndividualTextExerciseForExam();
database.createParticipationSubmissionAndResult(getIdOfIndividualTextExerciseOfExam, student1, 10.0, 10.0, 50, true);
}
Aggregations