Search in sources :

Example 1 with CourseRoster

use of teammates.common.datatransfer.CourseRoster in project teammates by TEAMMATES.

the class CourseRosterTest method allTests.

@Test
public void allTests() {
    ______TS("No students");
    CourseRoster roster = new CourseRoster(null, null);
    assertFalse(roster.isStudentInCourse("studentEmail"));
    ______TS("only 1 student, no instructors");
    roster = new CourseRoster(createStudentList("team 1", "s1@gmail.com"), null);
    assertFalse(roster.isStudentInCourse("non-existent@gmail.com"));
    assertTrue(roster.isStudentInCourse("s1@gmail.com"));
    assertFalse(roster.isStudentInTeam("non-existent@gmail.com", "team 1"));
    assertFalse(roster.isStudentInTeam("s1@gmail.com", "team 123"));
    assertTrue(roster.isStudentInTeam("s1@gmail.com", "team 1"));
    assertFalse(roster.isStudentsInSameTeam("non-existent@gmail.com", "s1@gmail.com"));
    assertFalse(roster.isStudentsInSameTeam("s1@gmail.com", "non-existent@gmail.com"));
    assertTrue(roster.isStudentsInSameTeam("s1@gmail.com", "s1@gmail.com"));
    assertEquals(roster.getStudentForEmail("s1@gmail.com").email, "s1@gmail.com");
    assertEquals(roster.getStudentForEmail("s1@gmail.com").team, "team 1");
    assertNull(roster.getInstructorForEmail("ins@email.com"));
    ______TS("only 1 instructor, no students");
    roster = new CourseRoster(null, createInstructorList("John", "ins1@email.com"));
    assertEquals(roster.getInstructorForEmail("ins1@email.com").email, "ins1@email.com");
    assertEquals(roster.getInstructorForEmail("ins1@email.com").name, "John");
    assertNull(roster.getInstructorForEmail("non-existent@email.com"));
    ______TS("multiple students, multiple instructors");
    roster = new CourseRoster(createStudentList("team 1", "s1@gmail.com", "team 1", "s2@gmail.com", "team 2", "s3@gmail.com"), createInstructorList("John", "ins1@email.com", "Jean", "ins2@email.com"));
    assertFalse(roster.isStudentInCourse("non-existent@gmail.com"));
    assertTrue(roster.isStudentInCourse("s2@gmail.com"));
    assertFalse(roster.isStudentInTeam("non-existent@gmail.com", "team 1"));
    assertFalse(roster.isStudentInTeam("s3@gmail.com", "team 1"));
    assertTrue(roster.isStudentInTeam("s1@gmail.com", "team 1"));
    assertTrue(roster.isStudentInTeam("s2@gmail.com", "team 1"));
    assertTrue(roster.isStudentInTeam("s3@gmail.com", "team 2"));
    assertFalse(roster.isStudentsInSameTeam("non-existent@gmail.com", "s1@gmail.com"));
    assertFalse(roster.isStudentsInSameTeam("s1@gmail.com", "s3@gmail.com"));
    assertTrue(roster.isStudentsInSameTeam("s2@gmail.com", "s1@gmail.com"));
    assertEquals(roster.getInstructorForEmail("ins1@email.com").email, "ins1@email.com");
    assertEquals(roster.getInstructorForEmail("ins1@email.com").name, "John");
    assertEquals(roster.getInstructorForEmail("ins2@email.com").email, "ins2@email.com");
    assertEquals(roster.getInstructorForEmail("ins2@email.com").name, "Jean");
}
Also used : CourseRoster(teammates.common.datatransfer.CourseRoster) Test(org.testng.annotations.Test)

Example 2 with CourseRoster

use of teammates.common.datatransfer.CourseRoster in project teammates by TEAMMATES.

the class FeedbackResponsesLogicTest method testIsNameVisibleTo.

