use of teammates.common.datatransfer.attributes.StudentAttributes in project teammates by TEAMMATES.
the class CourseRoster method isStudentsInSameTeam.
public boolean isStudentsInSameTeam(String studentEmail1, String studentEmail2) {
StudentAttributes student1 = studentListByEmail.get(studentEmail1);
StudentAttributes student2 = studentListByEmail.get(studentEmail2);
return student1 != null && student2 != null && student1.team != null && student1.team.equals(student2.team);
}
use of teammates.common.datatransfer.attributes.StudentAttributes in project teammates by TEAMMATES.
the class CoursesLogicTest method testGetCoursesForStudentAccount.
private void testGetCoursesForStudentAccount() throws Exception {
______TS("student having two courses");
StudentAttributes studentInTwoCourses = dataBundle.students.get("student2InCourse1");
List<CourseAttributes> courseList = coursesLogic.getCoursesForStudentAccount(studentInTwoCourses.googleId);
CourseAttributes.sortById(courseList);
assertEquals(2, courseList.size());
CourseAttributes course1 = dataBundle.courses.get("typicalCourse1");
CourseAttributes course2 = dataBundle.courses.get("typicalCourse2");
List<CourseAttributes> courses = new ArrayList<>();
courses.add(course1);
courses.add(course2);
CourseAttributes.sortById(courses);
assertEquals(courses.get(0).getId(), courseList.get(0).getId());
assertEquals(courses.get(0).getName(), courseList.get(0).getName());
assertEquals(courses.get(1).getId(), courseList.get(1).getId());
assertEquals(courses.get(1).getName(), courseList.get(1).getName());
______TS("student having one course");
StudentAttributes studentInOneCourse = dataBundle.students.get("student1InCourse1");
courseList = coursesLogic.getCoursesForStudentAccount(studentInOneCourse.googleId);
assertEquals(1, courseList.size());
course1 = dataBundle.courses.get("typicalCourse1");
assertEquals(course1.getId(), courseList.get(0).getId());
assertEquals(course1.getName(), courseList.get(0).getName());
// Student having zero courses is not applicable
______TS("non-existent student");
try {
coursesLogic.getCoursesForStudentAccount("non-existent-student");
signalFailureToDetectException();
} catch (EntityDoesNotExistException e) {
AssertHelper.assertContains("does not exist", e.getMessage());
}
______TS("null parameter");
try {
coursesLogic.getCoursesForStudentAccount(null);
signalFailureToDetectException();
} catch (AssertionError e) {
assertEquals(Const.StatusCodes.DBLEVEL_NULL_INPUT, e.getMessage());
}
}
use of teammates.common.datatransfer.attributes.StudentAttributes in project teammates by TEAMMATES.
the class CoursesLogicTest method testDeleteCourse.
private void testDeleteCourse() {
______TS("typical case");
CourseAttributes course1OfInstructor = dataBundle.courses.get("typicalCourse1");
StudentAttributes studentInCourse = dataBundle.students.get("student1InCourse1");
// Ensure there are entities in the datastore under this course
assertFalse(StudentsLogic.inst().getStudentsForCourse(course1OfInstructor.getId()).isEmpty());
verifyPresentInDatastore(course1OfInstructor);
verifyPresentInDatastore(studentInCourse);
verifyPresentInDatastore(dataBundle.instructors.get("instructor1OfCourse1"));
verifyPresentInDatastore(dataBundle.instructors.get("instructor3OfCourse1"));
verifyPresentInDatastore(dataBundle.students.get("student1InCourse1"));
verifyPresentInDatastore(dataBundle.students.get("student5InCourse1"));
verifyPresentInDatastore(dataBundle.feedbackSessions.get("session1InCourse1"));
verifyPresentInDatastore(dataBundle.feedbackSessions.get("session2InCourse1"));
assertEquals(course1OfInstructor.getId(), studentInCourse.course);
coursesLogic.deleteCourseCascade(course1OfInstructor.getId());
// Ensure the course and related entities are deleted
verifyAbsentInDatastore(course1OfInstructor);
verifyAbsentInDatastore(studentInCourse);
verifyAbsentInDatastore(dataBundle.instructors.get("instructor1OfCourse1"));
verifyAbsentInDatastore(dataBundle.instructors.get("instructor3OfCourse1"));
verifyAbsentInDatastore(dataBundle.students.get("student1InCourse1"));
verifyAbsentInDatastore(dataBundle.students.get("student5InCourse1"));
verifyAbsentInDatastore(dataBundle.feedbackSessions.get("session1InCourse1"));
verifyAbsentInDatastore(dataBundle.feedbackSessions.get("session2InCourse1"));
______TS("non-existent");
// try to delete again. Should fail silently.
coursesLogic.deleteCourseCascade(course1OfInstructor.getId());
______TS("null parameter");
try {
coursesLogic.deleteCourseCascade(null);
signalFailureToDetectException();
} catch (AssertionError e) {
assertEquals(Const.StatusCodes.DBLEVEL_NULL_INPUT, e.getMessage());
}
}
use of teammates.common.datatransfer.attributes.StudentAttributes in project teammates by TEAMMATES.
the class CoursesLogicTest method testGetCourseDetailsListForStudent.
private void testGetCourseDetailsListForStudent() throws Exception {
______TS("student having multiple evaluations in multiple courses");
CourseAttributes expectedCourse1 = dataBundle.courses.get("typicalCourse1");
// This student is in both course 1 and 2
StudentAttributes studentInBothCourses = dataBundle.students.get("student2InCourse1");
// Get course details for student
List<CourseDetailsBundle> courseList = coursesLogic.getCourseDetailsListForStudent(studentInBothCourses.googleId);
// Verify number of courses received
assertEquals(2, courseList.size());
CourseDetailsBundle actualCourse1 = courseList.get(0);
assertEquals(expectedCourse1.getId(), actualCourse1.course.getId());
assertEquals(expectedCourse1.getName(), actualCourse1.course.getName());
// student with no courses is not applicable
______TS("non-existent student");
try {
coursesLogic.getCourseDetailsListForStudent("non-existent-student");
signalFailureToDetectException();
} catch (EntityDoesNotExistException e) {
AssertHelper.assertContains("does not exist", e.getMessage());
}
______TS("null parameter");
try {
coursesLogic.getCourseDetailsListForStudent(null);
signalFailureToDetectException();
} catch (AssertionError e) {
assertEquals(Const.StatusCodes.DBLEVEL_NULL_INPUT, e.getMessage());
}
}
use of teammates.common.datatransfer.attributes.StudentAttributes in project teammates by TEAMMATES.
the class EmailGeneratorTest method testGenerateFeedbackSessionEmails_testSanitization.
@Test
public void testGenerateFeedbackSessionEmails_testSanitization() throws IOException {
FeedbackSessionAttributes session = fsLogic.getFeedbackSession("Normal feedback session name", "idOfTestingSanitizationCourse");
CourseAttributes course = coursesLogic.getCourse(session.getCourseId());
StudentAttributes student1 = studentsLogic.getStudentForEmail(course.getId(), "normal@sanitization.tmt");
InstructorAttributes instructor1 = instructorsLogic.getInstructorForEmail(course.getId(), "instructor1@sanitization.tmt");
______TS("feedback session opening emails: sanitization required");
List<EmailWrapper> emails = new EmailGenerator().generateFeedbackSessionOpeningEmails(session);
assertEquals(2, emails.size());
String subject = String.format(EmailType.FEEDBACK_OPENING.getSubject(), course.getName(), session.getFeedbackSessionName());
verifyEmailReceivedCorrectly(emails, student1.email, subject, "/sessionOpeningEmailTestingSanitzationForStudent.html");
verifyEmailReceivedCorrectly(emails, instructor1.email, subject, "/sessionOpeningEmailTestingSanitizationForInstructor.html");
______TS("feedback session closed alerts: sanitization required");
emails = new EmailGenerator().generateFeedbackSessionClosedEmails(session);
assertEquals(2, emails.size());
subject = String.format(EmailType.FEEDBACK_CLOSED.getSubject(), course.getName(), session.getFeedbackSessionName());
verifyEmailReceivedCorrectly(emails, student1.email, subject, "/sessionClosedEmailTestingSanitizationForStudent.html");
verifyEmailReceivedCorrectly(emails, instructor1.email, subject, "/sessionClosedEmailTestingSanitizationForInstructor.html");
______TS("feedback sessions summary of course email: sanitization required");
EmailWrapper email = new EmailGenerator().generateFeedbackSessionSummaryOfCourse(session.getCourseId(), student1);
subject = String.format(EmailType.STUDENT_EMAIL_CHANGED.getSubject(), course.getName(), course.getId());
verifyEmail(email, student1.email, subject, "/summaryOfFeedbackSessionsOfCourseEmailTestingSanitizationForStudent.html");
______TS("feedback session submission email: sanitization required");
Instant time = TimeHelper.parseInstant("2016-09-04 05:30 AM +0000");
email = new EmailGenerator().generateFeedbackSubmissionConfirmationEmailForInstructor(session, instructor1, time);
subject = String.format(EmailType.FEEDBACK_SUBMISSION_CONFIRMATION.getSubject(), course.getName(), session.getFeedbackSessionName());
verifyEmail(email, instructor1.email, subject, "/sessionSubmissionConfirmationEmailTestingSanitization.html");
}
Aggregations