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 @@ +
+
+ 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}. +
-
Regards,
TEAMMATES Team.
-
Hello Instructor Not Yet Joined Course 1,
+Hello Instructor1 Course1,
@@ -62,6 +62,7 @@ +
Regards,
TEAMMATES Team.
-
Hello Instructor Not Yet Joined Course 1,
+ + + ++ Heads up! The following feedback session is due to open soon. +
+ + Course: + + | ++ [idOfTypicalCourse1] Typical Course 1 with 2 Evals + | +
+ + Feedback Session Name: + + | ++ First feedback session + | +
+ + Session Start Time: + + | ++ Sun, 01 Apr 2012, 11:59 PM SAST + | +
+ + Deadline: + + | ++ Fri, 30 Apr 2027, 11:59 PM SAST + | +
+ + Session Instructions: + + | ++ Please please fill in the following questions. + | +
+ To "join" the course, please go to this Web address: + http://localhost:4200/web/join?key=${regkey.enc}&entitytype=instructor +
++ After joining the course, you can edit details of the above session at http://localhost:4200/web/instructor/sessions/edit?courseid=idOfTypicalCourse1&fsname=First%20feedback%20session. +
+ Regards,
+
TEAMMATES Team.
+