private void testIsNameVisibleTo() {
    ______TS("testIsNameVisibleTo");
    InstructorAttributes instructor = dataBundle.instructors.get("instructor1OfCourse1");
    StudentAttributes student = dataBundle.students.get("student1InCourse1");
    StudentAttributes student2 = dataBundle.students.get("student2InCourse1");
    StudentAttributes student3 = dataBundle.students.get("student3InCourse1");
    StudentAttributes student5 = dataBundle.students.get("student5InCourse1");
    FeedbackQuestionAttributes fq = getQuestionFromDatastore("qn3InSession1InCourse1");
    FeedbackResponseAttributes fr = getResponseFromDatastore("response1ForQ3S1C1");
    CourseRoster roster = new CourseRoster(new StudentsDb().getStudentsForCourse(fq.courseId), new InstructorsDb().getInstructorsForCourse(fq.courseId));
    assertTrue(frLogic.isNameVisibleToUser(fq, fr, instructor.email, UserRole.INSTRUCTOR, true, roster));
    assertTrue(frLogic.isNameVisibleToUser(fq, fr, instructor.email, UserRole.INSTRUCTOR, false, roster));
    assertTrue(frLogic.isNameVisibleToUser(fq, fr, student.email, UserRole.STUDENT, false, roster));
    ______TS("test if visible to own team members");
    fr.giver = student.email;
    assertTrue(frLogic.isNameVisibleToUser(fq, fr, student.email, UserRole.STUDENT, false, roster));
    ______TS("test if visible to receiver/reciever team members");
    fq.recipientType = FeedbackParticipantType.TEAMS;
    fq.showRecipientNameTo.clear();
    fq.showRecipientNameTo.add(FeedbackParticipantType.RECEIVER);
    fr.recipient = student.team;
    assertTrue(frLogic.isNameVisibleToUser(fq, fr, student.email, UserRole.STUDENT, false, roster));
    assertTrue(frLogic.isNameVisibleToUser(fq, fr, student3.email, UserRole.STUDENT, false, roster));
    fq.recipientType = FeedbackParticipantType.STUDENTS;
    fr.recipient = student.email;
    assertTrue(frLogic.isNameVisibleToUser(fq, fr, student.email, UserRole.STUDENT, false, roster));
    assertFalse(frLogic.isNameVisibleToUser(fq, fr, student2.email, UserRole.STUDENT, false, roster));
    fq.recipientType = FeedbackParticipantType.TEAMS;
    fq.showRecipientNameTo.clear();
    fq.showRecipientNameTo.add(FeedbackParticipantType.RECEIVER_TEAM_MEMBERS);
    fr.recipient = student.team;
    assertTrue(frLogic.isNameVisibleToUser(fq, fr, student.email, UserRole.STUDENT, false, roster));
    assertTrue(frLogic.isNameVisibleToUser(fq, fr, student3.email, UserRole.STUDENT, false, roster));
    fq.recipientType = FeedbackParticipantType.STUDENTS;
    fr.recipient = student.email;
    assertTrue(frLogic.isNameVisibleToUser(fq, fr, student.email, UserRole.STUDENT, false, roster));
    assertTrue(frLogic.isNameVisibleToUser(fq, fr, student2.email, UserRole.STUDENT, false, roster));
    assertFalse(frLogic.isNameVisibleToUser(fq, fr, student5.email, UserRole.STUDENT, false, roster));
    ______TS("test anonymous team recipients");
    // Only members of the recipient team should be able to see the recipient name
    fq.recipientType = FeedbackParticipantType.TEAMS;
    fq.showRecipientNameTo.clear();
    fq.showRecipientNameTo.add(FeedbackParticipantType.RECEIVER);
    fq.showResponsesTo.add(FeedbackParticipantType.STUDENTS);
    fr.recipient = "Team 1.1";
    assertFalse(frLogic.isNameVisibleToUser(fq, fr, student5.email, UserRole.STUDENT, false, roster));
    ______TS("null question");
    assertFalse(frLogic.isNameVisibleToUser(null, fr, student.email, UserRole.STUDENT, false, roster));
}
Also used : InstructorsDb(teammates.storage.api.InstructorsDb) FeedbackResponseAttributes(teammates.common.datatransfer.attributes.FeedbackResponseAttributes) CourseRoster(teammates.common.datatransfer.CourseRoster) FeedbackQuestionAttributes(teammates.common.datatransfer.attributes.FeedbackQuestionAttributes) StudentAttributes(teammates.common.datatransfer.attributes.StudentAttributes) StudentsDb(teammates.storage.api.StudentsDb) InstructorAttributes(teammates.common.datatransfer.attributes.InstructorAttributes)

Example 3 with CourseRoster

use of teammates.common.datatransfer.CourseRoster in project teammates by TEAMMATES.

the class FeedbackSessionsLogic method getFeedbackSessionResultsForInstructorInSectionWithinRangeFromView.

/**
 * Gets results of a feedback session to show to an instructor in a section in an indicated range.
 */
