Search in sources :

Example 61 with CourseAttributes

use of teammates.common.datatransfer.attributes.CourseAttributes in project teammates by TEAMMATES.

the class GateKeeperTest method testGetCurrentUser.

// TODO: test isUserLoggedIn method
@Test
public void testGetCurrentUser() throws Exception {
    ______TS("admin+instructor+student");
    InstructorAttributes instructor = dataBundle.instructors.get("instructor1OfCourse1");
    CourseAttributes course = dataBundle.courses.get("typicalCourse2");
    gaeSimulation.loginAsAdmin(instructor.googleId);
    // also make this user a student of another course
    StudentAttributes instructorAsStudent = StudentAttributes.builder(course.getId(), "Instructor As Student", "instructorasstudent@yahoo.com").withSection("Section 1").withTeam("Team 1").withComments("").build();
    instructorAsStudent.googleId = instructor.googleId;
    new Logic().createStudentWithoutDocument(instructorAsStudent);
    UserType user = gateKeeper.getCurrentUser();
    assertEquals(instructor.googleId, user.id);
    assertTrue(user.isAdmin);
    assertTrue(user.isInstructor);
    assertTrue(user.isStudent);
    ______TS("unregistered");
    gaeSimulation.loginUser("unknown");
    user = gateKeeper.getCurrentUser();
    assertEquals("unknown", user.id);
    assertFalse(user.isAdmin);
    assertFalse(user.isInstructor);
    assertFalse(user.isStudent);
    ______TS("not logged in");
    // check for user not logged in
    gaeSimulation.logoutUser();
    assertNull(gateKeeper.getCurrentUser());
}
Also used : Logic(teammates.logic.api.Logic) UserType(teammates.common.datatransfer.UserType) StudentAttributes(teammates.common.datatransfer.attributes.StudentAttributes) InstructorAttributes(teammates.common.datatransfer.attributes.InstructorAttributes) CourseAttributes(teammates.common.datatransfer.attributes.CourseAttributes) Test(org.testng.annotations.Test)

Example 62 with CourseAttributes

use of teammates.common.datatransfer.attributes.CourseAttributes in project teammates by TEAMMATES.

the class StudentsLogicTest method testIsStudentInTeam.

private void testIsStudentInTeam() {
    ______TS("non-existent student");
    String nonExistStudentEmail = "nonExist@google.tmt";
    String teamName = "Team 1";
    CourseAttributes course1 = dataBundle.courses.get("typicalCourse1");
    assertFalse(studentsLogic.isStudentInTeam(course1.getId(), teamName, nonExistStudentEmail));
    ______TS("student not in given team");
    StudentAttributes student1InCourse1 = dataBundle.students.get("student1InCourse1");
    assertFalse(studentsLogic.isStudentInTeam(course1.getId(), teamName, nonExistStudentEmail));
    ______TS("typical case");
    teamName = student1InCourse1.team;
    assertTrue(studentsLogic.isStudentInTeam(course1.getId(), teamName, student1InCourse1.email));
}
Also used : StudentAttributes(teammates.common.datatransfer.attributes.StudentAttributes) CourseAttributes(teammates.common.datatransfer.attributes.CourseAttributes)

Example 63 with CourseAttributes

use of teammates.common.datatransfer.attributes.CourseAttributes in project teammates by TEAMMATES.

the class StudentsLogicTest method testIsStudentsInSameTeam.

private void testIsStudentsInSameTeam() {
    ______TS("non-existent student1");
    CourseAttributes course1 = dataBundle.courses.get("typicalCourse1");
    StudentAttributes student2InCourse1 = dataBundle.students.get("student2InCourse1");
    String nonExistStudentEmail = "nonExist@google.tmt";
    assertFalse(studentsLogic.isStudentsInSameTeam(course1.getId(), nonExistStudentEmail, student2InCourse1.email));
    ______TS("students of different teams");
    StudentAttributes student5InCourse1 = dataBundle.students.get("student5InCourse1");
    assertFalse(studentsLogic.isStudentsInSameTeam(course1.getId(), student2InCourse1.email, student5InCourse1.email));
    ______TS("students of different teams");
    StudentAttributes student1InCourse1 = dataBundle.students.get("student1InCourse1");
    assertTrue(studentsLogic.isStudentsInSameTeam(course1.getId(), student2InCourse1.email, student1InCourse1.email));
}
Also used : StudentAttributes(teammates.common.datatransfer.attributes.StudentAttributes) CourseAttributes(teammates.common.datatransfer.attributes.CourseAttributes)

Example 64 with CourseAttributes

use of teammates.common.datatransfer.attributes.CourseAttributes in project teammates by TEAMMATES.

the class StudentsLogicTest method testIsStudentInCourse.

