Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: script and message templates for duplicate outcomes de… OD-17533 #914

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions server/src/main/resources/messages/catalog.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -659,4 +659,15 @@
dataType: TEXT
value: ish.email.footer

- name: Duplicate outcomes notification
type: email
keyCode: ish.email.duplicateOutcomesNotification
txtTemplate: ish.email.duplicateOutcomesNotification.txt
htmlTemplate: ish.email.duplicateOutcomesNotification.html
subject: Student enrolled in an already completed outcome
entityClass: Enrolment
description: A warning email to admin letting them know that someone is enrolled in an outcome they’ve already completed
tags:
options:


Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<!--
~ Copyright ish group pty ltd 2022.
~
~ This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License version 3 as published by the Free Software Foundation.
~
~ This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details.
-->

<tr>
<td align="center" class="bg-color content-padding" valign="top" width="100%">
<center>
<table cellpadding="0" cellspacing="0" class="w320" width="600">
<tr>
<td class="mini-block-container">
<table cellpadding="0" cellspacing="0" class="table-border-separate" width="100%">
<tr>
<td class="mini-block pull-left" valign="top">
Hi<br><br>

${record.student.contact.fullName} has just enrolled for course ${record.courseClass.course.name} ${record.courseClass.uniqueCode}, but they have already been enrolled in and not completed the following modules:<br><br>

Outcomes - outcome name, outcome national code, courseClass Code:<br><br>
<% outcomes.each { it -> %>
${it.module.title} ${it.module.nationalCode} ${it.enrolment.courseClass.code} <br>
<% } %>

<br><br><br><br>This is an automated notification from onCourse
</td>
</tr>
</table>
</td>
</tr>
</table>
</center>
</td>
</tr>
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
Hi

${record.student.contact.fullName} has just enrolled for course ${record.courseClass.course.name} ${record.courseClass.uniqueCode}, but they have already been enrolled in and not completed the following modules:

Outcomes - outcome name, outcome national code, courseClass Code:

<% outcomes.each { it -> %>
${it.module.title} ${it.module.nationalCode} ${it.enrolment.courseClass.code}
<% } %>


This is an automated notification from onCourse
15 changes: 14 additions & 1 deletion server/src/main/resources/scripts/catalog.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -905,4 +905,17 @@
options:
- name: scheduleNameValue
value: "Ish Schedule"
dataType: TEXT
dataType: TEXT

- name: Send duplicate outcome notification
keyCode: ish.script.sendDuplicateOutcomeNotification
body: ish.script.sendDuplicateOutcomeNotification.groovy
status: NOT_INSTALLED
triggerType: ENTITY_EVENT
entityClass: Enrolment
entityEventType: CREATE
description: We should let people enrol but send a warning email to admin letting them know that someone is enrolled in an outcome they’ve already completed
short: Send a warning email to admin letting them know that someone is enrolled in an outcome they’ve already completed
category: Notifications
tag:
options:
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import ish.common.types.EnrolmentStatus
import ish.oncourse.server.cayenne.Enrolment
import ish.oncourse.server.cayenne.Outcome


def enrolment = record as Enrolment
def enrolmentModules = enrolment.outcomes*.module.findAll{it}
def studentOutcomes = enrolment.student.enrolments.findAll { it.id != enrolment.id && it.status != EnrolmentStatus.CANCELLED}.outcomes.flatten() as List<Outcome>
def alreadyEnrolledOutcomes = studentOutcomes.findAll {enrolmentModules.contains(it.module)}.findAll{it}
if(!alreadyEnrolledOutcomes.isEmpty()){
message {
template "ish.email.duplicateOutcomesNotification"
to preference.email.admin
record enrolment
outcomes alreadyEnrolledOutcomes
}
}