Search in sources :

Example 26 with Team

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);
}
Also used : TeamImportStrategyType(de.tum.in.www1.artemis.domain.enumeration.TeamImportStrategyType)

Example 27 with Team

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());
}
Also used : TeamSearchUserDTO(de.tum.in.www1.artemis.service.dto.TeamSearchUserDTO) WithMockUser(org.springframework.security.test.context.support.WithMockUser) WithMockUser(org.springframework.security.test.context.support.WithMockUser) Test(org.junit.jupiter.api.Test)

Example 28 with Team

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();
}
Also used : BeforeEach(org.junit.jupiter.api.BeforeEach) java.util(java.util) de.tum.in.www1.artemis.repository(de.tum.in.www1.artemis.repository) Language(de.tum.in.www1.artemis.domain.enumeration.Language) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) ZonedDateTime(java.time.ZonedDateTime) ExerciseMode(de.tum.in.www1.artemis.domain.enumeration.ExerciseMode) Autowired(org.springframework.beans.factory.annotation.Autowired) Collectors(java.util.stream.Collectors) Test(org.junit.jupiter.api.Test) HttpStatus(org.springframework.http.HttpStatus) AfterEach(org.junit.jupiter.api.AfterEach) Stream(java.util.stream.Stream) de.tum.in.www1.artemis.domain(de.tum.in.www1.artemis.domain) WithMockUser(org.springframework.security.test.context.support.WithMockUser) TeamSearchUserDTO(de.tum.in.www1.artemis.service.dto.TeamSearchUserDTO) StudentParticipation(de.tum.in.www1.artemis.domain.participation.StudentParticipation) ModelFactory(de.tum.in.www1.artemis.util.ModelFactory) ModelingExercise(de.tum.in.www1.artemis.domain.modeling.ModelingExercise) ModelingExercise(de.tum.in.www1.artemis.domain.modeling.ModelingExercise) WithMockUser(org.springframework.security.test.context.support.WithMockUser) Test(org.junit.jupiter.api.Test)

Example 29 with Team

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);
}
Also used : CourseLearningGoalProgress(de.tum.in.www1.artemis.web.rest.dto.CourseLearningGoalProgress) WithMockUser(org.springframework.security.test.context.support.WithMockUser) Test(org.junit.jupiter.api.Test)

Example 30 with Team

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);
}
Also used : ExerciseUnit(de.tum.in.www1.artemis.domain.lecture.ExerciseUnit) WithMockUser(org.springframework.security.test.context.support.WithMockUser) ZonedDateTime(java.time.ZonedDateTime) Exam(de.tum.in.www1.artemis.domain.exam.Exam) BeforeEach(org.junit.jupiter.api.BeforeEach)

Aggregations

WithMockUser (org.springframework.security.test.context.support.WithMockUser)34 Test (org.junit.jupiter.api.Test)32 TeamImportStrategyType (de.tum.in.www1.artemis.domain.enumeration.TeamImportStrategyType)14 StudentParticipation (de.tum.in.www1.artemis.domain.participation.StudentParticipation)12 TeamAssignmentPayload (de.tum.in.www1.artemis.web.websocket.dto.TeamAssignmentPayload)12 AbstractSpringIntegrationBambooBitbucketJiraTest (de.tum.in.www1.artemis.AbstractSpringIntegrationBambooBitbucketJiraTest)10 ModelingExercise (de.tum.in.www1.artemis.domain.modeling.ModelingExercise)10 de.tum.in.www1.artemis.domain (de.tum.in.www1.artemis.domain)8 ExerciseMode (de.tum.in.www1.artemis.domain.enumeration.ExerciseMode)8 de.tum.in.www1.artemis.repository (de.tum.in.www1.artemis.repository)8 ZonedDateTime (java.time.ZonedDateTime)8 java.util (java.util)8 Collectors (java.util.stream.Collectors)8 Stream (java.util.stream.Stream)8 BeforeEach (org.junit.jupiter.api.BeforeEach)8 PreAuthorize (org.springframework.security.access.prepost.PreAuthorize)8 TeamSearchUserDTO (de.tum.in.www1.artemis.service.dto.TeamSearchUserDTO)6 ModelFactory (de.tum.in.www1.artemis.util.ModelFactory)6 CourseLearningGoalProgress (de.tum.in.www1.artemis.web.rest.dto.CourseLearningGoalProgress)6 Assertions.assertThat (org.assertj.core.api.Assertions.assertThat)6