private void testIsStudentInCourse() {
    ______TS("non-existent student");
    String nonExistStudentEmail = "nonExist@google.tmt";
    CourseAttributes course1 = dataBundle.courses.get("typicalCourse1");
    assertFalse(studentsLogic.isStudentInCourse(course1.getId(), nonExistStudentEmail));
    ______TS("typical case");
    StudentAttributes student1InCourse1 = dataBundle.students.get("student1InCourse1");
    assertTrue(studentsLogic.isStudentInCourse(course1.getId(), student1InCourse1.email));
}
Also used : StudentAttributes(teammates.common.datatransfer.attributes.StudentAttributes) CourseAttributes(teammates.common.datatransfer.attributes.CourseAttributes)

Example 65 with CourseAttributes

use of teammates.common.datatransfer.attributes.CourseAttributes in project teammates by TEAMMATES.

the class StudentsLogicTest method testValidateSections.

private void testValidateSections() throws Exception {
    CourseAttributes typicalCourse1 = dataBundle.courses.get("typicalCourse1");
    String courseId = typicalCourse1.getId();
    ______TS("Typical case");
    List<StudentAttributes> studentList = new ArrayList<>();
    studentList.add(StudentAttributes.builder(courseId, "New Student", "emailNew@com").withSection("Section 3").withTeam("Team 1.3").withComments("").build());
    studentList.add(StudentAttributes.builder(courseId, "student2 In Course1", "student2InCourse1@gmail.tmt").withSection("Section 2").withTeam("Team 1.4").withComments("").build());
    studentsLogic.validateSectionsAndTeams(studentList, courseId);
    ______TS("Failure case: invalid section");
    studentList = new ArrayList<>();
    for (int i = 0; i < 100; i++) {
        StudentAttributes addedStudent = StudentAttributes.builder(courseId, "Name " + i, "email@com" + i).withSection("Section 1").withTeam("Team " + i).withComments("cmt" + i).build();
        studentList.add(addedStudent);
    }
    try {
        studentsLogic.validateSectionsAndTeams(studentList, courseId);
    } catch (EnrollException e) {
        assertEquals(String.format(Const.StatusMessages.SECTION_QUOTA_EXCEED, "Section 1"), e.getMessage());
    }
    ______TS("Failure case: invalid team");
    studentList = new ArrayList<>();
    studentList.add(StudentAttributes.builder(courseId, "New Student", "newemail@com").withSection("Section 2").withTeam("Team 1.1").withComments("").build());
    try {
        studentsLogic.validateSectionsAndTeams(studentList, courseId);
    } catch (EnrollException e) {
        assertEquals(String.format(Const.StatusMessages.TEAM_INVALID_SECTION_EDIT, "Team 1.1</td></div>'\"") + "Please use the enroll page to edit multiple students", e.getMessage());
    }
}
Also used : EnrollException(teammates.common.exception.EnrollException) ArrayList(java.util.ArrayList) StudentAttributes(teammates.common.datatransfer.attributes.StudentAttributes) CourseAttributes(teammates.common.datatransfer.attributes.CourseAttributes)

Aggregations

CourseAttributes (teammates.common.datatransfer.attributes.CourseAttributes)106 InstructorAttributes (teammates.common.datatransfer.attributes.InstructorAttributes)48 Test (org.testng.annotations.Test)40 StudentAttributes (teammates.common.datatransfer.attributes.StudentAttributes)33 ArrayList (java.util.ArrayList)31 FeedbackSessionAttributes (teammates.common.datatransfer.attributes.FeedbackSessionAttributes)19 AccountAttributes (teammates.common.datatransfer.attributes.AccountAttributes)16 EntityDoesNotExistException (teammates.common.exception.EntityDoesNotExistException)15 EmailWrapper (teammates.common.util.EmailWrapper)15 HashMap (java.util.HashMap)12 InvalidParametersException (teammates.common.exception.InvalidParametersException)10 EmailGenerator (teammates.logic.api.EmailGenerator)10 CourseDetailsBundle (teammates.common.datatransfer.CourseDetailsBundle)8 StatusMessage (teammates.common.util.StatusMessage)6 StudentProfileAttributes (teammates.common.datatransfer.attributes.StudentProfileAttributes)5 TeamDetailsBundle (teammates.common.datatransfer.TeamDetailsBundle)4 FeedbackQuestionAttributes (teammates.common.datatransfer.attributes.FeedbackQuestionAttributes)4 EntityAlreadyExistsException (teammates.common.exception.EntityAlreadyExistsException)4 InstructorCoursesPageData (teammates.ui.pagedata.InstructorCoursesPageData)4 InstructorFeedbackSessionsPageData (teammates.ui.pagedata.InstructorFeedbackSessionsPageData)4