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");
}
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));
}
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);
}
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);
}
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);
}
Aggregations