Search in sources :

Example 26 with CourseAttributes

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

the class EmailGenerator method generateFeedbackSessionPublishedEmails.

/**
 * Generates the feedback session published emails for the given {@code session}.
 */
public List<EmailWrapper> generateFeedbackSessionPublishedEmails(FeedbackSessionAttributes session) {
    String template = EmailTemplates.USER_FEEDBACK_SESSION_PUBLISHED;
    CourseAttributes course = coursesLogic.getCourse(session.getCourseId());
    boolean isEmailNeeded = fsLogic.isFeedbackSessionViewableToStudents(session);
    List<InstructorAttributes> instructors = isEmailNeeded ? instructorsLogic.getInstructorsForCourse(session.getCourseId()) : new ArrayList<InstructorAttributes>();
    List<StudentAttributes> students = isEmailNeeded ? studentsLogic.getStudentsForCourse(session.getCourseId()) : new ArrayList<StudentAttributes>();
    String additionalContactInformation = getAdditionalContactInformationFragment(course);
    return generateFeedbackSessionEmailBases(course, session, students, instructors, template, EmailType.FEEDBACK_PUBLISHED.getSubject(), FEEDBACK_ACTION_VIEW, additionalContactInformation);
}
Also used : StudentAttributes(teammates.common.datatransfer.attributes.StudentAttributes) CourseAttributes(teammates.common.datatransfer.attributes.CourseAttributes) InstructorAttributes(teammates.common.datatransfer.attributes.InstructorAttributes)

Example 27 with CourseAttributes

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

the class EmailGenerator method generateFeedbackSessionUnpublishedEmails.

/**
 * Generates the feedback session published emails for the given {@code session}.
 */
public List<EmailWrapper> generateFeedbackSessionUnpublishedEmails(FeedbackSessionAttributes session) {
    String template = EmailTemplates.USER_FEEDBACK_SESSION_UNPUBLISHED;
    CourseAttributes course = coursesLogic.getCourse(session.getCourseId());
    boolean isEmailNeeded = fsLogic.isFeedbackSessionViewableToStudents(session);
    List<InstructorAttributes> instructors = isEmailNeeded ? instructorsLogic.getInstructorsForCourse(session.getCourseId()) : new ArrayList<InstructorAttributes>();
    List<StudentAttributes> students = isEmailNeeded ? studentsLogic.getStudentsForCourse(session.getCourseId()) : new ArrayList<StudentAttributes>();
    return generateFeedbackSessionEmailBases(course, session, students, instructors, template, EmailType.FEEDBACK_UNPUBLISHED.getSubject());
}
Also used : StudentAttributes(teammates.common.datatransfer.attributes.StudentAttributes) CourseAttributes(teammates.common.datatransfer.attributes.CourseAttributes) InstructorAttributes(teammates.common.datatransfer.attributes.InstructorAttributes)

Example 28 with CourseAttributes

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

the class EmailGenerator method generateFeedbackSessionSummaryOfCourse.

/**
 * Generates the email containing the summary of the feedback sessions
 * email for the given {@code courseId} for {@code student}.
 * @param courseId - ID of the course
 * @param student - attributes of student to send feedback session summary to
 */
