Search in sources :

Example 11 with EmailWrapper

use of teammates.common.util.EmailWrapper in project teammates by TEAMMATES.

the class EmailGenerator method generateStudentCourseRejoinEmailAfterGoogleIdReset.

/**
 * Generates the course re-join email for the given {@code student} in {@code course}.
 */
public EmailWrapper generateStudentCourseRejoinEmailAfterGoogleIdReset(CourseAttributes course, StudentAttributes student) {
    String emailBody = Templates.populateTemplate(fillUpStudentRejoinAfterGoogleIdResetFragment(student, EmailTemplates.USER_COURSE_JOIN), "${userName}", SanitizationHelper.sanitizeForHtml(student.name), "${courseName}", SanitizationHelper.sanitizeForHtml(course.getName()), "${coOwnersEmails}", generateCoOwnersEmailsLine(course.getId()), "${supportEmail}", Config.SUPPORT_EMAIL);
    EmailWrapper email = getEmptyEmailAddressedToEmail(student.email);
    email.setSubject(String.format(EmailType.STUDENT_COURSE_REJOIN_AFTER_GOOGLE_ID_RESET.getSubject(), course.getName(), course.getId()));
    email.setContent(emailBody);
    return email;
}
Also used : EmailWrapper(teammates.common.util.EmailWrapper)

Example 12 with EmailWrapper

use of teammates.common.util.EmailWrapper in project teammates by TEAMMATES.

the class EmailGenerator method generateCompiledLogsEmail.

/**
 * Generates the logs compilation email for the given {@code logs}.
 */
public EmailWrapper generateCompiledLogsEmail(List<AppLogLine> logs) {
    StringBuilder emailBody = new StringBuilder();
    for (int i = 0; i < logs.size(); i++) {
        emailBody.append(generateSevereErrorLogLine(i, logs.get(i)));
    }
    EmailWrapper email = getEmptyEmailAddressedToEmail(Config.SUPPORT_EMAIL);
    email.setSubject(String.format(EmailType.SEVERE_LOGS_COMPILATION.getSubject(), Config.getAppVersion()));
    email.setContent(emailBody.toString());
    return email;
}
Also used : EmailWrapper(teammates.common.util.EmailWrapper)

Example 13 with EmailWrapper

use of teammates.common.util.EmailWrapper in project teammates by TEAMMATES.

the class EmailGenerator method generateFeedbackSessionEmailBaseForInstructors.

private EmailWrapper generateFeedbackSessionEmailBaseForInstructors(CourseAttributes course, FeedbackSessionAttributes session, InstructorAttributes instructor, String template, String subject, String feedbackAction, String additionalContactInformation) {
    String instructorFragment = generateInstructorPreamble(course.getId(), course.getName());
    String emailBody = Templates.populateTemplate(template, "${userName}", SanitizationHelper.sanitizeForHtml(instructor.name), "${courseName}", SanitizationHelper.sanitizeForHtml(course.getName()), "${courseId}", SanitizationHelper.sanitizeForHtml(course.getId()), "${feedbackSessionName}", SanitizationHelper.sanitizeForHtml(session.getFeedbackSessionName()), "${deadline}", SanitizationHelper.sanitizeForHtml(session.getEndTimeString()), "${instructorFragment}", instructorFragment, "${sessionInstructions}", session.getInstructionsString(), "${submitUrl}", "{in the actual email sent to the students, this will be the unique link}", "${reportUrl}", "{in the actual email sent to the students, this will be the unique link}", "${feedbackAction}", feedbackAction, "${additionalContactInformation}", additionalContactInformation);
    EmailWrapper email = getEmptyEmailAddressedToEmail(instructor.email);
    email.setSubject(String.format(subject, course.getName(), session.getFeedbackSessionName()));
    email.setContent(emailBody);
    return email;
}
Also used : EmailWrapper(teammates.common.util.EmailWrapper)

Example 14 with EmailWrapper

use of teammates.common.util.EmailWrapper 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 15 with EmailWrapper

use of teammates.common.util.EmailWrapper in project teammates by TEAMMATES.

the class EmailGenerator method generateAdminEmail.

/**
 * Generates a generic email with the specified {@code content}, {@code subject}, and {@code recipient}.
 */
public EmailWrapper generateAdminEmail(String content, String subject, String recipient) {
    EmailWrapper email = getEmptyEmailAddressedToEmail(recipient);
    email.setSubject(subject);
    email.setContent(content);
    return email;
}
Also used : EmailWrapper(teammates.common.util.EmailWrapper)

Aggregations

EmailWrapper (teammates.common.util.EmailWrapper)55 EmailGenerator (teammates.logic.api.EmailGenerator)24 Test (org.testng.annotations.Test)20 CourseAttributes (teammates.common.datatransfer.attributes.CourseAttributes)15 InstructorAttributes (teammates.common.datatransfer.attributes.InstructorAttributes)15 StudentAttributes (teammates.common.datatransfer.attributes.StudentAttributes)13 TeammatesException (teammates.common.exception.TeammatesException)13 FeedbackSessionAttributes (teammates.common.datatransfer.attributes.FeedbackSessionAttributes)12 ArrayList (java.util.ArrayList)6 AccountAttributes (teammates.common.datatransfer.attributes.AccountAttributes)4 FeedbackQuestionAttributes (teammates.common.datatransfer.attributes.FeedbackQuestionAttributes)3 FeedbackResponseAttributes (teammates.common.datatransfer.attributes.FeedbackResponseAttributes)3 EmailSendingException (teammates.common.exception.EmailSendingException)3 NullPostParameterException (teammates.common.exception.NullPostParameterException)3 StatusMessage (teammates.common.util.StatusMessage)3 RedirectResult (teammates.ui.controller.RedirectResult)3 Instant (java.time.Instant)2 DataBundle (teammates.common.datatransfer.DataBundle)2 FeedbackNumericalScaleQuestionDetails (teammates.common.datatransfer.questions.FeedbackNumericalScaleQuestionDetails)2 EntityDoesNotExistException (teammates.common.exception.EntityDoesNotExistException)2