Script blocks and other
AlchemerScriptClosure
This integration allows you to push records into Alchemer in order to add them to a survey. Create one integration
per survey you want to send and then use this scripting block:
alchemer {
contact myContact
template myTemplate
reply "[email protected]"
}
Use the name option if you have more than one Alchemer integration and you want to push to only one.
alchemer {
name "name of integration"
contact myContact
template myTemplate
reply "[email protected]"
}
AzureStorageScriptClosure
Use this script block to easily send documents into the Azure Storage Blob service. Note that this has nothing to do with the onCourse document storage system and simply stores the blob in the Azure service without tracking it.
def transactions = query {
entity "AccountTransaction"
query "createdOn is today"
}
def bytes = export {
template "ish.onCourse.accountTransactionMYOB.csv"
records transactions
}
azurestorage {
name "integration name"
blob bytes
fileName "transactions.csv"
}
If you pass the DocumentParam object as the blob attribute, you can skip the name.
azurestorage {
name "integration name"
blob fileData
}
CanvasExpireScriptClosure
This automation component will iterate through all currently unsuspended users in Canvas and match their
enrolments to enrolments in onCourse.Suspend the Canvas user if all their enrolments have completed.
canvas_expire { }
By default the enrolment will be deemed to have ended when the class is complete. If you want to specify a
different end date you can do that with a simple expression like this:
canvas_expire {
ends "enrolment.customFieldEndDate"
}
Or with an expression like this:
canvas_expire {
ends "enrolment.courseClass.endDateTime + 10"
}
CanvasScriptClosure
This integration allows you to link onCourse to the Canvas LMS.
Add enrolments to Enrolments automatically as they are enrolled in onCourse.
canvas {
enrolment e
course_code "My-Canvas-Course"
section_code "key." + e.courseClass.uniqueCode
create_section true
create_student true
}
You can specify:
- create_section: create a new Canvas section from the equivalent onCourse Class if one does not already exist
inside your Canvas instance. - create_student: create a new Canvas User profile for the enrolled student if one does not exist in your Canvas
instance. If this is false and the user does not exist in Canvas then nothing will happen.
Additional options are available:
canvas {
enrolment e
course_code "My-Canvas-Course"
section_code "key." + e.courseClass.uniqueCode
create_section true
create_student true
authentication_provider_id 1
create_password "myCustomField"
course_blueprint "ABC"
add_tutors true
}
- authentication_provider_id: this sets the auth provider in Canvas to a non standard value
- create_password: will generate random password for studento canvas and save to your nominated customField of the
onCourse student. Be aware this is not secure since the password is not encrypted in onCourse, however it can be
useful for supporting students who need help logging in, or if you want to send the student their login details
from inside onCourse. - course_blueprint: if the course does not already exist in Canvas with the code provided, will create a new course
from the blueprint specified. - add_tutors: will enrol tutors from the enrolment's class into the Canvas course as teachers.
Additional data can be sent to Canvas like this:
def student = [
user: [
name: "David Smith",
time_zone: "Hawaii"
],
communication_channel: [
skip_confirmation: true
],
enable_sis_reactivation: true
]
canvas {
enrolment e
course_code "My-Canvas-Course"
section_code "key." + e.courseClass.uniqueCode
create_section true
create_student true
student_attributes student
}
Consult the Cnavas manual for the fields you can send through to Canvas and how to use them. You can set any student/user attributes in Canvas.
CoassembleScriptClosure
Integration allows us to establish interaction between Coassemble (previously called E-coach) and onCourse enrol system.
Add enrolments to Enrolments automatically as they are enrolled in onCourse.
ecoach {
enrolment record
}
Use the name option if you have more than one coassemble integration and you want to push to only one.
ecoach {
name "name of integration"
enrolment record
}
CollegePreferenceService
Service for accessing college preferences.
get(prefName, defaultValue)
-
prefName: String name of preference @param defaultValue default value @return preference value if it is not null, otherwise returns default value
-
defaultValue: Object default value @return preference value if it is not null, otherwise returns default value
-
Returns: Object preference value if it is not null, otherwise returns default value
get(prefName)
-
prefName: String name of preference @return preference value if it is not null, otherwise returns empty string.
-
Returns: Object preference value if it is not null, otherwise returns empty string.
hasSurveyForm()
Check if default survey form foor enrolled students configured for ncourse.
See ish.email.enrolmentConfirmation email template
- Returns: boolean Documentation not yet available
CsvBuilder
This class is a simple wrapper to make exporting CSV and other formats really easy.
Use it like this within an export script:
csv << [
"first name": contact.firstName
"last name": contact.lastName
"student number": contact.student.studentNumber
]
If you want to change the delimiters, quote or end of line, you should do that before you call csv << []
Note that this builder is really flexible and isn't just for CSV. Use it for any output with consistent
separators between fields.
addRow(row)
Appends new row to builder's output. Instead of calling this method by name,
you can use the symbol "<<" as seen in the example above.
If you call this more than once, the header is automatically disabled for the second
and subsequent calls.
- row: Map mapping of column names to values
enableHeader(writeHeader)
Use this to disable the header line
csv.enableHeader = false
- writeHeader: boolean defaults to true @return
setDelimiter(delimiter)
Set the delimiter to something else.
csv.delimiter = ';'
- delimiter: int defaults to ,
setEndOfLine(endOfLine)
Set the end of line to something else.
csv.endOfLine = '\n'
- endOfLine: String defaults to a \r\n
setQuote(quote)
Set the quote to something else.
csv.quote = '|'
- quote: char defaults to a "
DocumentService
This class contains simple image closure which allow to put any images from document management system to email template.
The syntax is
${image 'picture_1'}.
'picture_1' is name of document in onCourse system.
If onCourse have more than one document with the same name then the first one will be chosen.
Make sure that required image has unique name to prevent such collision.
The image closure interpreted into simple img html tag like:
Document script block
Document creation API.
Simple usage example:
output = report {
records someList
keyCode ish.classReport
background myFile
}
d = document {
action "create"
content output
name "myreport"
mimeType "image/pdf"
permission AttachmentInfoVisibility.PUBLIC
attach tutor_1, tutor_1
}
Or just attach existing document to any attachable records
document {
action "attach"
document d
attach tutor_1, enrolment_1, certificate_1
}
action(action)
Create new document or attach existing document
- action: String list action string
attach(attach)
- attach: AttachableTrait existing records to attach a document
content(content)
- content: byte[] for newly created document
content(documentParam)
- documentParam: DocumentParam Documentation not yet available
document(document)
- document: Document existing document record to attach
mimeType(mimeType)
- mimeType: String for newly created document
name(name)
- name: String for newly created document
permission(permission)
- permission: AttachmentInfoVisibility for newly created document
Export script block
Use a script to generate an export.
Usage example:
export {
fileName "export.csv"
template "ish.contact.list"
record overdueDebtors
}
fileName(fileName)
Specify the filename with extension of the final file with a fulfilled export
- fileName: String fileName of the file with the export
record(records)
A list of records to export.
This is the same as 'records', but this needs to handling a export card which is added in Script API
-
records: List
-
Returns: def Documentation not yet available
record(record)
You can also pass one record to export.
-
record: Object
-
Returns: def Documentation not yet available
records(records)
A list of records to export. Obviously the export template needs to be
built to accept a list of this type of object and produce an export file from them.
-
records: List
-
Returns: def Documentation not yet available
records(records)
You can instead pass records as vargs if you only have a few to pass.
-
records: Object
-
Returns: def Documentation not yet available
template(templateKeyCode)
Pass the keycode of the export template you want to use
-
templateKeyCode: String Documentation not yet available
-
Returns: def Documentation not yet available
KronosCreateEditScriptClosure
Add TutorAttendances to Kronos Shift automatically as it is created/edited in onCourse.
Fields mapping from onCourse to Kronos:
Schedule name >> "Ish Schedules"
Date >> session date
Start Time >> session tutor rostered start time
End Time >> session tutor rostered end time
Employee ID >> tutor.payrollRef
Cost Center 0 >> First 3 digits of courseClass.incomeAccount
Cost Center 2 >> courseClassTutor.definedTutorRole.description
Skill >> courseClassTutor.definedTutorRole.name
Shift Note >> courseClasscode
kronosCreateEdit {
scheduleName "Weekly Test Schedule"
session record
}
scheduleName: add Shifts to Kronos Schedules with name 'scheduleName'. Kronos should have a Schedule with this name
and period on the date from the TutorAttendance
KronosDeleteScriptClosure
Delete TutorAttendances as Shift from Kronos automatically as it is deleted in onCourse.
kronosDelete {
session record
}
Get Schedule Id and Shift Id from TutorAttendance custom fields then call DELETE request with these ids,
that delete Shift from Kronos
KronosDeleteWrongCustomFieldClosure
Delete TutorAttendance Custom Fields for deleted Kronos Schedules.
kronosDeleteWrongCustomFields {
}
Get all TutorAttendances with CustomFields 'shiftIdCustomField' and 'scheduleIdCustomField' then check if one of its is null
or do a GET request to understand if Schedule is exist.
LearnDashScriptClosure
Export successful enrolment record to LearnDash system. This action will search for students matching the onCourse
email address against the LearnDash username, and creates them if not found.
That student will be enrolled in the Learndash course with slug matching the course code in onCourse
learndash {
action "enrol"
course enrolment.courseClass.course.code
student enrolment.student
}
MailchimpScriptClosure
Mailchimp integration groovy script API. Allows to subscribe/unsubscribe contact to/from Mailchimp list.
You can use 'subscribe' action for updating contacts in MailChimp.
'Unsubscribe' deletes permanently contact from the list.
Usage examples:
Subscribe person to Mailchimp list using onCourse contact record:
mailchimp {
name "List1"
action "subscribe"
contact enrolment.student.contact
}
Name property here is the name of Mailchimp integration which should be created in onCourse beforehand.
If the name isn't specified, script will execute it for all created 'MailChimp' integrations.
Subscribe person without onCourse contact record to Mailchimp list:
mailchimp {
name "List2"
action "subscribe"
email "[email protected]"
firstName "John"
lastName "Doe"
optIn false
}
Unsubscribe person from Mailchimp list:
mailchimp {
name "List1"
action "unsubscribe"
email "[email protected]"
}
The ability to create Mailchimp tags:
mailchimp {
action "subscribe"
contact enrolment.student.contact
tags enrolment.student.contact.tags
}
or any list of string
mailchimp {
action "subscribe"
contact enrolment.student.contact
tags 'art', 'IT', 'prhotoshop'
}
Pull unsubscribers and mark the email address in onCourse as not allowed for marketing. Since param support both: LocalDate or string literal.
mailchimp {
action "pull unsubscribes"
since "2020-09-04"
}
Don't pass 'since' param to get all unsubscribes
mailchimp {
action "pull unsubscribes"
}
Delete a user permanently from MailChimp by email, after this the user can be added again
mailchimp {
action "delete permanently"
email "[email protected]"
}
action(action)
Set Mailchimp list action: "subscribe" or "unsubscribe" or "pull unsubscribes".
- action: String list action string, can be one of "subscribe" or "unsubscribe" or "pull unsubscribes"
contact(contact)
Specify contact to take subscriber's email, first and last name from.
- contact: Contact subscriber contact
email(email)
Set subscriber's email.
- email: String subscriber's email
firstName(firstName)
Set subscriber's first name.
- firstName: String first name of the subscriber
lastName(lastName)
Set subscriber's last name.
- lastName: String last name of the subscriber
optIn(optIn)
A flag used to specify if a user must confirm via email before they are subscribed to a mailing list
'true' as default
- optIn: boolean for confirm email
since(since)
Pull all unsubscribers since certain timestamp
- since: String date time
since(since)
Pull all unsubscribers since certain timestamp
- since: LocalDate date time
tags(tags)
The ability to create Mailchimp tags. You can pass any list of tags to the integration.
If you want to map those in some way first, you can do that in the script you write.
- tags: List of Tag list
tags(tags)
The ability to create Mailchimp tags. You can pass any list of strings to the integration.
If you want to map those in some way first, you can do that in the script you write.
- tags: String list
Mask
For each access key, a role may be given certain access levels. This class is not an enum because
the values here can be added up to give layers of access. For example, VIEW (1) + EDIT (5) = 6.
Message script block
Message sending API. Allows to create email or SMS.
You can render email content from the templates which are stored into onCourse or a text string.
The recipients are generated from entity records which are specified in closure.
But you also can specify emails which will receive message with attachment or custom content.
If there is no attachment and specify template identifier and entity records, the message is stored inside the onCourse database.
Otherwise, no.
Simple usage example:
message {
template keyCodeOfMessageTemplate
record records
from "[email protected]"
}
The above example will render the template with the specified keyCode and will pass the entity records to that template.
It will send that message to the contacts which will be get from the records.
You can optionally also pass a from address if you don't want to use the default email.from preference.
message {
template keyCodeOfMessageTemplate
record records
anyBinding_1 anyValue_1
anyBinding_2 anyValue_2
}
If the template has a variables they must be specified as a list of variables.
You can send emails with an attached file or pass your own content of message, without storing this data inside onCourse.
Usage example:
erolments = query {
entity "Enrolment"
query "status is SUCCESS "
}
def enrolments_pdf = report {
keycode "ish.onCourse.enrolmentConfirmation"
records erolments
}
def enrolments_csv = export {
template "ish.onCourse.enrolment.csv"
records erolments
}
def enrolments_xml = export {
template "ish.onCourse.enrolment.xml"
records erolments
}
def enrolments_file = new File("enrolments.txt")
erolments.each { e->
enrolments_file.append(e.student.fullName +'_'+ e.courseClass.uniqueCode +'\n')
}
message {
to "[email protected]"
cc "[email protected]"
bcc "[email protected]"
from "support@@example.com", "onCourse Support"
subject "Attachment example"
content "Look at attached files"
attachment "enrolments.pdf", "application/pdf", enrolments_pdf
attachment "enrolments.csv", "text/csv", enrolments_csv
attachment "enrolments.xml", "text/xml", enrolments_xml
attachment "text/plain", enrolments_file
}
message {
from "[email protected]"
to "[email protected]"
cc "[email protected]"
bcc "[email protected]"
subject "test email"
content "test email content"
attachment "accounts.csv", "text/csv", account_csv_data
}
The only lines which are required are "to", "subject" and "content" or "record", "template" and "bindings"
Message collision functionality. Allows to skip sending messages automatically if contact have already received message with specified key.
Usage example:
message {
template keyCodeOfMessageTemplate
record records
key "ABC", records
keyCollision "drop"
}
attachment(documentParam)
Add a documentParam as attachment to the email.
Using this method means that the message is not stored inside onCourse.
- documentParam: DocumentParam as DocumentParam
attachment(file)
Add a file as attachment to the email.
Using this method means that the message is not stored inside onCourse.
- file: File as File
attachment(contentType, content)
Add attachment to the email.
Using this method means that the message is not stored inside onCourse.
- contentType: String MIME type of the attachment @param content MIME type of the attachment
- content: Object Documentation not yet available
attachment(fileName, contentType, content)
Add attachment to the email.
Using this method means that the message is not stored inside onCourse.
- fileName: String attached file name which will appear in the email @param contentType MIME type of the attachment @param content attachment object
- contentType: String MIME type of the attachment @param content attachment object
- content: Object Documentation not yet available
attachment(attachment)
Add attachment to the email.
Using this method means that the message is not stored inside onCourse.
- attachment: Map of String, Object attachment properties map, e.g. [fileName: 'example.txt', type: 'text/plain', content: 'test text']
bcc(recipients)
Set BCC recipients emails for the message.
Using this method means that the message is not stored inside onCourse.
- recipients: String email address of the BCC recipients
cc(recipients)
Set CC recipients emails for the message.
Using this method means that the message is not stored inside onCourse.
- recipients: String email addresses of the CC recipients
content(content)
Set plain text content of the email.
Could be used only for SMTP email sending
Using this method means that the message is not stored inside onCourse.
- content: String plain text content of the email
createdBy(user)
Specify SystemUser who will be the linked to the resulting Message record in onCourse as its creator.
- user: SystemUser user who created the email
from(email)
Set "from" address for the email. Defaults to "email.from" preference if not set.
- email: String email from address
from(email, name)
Set "from" address for the email and name of the sender.
- email: String email from address @param name name of the sender
- name: String name of the sender
key(key, object)
Attach a string key to this message and link it to an object. This reference can be used to ensure duplicates
aren't sent for the same event.
- key: String a string key which identifies the script or event which creates this message @param object key is attached to a specific object (for example an enrolment or student)
- object: PersistentObject key is attached to a specific object (for example an enrolment or student)
keyCollision(collision)
Defines a rule to prevent duplicates being sent.
- collision: String check type. Can be 'accept' (this is the default and means the key is ignored), 'drop' (which will silently drop the message) and 'error' (which will drop the message and log an error to the audit log).
record(record)
A direct entity record to message.
- record: Object
record(records)
A list of records to message. Obviously the message template needs to be
built to accept a list of this type of object and produce a message from them.
- records: List
records(records)
A list of records to message. Obviously the message template needs to be
built to accept a list of this type of object and produce a message from them.
- records: List
subject(subject)
Set email subject.
Using this method means that the message is not stored inside onCourse.
- subject: String email subject
template(templateIdentifier)
Set message template to be used for rendering message body.
Could be used for Email and SMS sending
- templateIdentifier: String keyCode of the message template or name of the legacy message template
to(recipients)
Specify extra contacts which will receive email. By default email specified in contact record will be used,
however you can override the default email by using ">>" operator, e.g. contact1 >> "[email protected]"
Using this method means that the message is not stored inside onCourse.
- recipients: Contact contact records who will receive the email
to(recipients)
Specify extra emails which will receive email.
Using this method means that the message is not stored inside onCourse.
- recipients: String email addresses of the email recipients
MicropowerScriptClosure
Retrieves new and recently changed profiles from Micropower and adds them to onCourse. Automatically creates
memeberships and invoices for the specifiec MemberProduct sku
micropower {
name "Micropower"
}
Money
Money is a class which handles all the common features needed for handling currency.
Most importantly, this class properly handles rounding at all times.
ConstructorMoney(val)
Construct a new money instance. If null or empty string is passed, then a Money.ZERO amount will be created.
- val: String value to create
ConstructorMoney(dollars,cents)
Construct a new money instance, first argument is dollars, second is cents
- dollars: int dollars value @param cents cents value
- cents: int cents value
add(val)
returns sum
-
val: Money to be added to this money object @return new money object
-
Returns: Money new money object
add(val)
returns sum
-
val: BigDecimal to be added to this money object @return new money object
-
Returns: Money new money object
divide(val)
returns quotient, where object is dividend and the param is divisor
divide(val)
returns quotient, where object is dividend and the param is divisor
-
val: BigDecimal divisor @return new money object
-
Returns: Money new money object
divide(val, roundingUp)
returns quotient, where object is dividend and the param is divisor
Used for rounding any value with cents to a greater integer value
-
val: BigDecimal divisor @param roundingUp rounded up to the nearest dollar @return new money object
-
roundingUp: boolean rounded up to the nearest dollar @return new money object
-
Returns: Money new money object
divide(val, roundingUp)
returns quotient, where object is dividend and the param is divisor
Used for rounding any value with cents to a greater integer value
-
val: Money divisor @param roundingUp rounded up to the nearest dollar @return new money object
-
roundingUp: boolean rounded up to the nearest dollar @return new money object
-
Returns: Money new money object
multiply(val)
returns product
-
val: long factor @return new money object
-
Returns: Money new money object
multiply(val)
returns product
-
val: BigDecimal factor @return new money object
-
Returns: Money new money object
subtract(val)
returns difference, where object is minuend and param is subtrahend
subtract(val)
returns difference, where object is minuend and param is subtrahend
-
val: BigDecimal subtrahend @return new money object
-
Returns: Money new money object
toBigDecimal()
- Returns: BigDecimal a big decimal representation
toPlainString()
- Returns: String a string representation skipping currency sign $25 -> "25.00"
MonitoringServiceImpl
Monitoring service which provides monitoring metrics: time, network, environment, license, systemRuntime, onCourse version
MoodleScriptClosure
Export successful enrolment record to moodle system. This action will search for students matching the onCourse
email address against the Moodle username, and creates them if not found.
moodle {
name 'Moodle integration'
enrolment record
}
The action finds courses in Moodle by 'shortname' field against the course name in onCourse. You can use
the 'courseReference' option to select a different field in Moodle and map it against any value from onCourse.
moodle {
name "Moodle integration"
enrolment record
courseReference 'courseId': record.courseClass.course.code
}
PaymentInterface
Interface to host both payment in and out, for both client and server side.
@author marcin, ldeck
Preferences
List of all preferences which can be accessed in the system. You can access the values most easily as direct attributes:
but you can also use the string key:
Report script block
Run a report and create a PDF file. This file can then be stored in the document management system or sent attached to an email.
Simple example to produce a single certificate PDF:
report {
fileName "certificate.pdf"
keycode "ish.onCourse.certificate"
record records
}
Usage example with sending an email:
email {
to preference.email.admin
subject "onCourse transaction summary ${startDate.format("dd/MM/yy")} to ${endDate.format("dd/MM/yy")}"
content "'Trial Balance' report for the previous 7 days."
attachment "Trial_Balance.pdf", "application/pdf", report {
keycode "ish.onCourse.trialBalance"
records accounts
param 'localdateRange_from' : startDate, 'localdateRange_to' : endDate
}
}
background(background)
The name of the background the report engine will use to render the output PDF file. The background sits behind
the components printed on the report. This is useful for a header or certificate background.
- background: String name of background. You can skip this option for a white background.
fileName(fileName)
Specify the filename with extension of the final file with a fulfilled report
- fileName: String fileName of the file with the report
generatePreview(generatePreview)
- generatePreview: Boolean Documentation not yet available
keycode(keyCode)
Pass the keycode of the report template in onCourse you want to run.
- keyCode: String keyCode of the report passed to the report engine
param(param)
Additional optional parameters passed to the report engine.
Reports must be provided with the correct number and types they accept to run. For example:
report {
keycode "ish.onCourse.trialBalance"
records accounts
param 'localdateRange_from' : startDate, 'localdateRange_to' : endDate
}
- param: Map parameters passed to the report
record(record)
Pass a record to the report engine. This record will be iterated through in the report engine
to produce the report output.
- record: Object record which is included in the report
record(records)
Pass a record to the report engine. This record will be iterated through in the report engine
to produce the report output.
- records: List Documentation not yet available
records(records)
Pass a list of records to the report engine. These records will be iterated through in the report engine
to produce the report output.
- records: List records which are included in the report
records(records)
Pass a record to the report engine.
- records: Object Documentation not yet available
S3ScriptClosure
Use this script block to easily send documents into the S3 service. Note that this has nothing to do with the onCourse document storage system and simply stores the blob in the S3 service without tracking it.
def transactions = query {
entity "AccountTransaction"
query "createdOn is today"
}
def bytes = export {
template "ish.onCourse.accountTransactionMYOB.csv"
records transactions
}
s3 {
name "integration name"
blob bytes
fileName "transactions.csv"
}
If you pass the DocumentParam object as the blob attribute, you can skip the name.
s3 {
name "integration name"
blob documentParam
}
Sms script block
SMS message sending API.
Usage example:
sms {
to contact1, contact2
text "test SMS text"
}
text(text)
Set SMS message text.
-
text: String message text
-
Returns: def Documentation not yet available
to(recipients)
Set recipients for the SMS message.
-
recipients: Contact recipients of the message
-
Returns: def Documentation not yet available
to(recipients)
Set list of recipients for the SMS message.
-
recipients: List of Contact list of recipients of the message
-
Returns: def Documentation not yet available
SurveyMonkeyScriptClosure
This integration allows you to push records into SurveyMonkey in order to add them to a survey. Create one integration
per survey you want to send and then use this scripting block:
surveyMonkey {
contact myContact
}
Use the name option if you have more than one SurveyMonkey integration and you want to push to only one.
surveyMonkey {
name "name of integration"
contact myContact
}
SystemUserService
systemUsersByRole(name)
-
name: String of role @return a list of all system users with certain access role
-
Returns: List of SystemUser a list of all system users with certain access role
Taggable
Entities which implement this interface may have TagRequirement, for example Student, Tutor but real TagRelation always created for Contact entity
TalentLMSScriptClosure
Export successful enrolment record to Talent LMS system. This action will search for students matching the onCourse
email address against the Talent LMS email, and creates them if not found.
That student will be enrolled in the Learndash course with code matching the course code in onCourse
talentLMS {
action "enrol"
course enrolment.courseClass.course.code
student enrolment.student
}
Updated 21 days ago