public EmailWrapper generateFeedbackSessionSummaryOfCourse(String courseId, StudentAttributes student) {
    CourseAttributes course = coursesLogic.getCourse(courseId);
    List<FeedbackSessionAttributes> sessions = new ArrayList<>();
    List<FeedbackSessionAttributes> fsInCourse = fsLogic.getFeedbackSessionsForCourse(courseId);
    for (FeedbackSessionAttributes fsa : fsInCourse) {
        if (!fsa.isPrivateSession() && (fsa.isSentOpenEmail() || fsa.isSentPublishedEmail())) {
            sessions.add(fsa);
        }
    }
    StringBuffer linksFragmentValue = new StringBuffer(1000);
    String joinUrl = Config.getAppUrl(student.getRegistrationUrl()).toAbsoluteString();
    String joinFragmentValue = isYetToJoinCourse(student) ? Templates.populateTemplate(EmailTemplates.FRAGMENT_STUDENT_COURSE_JOIN, "${joinUrl}", joinUrl, "${courseName}", SanitizationHelper.sanitizeForHtml(course.getName())) : "";
    for (FeedbackSessionAttributes fsa : sessions) {
        String submitUrlHtml = "(Feedback session is not yet opened)";
        String reportUrlHtml = "(Feedback session is not yet published)";
        if (fsa.isOpened() || fsa.isClosed()) {
            String submitUrl = Config.getAppUrl(Const.ActionURIs.STUDENT_FEEDBACK_SUBMISSION_EDIT_PAGE).withCourseId(course.getId()).withSessionName(fsa.getFeedbackSessionName()).withRegistrationKey(StringHelper.encrypt(student.key)).withStudentEmail(student.email).toAbsoluteString();
            submitUrlHtml = "<a href=\"" + submitUrl + "\">" + submitUrl + "</a>";
        }
        if (fsa.isPublished()) {
            String reportUrl = Config.getAppUrl(Const.ActionURIs.STUDENT_FEEDBACK_RESULTS_PAGE).withCourseId(course.getId()).withSessionName(fsa.getFeedbackSessionName()).withRegistrationKey(StringHelper.encrypt(student.key)).withStudentEmail(student.email).toAbsoluteString();
            reportUrlHtml = "<a href=\"" + reportUrl + "\">" + reportUrl + "</a>";
        }
        linksFragmentValue.append(Templates.populateTemplate(EmailTemplates.FRAGMENT_SINGLE_FEEDBACK_SESSION_LINKS, "${feedbackSessionName}", fsa.getFeedbackSessionName(), "${deadline}", fsa.getEndTimeString() + (fsa.isClosed() ? " (Passed)" : ""), "${submitUrl}", submitUrlHtml, "${reportUrl}", reportUrlHtml));
    }
    String additionalContactInformation = getAdditionalContactInformationFragment(course);
    String emailBody = Templates.populateTemplate(EmailTemplates.USER_FEEDBACK_SESSION_RESEND_ALL_LINKS, "${userName}", SanitizationHelper.sanitizeForHtml(student.name), "${userEmail}", student.email, "${courseName}", SanitizationHelper.sanitizeForHtml(course.getName()), "${courseId}", course.getId(), "${joinFragment}", joinFragmentValue, "${linksFragment}", linksFragmentValue.toString(), "${additionalContactInformation}", additionalContactInformation);
    EmailWrapper email = getEmptyEmailAddressedToEmail(student.email);
    email.setSubject(String.format(EmailType.STUDENT_EMAIL_CHANGED.getSubject(), course.getName(), course.getId()));
    email.setContent(emailBody);
    return email;
}
Also used : FeedbackSessionAttributes(teammates.common.datatransfer.attributes.FeedbackSessionAttributes) ArrayList(java.util.ArrayList) CourseAttributes(teammates.common.datatransfer.attributes.CourseAttributes) EmailWrapper(teammates.common.util.EmailWrapper)

Example 29 with CourseAttributes

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

the class EmailGenerator method generateFeedbackSubmissionConfirmationEmailForInstructor.

/**
 * Generates the feedback submission confirmation email for the given {@code session} for {@code instructor}.
 */
public EmailWrapper generateFeedbackSubmissionConfirmationEmailForInstructor(FeedbackSessionAttributes session, InstructorAttributes instructor, Instant timestamp) {
    CourseAttributes course = coursesLogic.getCourse(session.getCourseId());
    String submitUrl = Config.getAppUrl(Const.ActionURIs.INSTRUCTOR_FEEDBACK_SUBMISSION_EDIT_PAGE).withCourseId(course.getId()).withSessionName(session.getFeedbackSessionName()).toAbsoluteString();
    return generateSubmissionConfirmationEmail(course, session, submitUrl, instructor.name, instructor.email, timestamp);
}
Also used : CourseAttributes(teammates.common.datatransfer.attributes.CourseAttributes)

Example 30 with CourseAttributes

use of teammates.common.datatransfer.attributes.CourseAttributes 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)

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