use of teammates.common.util.EmailWrapper in project teammates by TEAMMATES.
the class TaskQueuer method scheduleEmailsForSending.
/**
* Schedules for the given list of emails to be sent.
*
* @param emails the list of emails to be sent
*/
public void scheduleEmailsForSending(List<EmailWrapper> emails) {
if (emails.isEmpty()) {
return;
}
// Equally spread out the emails to be sent over 1 hour
// Sets interval to a maximum of 5 seconds if the interval is too large
int oneHourInMillis = 60 * 60 * 1000;
int emailIntervalMillis = Math.min(5000, oneHourInMillis / emails.size());
int numberOfEmailsSent = 0;
for (EmailWrapper email : emails) {
long emailDelayTimer = numberOfEmailsSent * emailIntervalMillis;
scheduleEmailForSending(email, emailDelayTimer);
numberOfEmailsSent++;
}
}
use of teammates.common.util.EmailWrapper in project teammates by TEAMMATES.
the class EmailGenerator method generateStudentCourseJoinEmail.
/**
* Generates the course join email for the given {@code student} in {@code course}.
*/
public EmailWrapper generateStudentCourseJoinEmail(CourseAttributes course, StudentAttributes student) {
String emailBody = Templates.populateTemplate(fillUpStudentJoinFragment(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_JOIN.getSubject(), course.getName(), course.getId()));
email.setContent(emailBody);
return email;
}
use of teammates.common.util.EmailWrapper in project teammates by TEAMMATES.
the class EmailGenerator method generateSubmissionConfirmationEmail.
private EmailWrapper generateSubmissionConfirmationEmail(CourseAttributes course, FeedbackSessionAttributes session, String submitUrl, String userName, String userEmail, Instant timestamp) {
String template = EmailTemplates.USER_FEEDBACK_SUBMISSION_CONFIRMATION;
String subject = EmailType.FEEDBACK_SUBMISSION_CONFIRMATION.getSubject();
String additionalContactInformation = getAdditionalContactInformationFragment(course);
String emailBody = Templates.populateTemplate(template, "${userName}", SanitizationHelper.sanitizeForHtml(userName), "${courseName}", SanitizationHelper.sanitizeForHtml(course.getName()), "${courseId}", SanitizationHelper.sanitizeForHtml(course.getId()), "${feedbackSessionName}", SanitizationHelper.sanitizeForHtml(session.getFeedbackSessionName()), "${deadline}", SanitizationHelper.sanitizeForHtml(session.getEndTimeString()), "${submitUrl}", submitUrl, "${timeStamp}", SanitizationHelper.sanitizeForHtml(TimeHelper.formatDateTimeForSessions(timestamp, session.getTimeZone())), "${additionalContactInformation}", additionalContactInformation);
EmailWrapper email = getEmptyEmailAddressedToEmail(userEmail);
email.setSubject(String.format(subject, course.getName(), session.getFeedbackSessionName()));
email.setContent(emailBody);
return email;
}
use of teammates.common.util.EmailWrapper in project teammates by TEAMMATES.
the class EmailGenerator method generateFeedbackSessionEmailBaseForInstructorReminders.
private EmailWrapper generateFeedbackSessionEmailBaseForInstructorReminders(CourseAttributes course, FeedbackSessionAttributes session, InstructorAttributes instructor, String template, String subject, String additionalContactInformation) {
String submitUrl = Config.getAppUrl(Const.ActionURIs.INSTRUCTOR_FEEDBACK_SUBMISSION_EDIT_PAGE).withCourseId(course.getId()).withSessionName(session.getFeedbackSessionName()).toAbsoluteString();
String reportUrl = Config.getAppUrl(Const.ActionURIs.INSTRUCTOR_FEEDBACK_RESULTS_PAGE).withCourseId(course.getId()).withSessionName(session.getFeedbackSessionName()).toAbsoluteString();
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}", "", "${sessionInstructions}", session.getInstructionsString(), "${submitUrl}", submitUrl, "${reportUrl}", reportUrl, "${feedbackAction}", FEEDBACK_ACTION_SUBMIT, "${additionalContactInformation}", additionalContactInformation);
EmailWrapper email = getEmptyEmailAddressedToEmail(instructor.email);
email.setSubject(String.format(subject, course.getName(), session.getFeedbackSessionName()));
email.setContent(emailBody);
return email;
}
use of teammates.common.util.EmailWrapper in project teammates by TEAMMATES.
the class EmailGenerator method generateFeedbackSessionOpeningEmails.
/**
* Generates the feedback session opening emails for the given {@code session}.
*/
public List<EmailWrapper> generateFeedbackSessionOpeningEmails(FeedbackSessionAttributes session) {
String template = EmailTemplates.USER_FEEDBACK_SESSION;
CourseAttributes course = coursesLogic.getCourse(session.getCourseId());
boolean isEmailNeeded = fsLogic.isFeedbackSessionForStudentsToAnswer(session);
List<InstructorAttributes> instructors = isEmailNeeded ? instructorsLogic.getInstructorsForCourse(session.getCourseId()) : new ArrayList<InstructorAttributes>();
List<StudentAttributes> students = isEmailNeeded ? studentsLogic.getStudentsForCourse(session.getCourseId()) : new ArrayList<StudentAttributes>();
List<EmailWrapper> emails = generateFeedbackSessionEmailBases(course, session, students, instructors, template, EmailType.FEEDBACK_OPENING.getSubject());
for (EmailWrapper email : emails) {
email.setContent(email.getContent().replace("${status}", FEEDBACK_STATUS_SESSION_OPENING));
}
return emails;
}
Aggregations