Skip to content

Commit

Permalink
[#11756] Session closing email contains no information about extended…
Browse files Browse the repository at this point in the history
… deadline (#11758)
  • Loading branch information
samuelfangjw authored Apr 24, 2022
1 parent cd420d8 commit 1a37718
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 12 deletions.
26 changes: 20 additions & 6 deletions src/main/java/teammates/logic/api/EmailGenerator.java
Original file line number Diff line number Diff line change
Expand Up @@ -521,8 +521,20 @@ public List<EmailWrapper> generateFeedbackSessionClosingWithExtensionEmails(
}

String template = EmailTemplates.USER_FEEDBACK_SESSION.replace("${status}", FEEDBACK_STATUS_SESSION_CLOSING);
return generateFeedbackSessionEmailBases(course, session, students, instructors, Collections.emptyList(), template,
EmailType.FEEDBACK_CLOSING, FEEDBACK_ACTION_SUBMIT_EDIT_OR_VIEW);
EmailType type = EmailType.FEEDBACK_CLOSING;
String feedbackAction = FEEDBACK_ACTION_SUBMIT_EDIT_OR_VIEW;
List<EmailWrapper> emails = new ArrayList<>();
for (StudentAttributes student : students) {
FeedbackSessionAttributes studentSession = session.getCopyForStudent(student.getEmail());
emails.addAll(generateFeedbackSessionEmailBases(course, studentSession, Collections.singletonList(student),
Collections.emptyList(), Collections.emptyList(), template, type, feedbackAction));
}
for (InstructorAttributes instructor : instructors) {
FeedbackSessionAttributes instructorSession = session.getCopyForInstructor(instructor.getEmail());
emails.addAll(generateFeedbackSessionEmailBases(course, instructorSession, Collections.emptyList(),
Collections.singletonList(instructor), Collections.emptyList(), template, type, feedbackAction));
}
return emails;
}

/**
Expand Down Expand Up @@ -722,14 +734,15 @@ private EmailWrapper generateFeedbackSessionEmailBaseForStudents(
.toAbsoluteString();

Instant endTime = TimeHelper.getMidnightAdjustedInstantBasedOnZone(
session.getEndTime(), session.getTimeZone(), false);
session.getDeadline(), session.getTimeZone(), false);
String emailBody = Templates.populateTemplate(template,
"${userName}", SanitizationHelper.sanitizeForHtml(student.getName()),
"${courseName}", SanitizationHelper.sanitizeForHtml(course.getName()),
"${courseId}", SanitizationHelper.sanitizeForHtml(course.getId()),
"${feedbackSessionName}", SanitizationHelper.sanitizeForHtml(session.getFeedbackSessionName()),
"${deadline}", SanitizationHelper.sanitizeForHtml(
TimeHelper.formatInstant(endTime, session.getTimeZone(), DATETIME_DISPLAY_FORMAT)),
TimeHelper.formatInstant(endTime, session.getTimeZone(), DATETIME_DISPLAY_FORMAT))
+ (session.getUserEmail() == null ? "" : " (after extension)"),
"${instructorPreamble}", "",
"${sessionInstructions}", session.getInstructionsString(),
"${submitUrl}", submitUrl,
Expand Down Expand Up @@ -762,14 +775,15 @@ private EmailWrapper generateFeedbackSessionEmailBaseForInstructors(
.toAbsoluteString();

Instant endTime = TimeHelper.getMidnightAdjustedInstantBasedOnZone(
session.getEndTime(), session.getTimeZone(), false);
session.getDeadline(), session.getTimeZone(), false);
String emailBody = Templates.populateTemplate(template,
"${userName}", SanitizationHelper.sanitizeForHtml(instructor.getName()),
"${courseName}", SanitizationHelper.sanitizeForHtml(course.getName()),
"${courseId}", SanitizationHelper.sanitizeForHtml(course.getId()),
"${feedbackSessionName}", SanitizationHelper.sanitizeForHtml(session.getFeedbackSessionName()),
"${deadline}", SanitizationHelper.sanitizeForHtml(
TimeHelper.formatInstant(endTime, session.getTimeZone(), DATETIME_DISPLAY_FORMAT)),
TimeHelper.formatInstant(endTime, session.getTimeZone(), DATETIME_DISPLAY_FORMAT))
+ (session.getUserEmail() == null ? "" : " (after extension)"),
"${instructorPreamble}", "",
"${sessionInstructions}", session.getInstructionsString(),
"${submitUrl}", submitUrl,
Expand Down
8 changes: 4 additions & 4 deletions src/test/resources/data/EmailGeneratorTest.json
Original file line number Diff line number Diff line change
Expand Up @@ -424,8 +424,8 @@
"student5InCourse1@gmail.tmt": "2027-04-30T23:00:00Z"
},
"instructorDeadlines": {
"instructor2@course1.tmt": "2027-04-30T23:00:00Z",
"instructor3@course1.tmt": "2027-04-30T23:00:00Z"
"instructor2@course1.tmt": "2027-05-01T22:00:00Z",
"instructor3@course1.tmt": "2027-05-01T22:00:00Z"
}
},
"session2InCourse1": {
Expand Down Expand Up @@ -1220,7 +1220,7 @@
"feedbackSessionName": "First feedback session",
"userEmail": "instructor2@course1.tmt",
"isInstructor": true,
"endTime": "2027-04-30T23:00:00Z",
"endTime": "2027-05-01T22:00:00Z",
"sentClosingEmail": false,
"sentClosedEmail": false,
"createdAt": "2027-04-30T15:00:00Z",
Expand All @@ -1231,7 +1231,7 @@
"feedbackSessionName": "First feedback session",
"userEmail": "instructor3@course1.tmt",
"isInstructor": true,
"endTime": "2027-04-30T23:00:00Z",
"endTime": "2027-05-01T22:00:00Z",
"sentClosingEmail": false,
"sentClosedEmail": false,
"createdAt": "2027-04-30T15:00:00Z",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
</strong>
</td>
<td style="padding:5px;">
Fri, 30 Apr 2027, 11:59 PM SAST
Sat, 01 May 2027, 11:59 PM SAST (after extension)
</td>
</tr>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
</strong>
</td>
<td style="padding:5px;">
Fri, 30 Apr 2027, 11:59 PM SAST
Sat, 01 May 2027, 01:00 AM SAST (after extension)
</td>
</tr>

Expand Down

0 comments on commit 1a37718

Please sign in to comment.