diff --git a/src/main/java/teammates/common/util/Templates.java b/src/main/java/teammates/common/util/Templates.java index 67b6d5c92b1..15da613606e 100644 --- a/src/main/java/teammates/common/util/Templates.java +++ b/src/main/java/teammates/common/util/Templates.java @@ -80,6 +80,10 @@ public static class EmailTemplates { FileHelper.readResourceFile("userEmailFragment-sessionAdditionalContactInformationFragment.html"); public static final String OWNER_FEEDBACK_SESSION_OPENING_SOON = FileHelper.readResourceFile("ownerEmailTemplate-sessionOpeningSoon.html"); + public static final String FRAGMENT_OPENING_SOON_EDIT_DETAILS = + FileHelper.readResourceFile("ownerEmailFragment-editDetails.html"); + public static final String FRAGMENT_OPENING_SOON_JOIN_COURSE_BEFORE_EDIT_DETAILS = + FileHelper.readResourceFile("ownerEmailFragment-joinCourseBeforeEditDetails.html"); } } diff --git a/src/main/java/teammates/logic/api/EmailGenerator.java b/src/main/java/teammates/logic/api/EmailGenerator.java index 9bae762860e..bd345be0aae 100644 --- a/src/main/java/teammates/logic/api/EmailGenerator.java +++ b/src/main/java/teammates/logic/api/EmailGenerator.java @@ -129,6 +129,16 @@ private EmailWrapper generateFeedbackSessionOpeningSoonEmailBase( CourseAttributes course, FeedbackSessionAttributes session, InstructorAttributes coOwner, EmailType type, String editUrl) { + String additionalNotes; + + // If instructor has not joined the course, populate additional notes with information to join course. + if (coOwner.isRegistered()) { + additionalNotes = fillUpEditFeedbackSessionDetailsFragment(editUrl); + } else { + additionalNotes = fillUpJoinCourseBeforeEditFeedbackSessionDetailsFragment(editUrl, + getInstructorCourseJoinUrl(coOwner)); + } + String emailBody = Templates.populateTemplate(EmailTemplates.OWNER_FEEDBACK_SESSION_OPENING_SOON, "${userName}", SanitizationHelper.sanitizeForHtml(coOwner.getName()), "${courseName}", SanitizationHelper.sanitizeForHtml(course.getName()), @@ -140,8 +150,7 @@ private EmailWrapper generateFeedbackSessionOpeningSoonEmailBase( "${sessionInstructions}", session.getInstructionsString(), "${startTime}", SanitizationHelper.sanitizeForHtml(TimeHelper.formatInstant( session.getStartTime(), session.getTimeZone(), DATETIME_DISPLAY_FORMAT)), - "${sessionEditUrl}", editUrl, - "${additionalNotes}", "", + "${additionalNotes}", additionalNotes, "${additionalContactInformation}", ""); EmailWrapper email = getEmptyEmailAddressedToEmail(coOwner.getEmail()); @@ -151,6 +160,25 @@ private EmailWrapper generateFeedbackSessionOpeningSoonEmailBase( return email; } + /** + * Generates the fragment for instructions on how to edit details for feedback session at {@code editUrl}. + */ + private String fillUpEditFeedbackSessionDetailsFragment(String editUrl) { + return Templates.populateTemplate(EmailTemplates.FRAGMENT_OPENING_SOON_EDIT_DETAILS, + "${sessionEditUrl}", editUrl); + } + + /** + * Generates the fragment for instructions on how to edit details for feedback session at {@code editUrl} and + * how to join the course at {@code joinUrl}. + */ + private String fillUpJoinCourseBeforeEditFeedbackSessionDetailsFragment(String editUrl, String joinUrl) { + return Templates.populateTemplate(EmailTemplates.FRAGMENT_OPENING_SOON_JOIN_COURSE_BEFORE_EDIT_DETAILS, + "${sessionEditUrl}", editUrl, + "${joinUrl}", joinUrl + ); + } + /** * Generates the feedback session reminder emails for the given {@code session} for {@code students} * and {@code instructorsToRemind}. In addition, the emails will also be forwarded to {@code instructorsToNotify}. @@ -487,11 +515,9 @@ private EmailWrapper generateFeedbackSessionEmailBaseForInstructorReminders( } private String generateInstructorJoinReminderFragment(InstructorAttributes instructor) { - String joinUrl = Config.getFrontEndAppUrl(instructor.getRegistrationUrl()).toAbsoluteString(); - return Templates.populateTemplate(EmailTemplates.FRAGMENT_INSTRUCTOR_COURSE_JOIN_REMINDER, "${feedbackAction}", FEEDBACK_ACTION_SUBMIT_EDIT_OR_VIEW, - "${joinUrl}", joinUrl); + "${joinUrl}", getInstructorCourseJoinUrl(instructor)); } /** @@ -878,12 +904,14 @@ private String fillUpStudentRejoinAfterGoogleIdResetFragment(StudentAttributes s "${supportEmail}", Config.SUPPORT_EMAIL); } - private String fillUpInstructorJoinFragment(InstructorAttributes instructor) { - String joinUrl = Config.getFrontEndAppUrl(instructor.getRegistrationUrl()).toAbsoluteString(); + private String getInstructorCourseJoinUrl(InstructorAttributes instructor) { + return Config.getFrontEndAppUrl(instructor.getRegistrationUrl()).toAbsoluteString(); + } + private String fillUpInstructorJoinFragment(InstructorAttributes instructor) { return Templates.populateTemplate(EmailTemplates.USER_COURSE_JOIN, "${joinFragment}", EmailTemplates.FRAGMENT_INSTRUCTOR_COURSE_JOIN, - "${joinUrl}", joinUrl); + "${joinUrl}", getInstructorCourseJoinUrl(instructor)); } private String fillUpInstructorRejoinAfterGoogleIdResetFragment(InstructorAttributes instructor) { diff --git a/src/main/resources/ownerEmailFragment-editDetails.html b/src/main/resources/ownerEmailFragment-editDetails.html new file mode 100644 index 00000000000..582f3e40637 --- /dev/null +++ b/src/main/resources/ownerEmailFragment-editDetails.html @@ -0,0 +1,10 @@ +

+

+

diff --git a/src/main/resources/ownerEmailFragment-joinCourseBeforeEditDetails.html b/src/main/resources/ownerEmailFragment-joinCourseBeforeEditDetails.html new file mode 100644 index 00000000000..9d1c91c6303 --- /dev/null +++ b/src/main/resources/ownerEmailFragment-joinCourseBeforeEditDetails.html @@ -0,0 +1,19 @@ +

+ To "join" the course, please go to this Web address: + ${joinUrl} +

+

+ After joining the course, you can edit details of the above session at ${sessionEditUrl}. +

+

diff --git a/src/main/resources/ownerEmailTemplate-sessionOpeningSoon.html b/src/main/resources/ownerEmailTemplate-sessionOpeningSoon.html index 2261d10fe44..8621ee2fdf7 100644 --- a/src/main/resources/ownerEmailTemplate-sessionOpeningSoon.html +++ b/src/main/resources/ownerEmailTemplate-sessionOpeningSoon.html @@ -62,18 +62,10 @@ -

-

-

+ +${additionalNotes}

Regards,
TEAMMATES Team. -

\ No newline at end of file +

diff --git a/src/test/java/teammates/logic/api/EmailGeneratorTest.java b/src/test/java/teammates/logic/api/EmailGeneratorTest.java index c8e0a5ad262..2d536e4df55 100644 --- a/src/test/java/teammates/logic/api/EmailGeneratorTest.java +++ b/src/test/java/teammates/logic/api/EmailGeneratorTest.java @@ -216,14 +216,23 @@ public void testGenerateFeedbackSessionEmails() throws Exception { subject = String.format(EmailType.FEEDBACK_OPENING_SOON.getSubject(), course.getName(), session.getFeedbackSessionName()); - // this instructor email has been given co-owner privileges in the test file - InstructorAttributes coOwner1 = + // this instructor email has been given co-owner privileges in the test file but has not joined + InstructorAttributes coOwnerNotJoined = instructorsLogic.getInstructorForEmail(course.getId(), "instructorNotYetJoinedCourse1@email.tmt"); - assertTrue(coOwner1.hasCoownerPrivileges()); + assertTrue(coOwnerNotJoined.hasCoownerPrivileges()); - verifyEmailReceivedCorrectly(emails, coOwner1.getEmail(), subject, - "/sessionOpeningSoonEmailForCoOwner.html"); + verifyEmailReceivedCorrectly(emails, coOwnerNotJoined.getEmail(), subject, + "/sessionOpeningSoonEmailForCoOwnerNotJoined.html"); + + // this instructor email has been given co-owner privileges in the test file and has joined + InstructorAttributes coOwnerJoined = + instructorsLogic.getInstructorForEmail(course.getId(), "instructor1@course1.tmt"); + + assertTrue(coOwnerJoined.hasCoownerPrivileges()); + + verifyEmailReceivedCorrectly(emails, coOwnerJoined.getEmail(), subject, + "/sessionOpeningSoonEmailForCoOwnerJoined.html"); ______TS("feedback session published alerts"); diff --git a/src/test/resources/emails/sessionOpeningSoonEmailForCoOwner.html b/src/test/resources/emails/sessionOpeningSoonEmailForCoOwnerJoined.html similarity index 97% rename from src/test/resources/emails/sessionOpeningSoonEmailForCoOwner.html rename to src/test/resources/emails/sessionOpeningSoonEmailForCoOwnerJoined.html index 7d9b788b22a..11fce98f85d 100644 --- a/src/test/resources/emails/sessionOpeningSoonEmailForCoOwner.html +++ b/src/test/resources/emails/sessionOpeningSoonEmailForCoOwnerJoined.html @@ -1,4 +1,4 @@ -

Hello Instructor Not Yet Joined Course 1,

+

Hello Instructor1 Course1,

@@ -62,6 +62,7 @@ +