use of teammates.logic.api.EmailGenerator in project teammates by TEAMMATES.
the class FeedbackSessionClosedRemindersAction method execute.
@Override
public void execute() {
List<FeedbackSessionAttributes> sessions = logic.getFeedbackSessionsClosedWithinThePastHour();
for (FeedbackSessionAttributes session : sessions) {
List<EmailWrapper> emailsToBeSent = new EmailGenerator().generateFeedbackSessionClosedEmails(session);
try {
taskQueuer.scheduleEmailsForSending(emailsToBeSent);
session.setSentClosedEmail(true);
logic.updateFeedbackSession(session);
} catch (Exception e) {
log.severe("Unexpected error: " + TeammatesException.toStringWithStackTrace(e));
}
}
}
use of teammates.logic.api.EmailGenerator in project teammates by TEAMMATES.
the class FeedbackSessionOpeningRemindersAction method execute.
@Override
public void execute() {
List<FeedbackSessionAttributes> sessions = logic.getFeedbackSessionsWhichNeedOpenEmailsToBeSent();
for (FeedbackSessionAttributes session : sessions) {
List<EmailWrapper> emailsToBeSent = new EmailGenerator().generateFeedbackSessionOpeningEmails(session);
try {
taskQueuer.scheduleEmailsForSending(emailsToBeSent);
session.setSentOpenEmail(true);
logic.updateFeedbackSession(session);
} catch (Exception e) {
log.severe("Unexpected error: " + TeammatesException.toStringWithStackTrace(e));
}
}
}
use of teammates.logic.api.EmailGenerator in project teammates by TEAMMATES.
the class FeedbackSessionRemindParticularUsersEmailWorkerAction method execute.
@Override
public void execute() {
String feedbackSessionName = getNonNullRequestParamValue(ParamsNames.SUBMISSION_FEEDBACK);
String courseId = getNonNullRequestParamValue(ParamsNames.SUBMISSION_COURSE);
String[] usersToRemind = getNonNullRequestParamValues(ParamsNames.SUBMISSION_REMIND_USERLIST);
String googleIdOfInstructorToNotify = getNonNullRequestParamValue(ParamsNames.USER_ID);
try {
FeedbackSessionAttributes session = logic.getFeedbackSession(feedbackSessionName, courseId);
List<StudentAttributes> studentsToRemindList = new ArrayList<>();
List<InstructorAttributes> instructorsToRemindList = new ArrayList<>();
InstructorAttributes instructorToNotify = logic.getInstructorForGoogleId(courseId, googleIdOfInstructorToNotify);
for (String userEmail : usersToRemind) {
StudentAttributes student = logic.getStudentForEmail(courseId, userEmail);
if (student != null) {
studentsToRemindList.add(student);
}
InstructorAttributes instructor = logic.getInstructorForEmail(courseId, userEmail);
if (instructor != null) {
instructorsToRemindList.add(instructor);
}
}
List<EmailWrapper> emails = new EmailGenerator().generateFeedbackSessionReminderEmails(session, studentsToRemindList, instructorsToRemindList, instructorToNotify);
taskQueuer.scheduleEmailsForSending(emails);
} catch (Exception e) {
log.severe("Unexpected error while sending emails: " + TeammatesException.toStringWithStackTrace(e));
}
}
use of teammates.logic.api.EmailGenerator in project teammates by TEAMMATES.
the class InstructorCourseJoinEmailWorkerAction method execute.
@Override
public void execute() {
String inviterId = getRequestParamValue(ParamsNames.INVITER_ID);
Assumption.assertPostParamNotNull(ParamsNames.INVITER_ID, inviterId);
String courseId = getRequestParamValue(ParamsNames.COURSE_ID);
Assumption.assertPostParamNotNull(ParamsNames.COURSE_ID, courseId);
String instructorEmail = getRequestParamValue(ParamsNames.INSTRUCTOR_EMAIL);
Assumption.assertPostParamNotNull(ParamsNames.INSTRUCTOR_EMAIL, instructorEmail);
AccountAttributes inviter = logic.getAccount(inviterId);
Assumption.assertNotNull(inviter);
CourseAttributes course = logic.getCourse(courseId);
Assumption.assertNotNull(course);
InstructorAttributes instructor = logic.getInstructorForEmail(courseId, instructorEmail);
Assumption.assertNotNull(instructor);
EmailWrapper email = new EmailGenerator().generateInstructorCourseJoinEmail(inviter, instructor, course);
try {
emailSender.sendEmail(email);
} catch (Exception e) {
Assumption.fail("Unexpected error while sending email" + TeammatesException.toStringWithStackTrace(e));
}
}
Aggregations