public FeedbackSessionResultsBundle getFeedbackSessionResultsForInstructorInSectionWithinRangeFromView(String feedbackSessionName, String courseId, String userEmail, String section, int range, String viewType) throws EntityDoesNotExistException {
    CourseRoster roster = new CourseRoster(studentsLogic.getStudentsForCourse(courseId), instructorsLogic.getInstructorsForCourse(courseId));
    Map<String, String> params = new HashMap<>();
    params.put(PARAM_IS_INCLUDE_RESPONSE_STATUS, "true");
    params.put(PARAM_IN_SECTION, "false");
    params.put(PARAM_FROM_SECTION, "true");
    params.put(PARAM_TO_SECTION, "false");
    params.put(PARAM_SECTION, section);
    if (range > 0) {
        params.put(PARAM_RANGE, String.valueOf(range));
    }
    params.put(PARAM_VIEW_TYPE, viewType);
    return getFeedbackSessionResultsForUserWithParams(feedbackSessionName, courseId, userEmail, UserRole.INSTRUCTOR, roster, params);
}
Also used : HashMap(java.util.HashMap) CourseRoster(teammates.common.datatransfer.CourseRoster)

Example 4 with CourseRoster

use of teammates.common.datatransfer.CourseRoster in project teammates by TEAMMATES.

the class FeedbackSessionsLogic method getFeedbackSessionResultsForInstructorToSection.

/**
 * Gets results of  a feedback session to show to an instructor to a specific section.
 */
public FeedbackSessionResultsBundle getFeedbackSessionResultsForInstructorToSection(String feedbackSessionName, String courseId, String userEmail, String section) throws EntityDoesNotExistException {
    CourseRoster roster = new CourseRoster(studentsLogic.getStudentsForCourse(courseId), instructorsLogic.getInstructorsForCourse(courseId));
    Map<String, String> params = new HashMap<>();
    params.put(PARAM_IS_INCLUDE_RESPONSE_STATUS, "true");
    params.put(PARAM_IN_SECTION, "false");
    params.put(PARAM_FROM_SECTION, "false");
    params.put(PARAM_TO_SECTION, "true");
    params.put(PARAM_SECTION, section);
    return getFeedbackSessionResultsForUserWithParams(feedbackSessionName, courseId, userEmail, UserRole.INSTRUCTOR, roster, params);
}
Also used : HashMap(java.util.HashMap) CourseRoster(teammates.common.datatransfer.CourseRoster)

Example 5 with CourseRoster

use of teammates.common.datatransfer.CourseRoster in project teammates by TEAMMATES.

the class FeedbackSessionsLogic method getFeedbackSessionResultsForInstructorFromSectionWithinRange.

/**
 * Gets results of a feedback session to show to an instructor in a section in an indicated range.
 */
public FeedbackSessionResultsBundle getFeedbackSessionResultsForInstructorFromSectionWithinRange(String feedbackSessionName, String courseId, String userEmail, String section, int range) throws EntityDoesNotExistException {
    CourseRoster roster = new CourseRoster(studentsLogic.getStudentsForCourse(courseId), instructorsLogic.getInstructorsForCourse(courseId));
    Map<String, String> params = new HashMap<>();
    params.put(PARAM_IS_INCLUDE_RESPONSE_STATUS, "true");
    params.put(PARAM_IN_SECTION, "false");
    params.put(PARAM_FROM_SECTION, "true");
    params.put(PARAM_TO_SECTION, "false");
    params.put(PARAM_SECTION, section);
    if (range > 0) {
        params.put(PARAM_RANGE, String.valueOf(range));
    }
    return getFeedbackSessionResultsForUserWithParams(feedbackSessionName, courseId, userEmail, UserRole.INSTRUCTOR, roster, params);
}
Also used : HashMap(java.util.HashMap) CourseRoster(teammates.common.datatransfer.CourseRoster)

Aggregations

CourseRoster (teammates.common.datatransfer.CourseRoster)12 HashMap (java.util.HashMap)9 FeedbackQuestionAttributes (teammates.common.datatransfer.attributes.FeedbackQuestionAttributes)3 FeedbackResponseAttributes (teammates.common.datatransfer.attributes.FeedbackResponseAttributes)2 FeedbackSessionAttributes (teammates.common.datatransfer.attributes.FeedbackSessionAttributes)2 InstructorAttributes (teammates.common.datatransfer.attributes.InstructorAttributes)2 StudentAttributes (teammates.common.datatransfer.attributes.StudentAttributes)2 EntityDoesNotExistException (teammates.common.exception.EntityDoesNotExistException)2 Instant (java.time.Instant)1 ArrayList (java.util.ArrayList)1 Comparator (java.util.Comparator)1 Date (java.util.Date)1 HashSet (java.util.HashSet)1 List (java.util.List)1 Map (java.util.Map)1 Entry (java.util.Map.Entry)1 Set (java.util.Set)1 Test (org.testng.annotations.Test)1 FeedbackParticipantType (teammates.common.datatransfer.FeedbackParticipantType)1 FeedbackSessionDetailsBundle (teammates.common.datatransfer.FeedbackSessionDetailsBundle)1