Skip to content
Snippets Groups Projects
Commit d0fda071 authored by srosse's avatar srosse
Browse files

OO-4730: check if there is a grader to inform before sending an email

parent a18f3f28
No related branches found
No related tags found
No related merge requests found
...@@ -258,10 +258,12 @@ public class GradingServiceImpl implements GradingService, UserDataDeletable, Re ...@@ -258,10 +258,12 @@ public class GradingServiceImpl implements GradingService, UserDataDeletable, Re
private boolean doSendEmails(MailContext context, List<GraderToIdentity> graders, MailTemplate template, MailerResult result) { private boolean doSendEmails(MailContext context, List<GraderToIdentity> graders, MailTemplate template, MailerResult result) {
for(GraderToIdentity grader:graders) { for(GraderToIdentity grader:graders) {
Identity recipient = grader.getIdentity(); if(grader != null && grader.getIdentity() != null) {
MailBundle bundle = mailManager.makeMailBundle(context, recipient, template, null, null, result); Identity recipient = grader.getIdentity();
MailerResult sendResult = mailManager.sendMessage(bundle); MailBundle bundle = mailManager.makeMailBundle(context, recipient, template, null, null, result);
result.append(sendResult); MailerResult sendResult = mailManager.sendMessage(bundle);
result.append(sendResult);
}
} }
return result.isSuccessful(); return result.isSuccessful();
} }
...@@ -719,6 +721,7 @@ public class GradingServiceImpl implements GradingService, UserDataDeletable, Re ...@@ -719,6 +721,7 @@ public class GradingServiceImpl implements GradingService, UserDataDeletable, Re
public void sendGraderAsssignmentNotification(GraderToIdentity grader, RepositoryEntry referenceEntry, public void sendGraderAsssignmentNotification(GraderToIdentity grader, RepositoryEntry referenceEntry,
GradingAssignment assignment, RepositoryEntryGradingConfiguration config) { GradingAssignment assignment, RepositoryEntryGradingConfiguration config) {
if(grader == null) return; // nothing to do
GraderMailTemplate mailTemplate = new GraderMailTemplate(config.getNotificationSubject(), config.getNotificationBody()); GraderMailTemplate mailTemplate = new GraderMailTemplate(config.getNotificationSubject(), config.getNotificationBody());
decorateGraderMailTemplate(referenceEntry, mailTemplate); decorateGraderMailTemplate(referenceEntry, mailTemplate);
...@@ -797,7 +800,9 @@ public class GradingServiceImpl implements GradingService, UserDataDeletable, Re ...@@ -797,7 +800,9 @@ public class GradingServiceImpl implements GradingService, UserDataDeletable, Re
dbInstance.commit(); dbInstance.commit();
if(config != null && config.getNotificationTypeEnum() == GradingNotificationType.afterTestSubmission) { if(config != null && config.getNotificationTypeEnum() == GradingNotificationType.afterTestSubmission) {
sendGraderAsssignmentNotification(choosedGrader, referenceEntry, assignment, config); if(choosedGrader != null) {
sendGraderAsssignmentNotification(choosedGrader, referenceEntry, assignment, config);
}
assignment.setAssignmentNotificationDate(new Date()); assignment.setAssignmentNotificationDate(new Date());
gradingAssignmentDao.updateAssignment(assignment); gradingAssignmentDao.updateAssignment(assignment);
dbInstance.commit(); dbInstance.commit();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment