Search in sources :

Example 21 with EmailGenerator

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));
        }
    }
}
Also used : FeedbackSessionAttributes(teammates.common.datatransfer.attributes.FeedbackSessionAttributes) EmailGenerator(teammates.logic.api.EmailGenerator) TeammatesException(teammates.common.exception.TeammatesException) EmailWrapper(teammates.common.util.EmailWrapper)

Example 22 with EmailGenerator

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));
        }
    }
}
Also used : FeedbackSessionAttributes(teammates.common.datatransfer.attributes.FeedbackSessionAttributes) EmailGenerator(teammates.logic.api.EmailGenerator) TeammatesException(teammates.common.exception.TeammatesException) EmailWrapper(teammates.common.util.EmailWrapper)

Example 23 with EmailGenerator

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));
    }
}
Also used : FeedbackSessionAttributes(teammates.common.datatransfer.attributes.FeedbackSessionAttributes) EmailGenerator(teammates.logic.api.EmailGenerator) ArrayList(java.util.ArrayList) StudentAttributes(teammates.common.datatransfer.attributes.StudentAttributes) TeammatesException(teammates.common.exception.TeammatesException) InstructorAttributes(teammates.common.datatransfer.attributes.InstructorAttributes) EmailWrapper(teammates.common.util.EmailWrapper)

Example 24 with EmailGenerator

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));
    }
}
Also used : EmailGenerator(teammates.logic.api.EmailGenerator) AccountAttributes(teammates.common.datatransfer.attributes.AccountAttributes) TeammatesException(teammates.common.exception.TeammatesException) CourseAttributes(teammates.common.datatransfer.attributes.CourseAttributes) InstructorAttributes(teammates.common.datatransfer.attributes.InstructorAttributes) EmailWrapper(teammates.common.util.EmailWrapper)

Aggregations

EmailWrapper (teammates.common.util.EmailWrapper)24 EmailGenerator (teammates.logic.api.EmailGenerator)24 TeammatesException (teammates.common.exception.TeammatesException)12 CourseAttributes (teammates.common.datatransfer.attributes.CourseAttributes)10 FeedbackSessionAttributes (teammates.common.datatransfer.attributes.FeedbackSessionAttributes)10 InstructorAttributes (teammates.common.datatransfer.attributes.InstructorAttributes)10 Test (org.testng.annotations.Test)9 StudentAttributes (teammates.common.datatransfer.attributes.StudentAttributes)9 ArrayList (java.util.ArrayList)3 AccountAttributes (teammates.common.datatransfer.attributes.AccountAttributes)3 EmailSendingException (teammates.common.exception.EmailSendingException)3 StatusMessage (teammates.common.util.StatusMessage)3 Instant (java.time.Instant)2 EntityDoesNotExistException (teammates.common.exception.EntityDoesNotExistException)2 InvalidParametersException (teammates.common.exception.InvalidParametersException)2 AppLogLine (com.google.appengine.api.log.AppLogLine)1 AdminEmailAttributes (teammates.common.datatransfer.attributes.AdminEmailAttributes)1 FeedbackQuestionAttributes (teammates.common.datatransfer.attributes.FeedbackQuestionAttributes)1 FeedbackResponseAttributes (teammates.common.datatransfer.attributes.FeedbackResponseAttributes)1 FeedbackQuestionDetails (teammates.common.datatransfer.questions.FeedbackQuestionDetails)1