Search in sources :

Example 11 with EmailGenerator

use of teammates.logic.api.EmailGenerator in project teammates by TEAMMATES.

the class FeedbackSessionClosingRemindersAction method execute.

@Override
public void execute() {
    List<FeedbackSessionAttributes> sessions = logic.getFeedbackSessionsClosingWithinTimeLimit();
    for (FeedbackSessionAttributes session : sessions) {
        List<EmailWrapper> emailsToBeSent = new EmailGenerator().generateFeedbackSessionClosingEmails(session);
        try {
            taskQueuer.scheduleEmailsForSending(emailsToBeSent);
            session.setSentClosingEmail(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 12 with EmailGenerator

use of teammates.logic.api.EmailGenerator in project teammates by TEAMMATES.

the class FeedbackSessionPublishedEmailWorkerAction method execute.

@Override
public void execute() {
    String feedbackSessionName = getRequestParamValue(ParamsNames.EMAIL_FEEDBACK);
    Assumption.assertPostParamNotNull(ParamsNames.EMAIL_FEEDBACK, feedbackSessionName);
    String courseId = getRequestParamValue(ParamsNames.EMAIL_COURSE);
    Assumption.assertPostParamNotNull(ParamsNames.EMAIL_COURSE, courseId);
    FeedbackSessionAttributes session = logic.getFeedbackSession(feedbackSessionName, courseId);
    if (session == null) {
        log.severe("Feedback session object for feedback session name: " + feedbackSessionName + " for course: " + courseId + " could not be fetched.");
        return;
    }
    List<EmailWrapper> emailsToBeSent = new EmailGenerator().generateFeedbackSessionPublishedEmails(session);
    try {
        taskQueuer.scheduleEmailsForSending(emailsToBeSent);
        session.setSentPublishedEmail(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 13 with EmailGenerator

use of teammates.logic.api.EmailGenerator in project teammates by TEAMMATES.

the class FeedbackSessionRemindEmailWorkerAction method execute.

@Override
public void execute() {
    String feedbackSessionName = getRequestParamValue(ParamsNames.SUBMISSION_FEEDBACK);
    Assumption.assertPostParamNotNull(ParamsNames.SUBMISSION_FEEDBACK, feedbackSessionName);
    String courseId = getRequestParamValue(ParamsNames.SUBMISSION_COURSE);
    Assumption.assertPostParamNotNull(ParamsNames.SUBMISSION_COURSE, courseId);
    String instructorId = getRequestParamValue(ParamsNames.USER_ID);
    Assumption.assertPostParamNotNull(ParamsNames.USER_ID, instructorId);
    try {
        FeedbackSessionAttributes session = logic.getFeedbackSession(feedbackSessionName, courseId);
        List<StudentAttributes> studentList = logic.getStudentsForCourse(courseId);
        List<InstructorAttributes> instructorList = logic.getInstructorsForCourse(courseId);
        InstructorAttributes instructorToNotify = logic.getInstructorForGoogleId(courseId, instructorId);
        List<StudentAttributes> studentsToRemindList = new ArrayList<>();
        for (StudentAttributes student : studentList) {
            if (!logic.isFeedbackSessionCompletedByStudent(session, student.email)) {
                studentsToRemindList.add(student);
            }
        }
        // Filter out instructors who have submitted the feedback session
        List<InstructorAttributes> instructorsToRemindList = new ArrayList<>();
        for (InstructorAttributes instructor : instructorList) {
            if (!logic.isFeedbackSessionCompletedByInstructor(session, instructor.email)) {
                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 14 with EmailGenerator

use of teammates.logic.api.EmailGenerator in project teammates by TEAMMATES.

the class FeedbackSessionUnpublishedEmailWorkerAction method execute.

@Override
public void execute() {
    String feedbackSessionName = getRequestParamValue(ParamsNames.EMAIL_FEEDBACK);
    Assumption.assertPostParamNotNull(ParamsNames.EMAIL_FEEDBACK, feedbackSessionName);
    String courseId = getRequestParamValue(ParamsNames.EMAIL_COURSE);
    Assumption.assertPostParamNotNull(ParamsNames.EMAIL_COURSE, courseId);
    FeedbackSessionAttributes session = logic.getFeedbackSession(feedbackSessionName, courseId);
    if (session == null) {
        log.severe("Feedback session object for feedback session name: " + feedbackSessionName + " for course: " + courseId + " could not be fetched.");
        return;
    }
    List<EmailWrapper> emailsToBeSent = new EmailGenerator().generateFeedbackSessionUnpublishedEmails(session);
    try {
        taskQueuer.scheduleEmailsForSending(emailsToBeSent);
        session.setSentPublishedEmail(false);
        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 15 with EmailGenerator

use of teammates.logic.api.EmailGenerator in project teammates by TEAMMATES.

the class EmailGeneratorTest method testGenerateStudentCourseJoinEmail.

@Test
public void testGenerateStudentCourseJoinEmail() throws IOException {
    ______TS("student course join email");
    CourseAttributes course = CourseAttributes.builder("idOfTypicalCourse1", "Course Name", ZoneId.of("UTC")).build();
    StudentAttributes student = StudentAttributes.builder("", "Student Name", "student@email.tmt").withKey("skxxxxxxxxxks").build();
    EmailWrapper email = new EmailGenerator().generateStudentCourseJoinEmail(course, student);
    String subject = String.format(EmailType.STUDENT_COURSE_JOIN.getSubject(), course.getName(), course.getId());
    verifyEmail(email, student.email, subject, "/studentCourseWithCoOwnersJoinEmail.html");
    ______TS("student course with co-owners join email after Google ID reset");
    email = new EmailGenerator().generateStudentCourseRejoinEmailAfterGoogleIdReset(course, student);
    subject = String.format(EmailType.STUDENT_COURSE_REJOIN_AFTER_GOOGLE_ID_RESET.getSubject(), course.getName(), course.getId());
    verifyEmail(email, student.email, subject, "/studentCourseWithCoOwnersRejoinAfterGoogleIdResetEmail.html");
    ______TS("student course (without co-owners) join email");
    course = CourseAttributes.builder("course-id", "Course Name", ZoneId.of("UTC")).build();
    email = new EmailGenerator().generateStudentCourseJoinEmail(course, student);
    subject = String.format(EmailType.STUDENT_COURSE_JOIN.getSubject(), course.getName(), course.getId());
    verifyEmail(email, student.email, subject, "/studentCourseWithoutCoOwnersJoinEmail.html");
    ______TS("student course (without-co-owners) join email after Google ID reset");
    email = new EmailGenerator().generateStudentCourseRejoinEmailAfterGoogleIdReset(course, student);
    subject = String.format(EmailType.STUDENT_COURSE_REJOIN_AFTER_GOOGLE_ID_RESET.getSubject(), course.getName(), course.getId());
    verifyEmail(email, student.email, subject, "/studentCourseWithoutCoOwnersRejoinAfterGoogleIdResetEmail.html");
}
Also used : EmailGenerator(teammates.logic.api.EmailGenerator) StudentAttributes(teammates.common.datatransfer.attributes.StudentAttributes) CourseAttributes(teammates.common.datatransfer.attributes.CourseAttributes) EmailWrapper(teammates.common.util.EmailWrapper) Test(org.testng.annotations.Test)

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