Search in sources :

Example 61 with StudentAttributes

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);
}
Also used : StudentAttributes(teammates.common.datatransfer.attributes.StudentAttributes)

Example 62 with StudentAttributes

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());
    }
}
Also used : ArrayList(java.util.ArrayList) StudentAttributes(teammates.common.datatransfer.attributes.StudentAttributes) CourseAttributes(teammates.common.datatransfer.attributes.CourseAttributes) EntityDoesNotExistException(teammates.common.exception.EntityDoesNotExistException)

Example 63 with StudentAttributes

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());
    }
}
Also used : StudentAttributes(teammates.common.datatransfer.attributes.StudentAttributes) CourseAttributes(teammates.common.datatransfer.attributes.CourseAttributes)

Example 64 with StudentAttributes

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());
    }
}
Also used : CourseDetailsBundle(teammates.common.datatransfer.CourseDetailsBundle) StudentAttributes(teammates.common.datatransfer.attributes.StudentAttributes) CourseAttributes(teammates.common.datatransfer.attributes.CourseAttributes) EntityDoesNotExistException(teammates.common.exception.EntityDoesNotExistException)

Example 65 with StudentAttributes

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");
}
Also used : FeedbackSessionAttributes(teammates.common.datatransfer.attributes.FeedbackSessionAttributes) EmailGenerator(teammates.logic.api.EmailGenerator) Instant(java.time.Instant) StudentAttributes(teammates.common.datatransfer.attributes.StudentAttributes) CourseAttributes(teammates.common.datatransfer.attributes.CourseAttributes) InstructorAttributes(teammates.common.datatransfer.attributes.InstructorAttributes) EmailWrapper(teammates.common.util.EmailWrapper) Test(org.testng.annotations.Test)

Aggregations

StudentAttributes (teammates.common.datatransfer.attributes.StudentAttributes)241 InstructorAttributes (teammates.common.datatransfer.attributes.InstructorAttributes)85 Test (org.testng.annotations.Test)80 ArrayList (java.util.ArrayList)55 CourseAttributes (teammates.common.datatransfer.attributes.CourseAttributes)33 FeedbackSessionAttributes (teammates.common.datatransfer.attributes.FeedbackSessionAttributes)33 FeedbackResponseAttributes (teammates.common.datatransfer.attributes.FeedbackResponseAttributes)30 EntityDoesNotExistException (teammates.common.exception.EntityDoesNotExistException)27 FeedbackQuestionAttributes (teammates.common.datatransfer.attributes.FeedbackQuestionAttributes)22 AccountAttributes (teammates.common.datatransfer.attributes.AccountAttributes)17 ShowPageResult (teammates.ui.controller.ShowPageResult)15 HashMap (java.util.HashMap)14 TeamDetailsBundle (teammates.common.datatransfer.TeamDetailsBundle)14 InvalidParametersException (teammates.common.exception.InvalidParametersException)14 EmailWrapper (teammates.common.util.EmailWrapper)13 RedirectResult (teammates.ui.controller.RedirectResult)12 List (java.util.List)11 StatusMessage (teammates.common.util.StatusMessage)10 HashSet (java.util.HashSet)9 StudentEnrollDetails (teammates.common.datatransfer.StudentEnrollDetails)9