Merge pull request #674 from pateljannat/assignment-fix
fix: assignment submission email
This commit is contained in:
@@ -2,6 +2,13 @@
|
||||
// For license information, please see license.txt
|
||||
|
||||
frappe.ui.form.on("LMS Assignment Submission", {
|
||||
// refresh: function(frm) {
|
||||
// }
|
||||
onload: function (frm) {
|
||||
frm.set_query("member", function (doc) {
|
||||
return {
|
||||
filters: {
|
||||
ignore_user_type: 1,
|
||||
},
|
||||
};
|
||||
});
|
||||
},
|
||||
});
|
||||
|
||||
@@ -5,12 +5,17 @@ import frappe
|
||||
from frappe import _
|
||||
from frappe.model.document import Document
|
||||
from frappe.utils import validate_url
|
||||
from frappe.email.doctype.email_template.email_template import get_email_template
|
||||
|
||||
|
||||
class LMSAssignmentSubmission(Document):
|
||||
def validate(self):
|
||||
self.validate_duplicates()
|
||||
|
||||
def after_insert(self):
|
||||
if not frappe.flags.in_test:
|
||||
self.send_mail()
|
||||
|
||||
def validate_duplicates(self):
|
||||
if frappe.db.exists(
|
||||
"LMS Assignment Submission",
|
||||
@@ -23,6 +28,35 @@ class LMSAssignmentSubmission(Document):
|
||||
)
|
||||
)
|
||||
|
||||
def send_mail(self):
|
||||
subject = _("New Assignment Submission")
|
||||
template = "assignment_submission"
|
||||
custom_template = frappe.db.get_single_value(
|
||||
"LMS Settings", "assignment_submission_template"
|
||||
)
|
||||
|
||||
args = {
|
||||
"member_name": self.member_name,
|
||||
"assignment_name": self.assignment,
|
||||
"assignment_title": self.assignment_title,
|
||||
"submission_name": self.name,
|
||||
}
|
||||
|
||||
moderators = frappe.get_all("Has Role", {"role": "Moderator"}, pluck="parent")
|
||||
|
||||
if custom_template:
|
||||
email_template = get_email_template(custom_template, args)
|
||||
subject = email_template.get("subject")
|
||||
content = email_template.get("message")
|
||||
frappe.sendmail(
|
||||
recipients=moderators,
|
||||
subject=subject,
|
||||
template=template if not custom_template else None,
|
||||
content=content if custom_template else None,
|
||||
args=args,
|
||||
header=[subject, "green"],
|
||||
)
|
||||
|
||||
|
||||
@frappe.whitelist()
|
||||
def upload_assignment(
|
||||
|
||||
@@ -10,14 +10,12 @@
|
||||
"is_onboarding_complete",
|
||||
"column_break_zdel",
|
||||
"livecode_url",
|
||||
"certification_template",
|
||||
"course_settings_section",
|
||||
"search_placeholder",
|
||||
"column_break_iqxy",
|
||||
"portal_course_creation",
|
||||
"section_break_szgq",
|
||||
"send_calendar_invite_for_evaluations",
|
||||
"batch_confirmation_template",
|
||||
"allow_student_progress",
|
||||
"column_break_2",
|
||||
"show_dashboard",
|
||||
@@ -51,7 +49,12 @@
|
||||
"default_currency",
|
||||
"show_usd_equivalent",
|
||||
"apply_rounding",
|
||||
"exception_country"
|
||||
"exception_country",
|
||||
"email_templates_tab",
|
||||
"certification_template",
|
||||
"batch_confirmation_template",
|
||||
"column_break_uwsp",
|
||||
"assignment_submission_template"
|
||||
],
|
||||
"fields": [
|
||||
{
|
||||
@@ -323,12 +326,27 @@
|
||||
"fieldtype": "Link",
|
||||
"label": "Certificate Email Template",
|
||||
"options": "Email Template"
|
||||
},
|
||||
{
|
||||
"fieldname": "email_templates_tab",
|
||||
"fieldtype": "Tab Break",
|
||||
"label": "Email Templates"
|
||||
},
|
||||
{
|
||||
"fieldname": "assignment_submission_template",
|
||||
"fieldtype": "Link",
|
||||
"label": "Assignment Submission Template",
|
||||
"options": "Email Template"
|
||||
},
|
||||
{
|
||||
"fieldname": "column_break_uwsp",
|
||||
"fieldtype": "Column Break"
|
||||
}
|
||||
],
|
||||
"index_web_pages_for_search": 1,
|
||||
"issingle": 1,
|
||||
"links": [],
|
||||
"modified": "2023-11-01 22:38:38.380325",
|
||||
"modified": "2023-11-07 11:23:14.257687",
|
||||
"modified_by": "Administrator",
|
||||
"module": "LMS",
|
||||
"name": "LMS Settings",
|
||||
|
||||
@@ -1,27 +0,0 @@
|
||||
{
|
||||
"attach_print": 0,
|
||||
"channel": "Email",
|
||||
"creation": "2023-03-27 16:34:03.505647",
|
||||
"days_in_advance": 0,
|
||||
"docstatus": 0,
|
||||
"doctype": "Notification",
|
||||
"document_type": "LMS Assignment Submission",
|
||||
"enabled": 1,
|
||||
"event": "New",
|
||||
"idx": 0,
|
||||
"is_standard": 1,
|
||||
"message": "<h3> {{ _(\"Assignment Submission\") }}\n\n{% set title = frappe.db.get_value(\"Course Lesson\", doc.lesson, \"title\") %}\n\n<p> {{ _(\"{0} has submitted their assignment for the lesson {1}\").format(doc.member_name, title) }} </p>\n\n <p> {{ _(\" Please evaluate and grade the assignment. \") }} </p>",
|
||||
"modified": "2023-03-27 16:46:44.564007",
|
||||
"modified_by": "Administrator",
|
||||
"module": "LMS",
|
||||
"name": "Assignment Submission Notification",
|
||||
"owner": "Administrator",
|
||||
"recipients": [
|
||||
{
|
||||
"receiver_by_document_field": "evaluator"
|
||||
}
|
||||
],
|
||||
"send_system_notification": 0,
|
||||
"send_to_all_assignees": 0,
|
||||
"subject": "Assignment Submission"
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
<div style="background-color: #f4f5f6; padding: 1rem;">
|
||||
<div style="background-color: #ffffff; width: 75%; margin: 0 auto; padding: 1rem;">
|
||||
<h3> {{ _("Assignment Submission") }} </h3>
|
||||
{% set title = frappe.db.get_value("Course Lesson", doc.lesson, "title") %}
|
||||
<br>
|
||||
<p> {{ _("{0} has submitted their assignment for the lesson {1}").format(frappe.bold(doc.member_name), frappe.bold(title)) }}
|
||||
</p>
|
||||
<p> {{ _(" Please evaluate and grade the assignment.") }} </p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -1,6 +0,0 @@
|
||||
import frappe
|
||||
|
||||
|
||||
def get_context(context):
|
||||
# do your magic here
|
||||
pass
|
||||
@@ -80,4 +80,5 @@ lms.patches.v1_0.add_certificate_template #26-10-2023
|
||||
lms.patches.v1_0.create_batch_source
|
||||
|
||||
[post_model_sync]
|
||||
lms.patches.v1_0.batch_tabs_settings
|
||||
lms.patches.v1_0.batch_tabs_settings
|
||||
execute:frappe.delete_doc("Notification", "Assignment Submission Notification")
|
||||
10
lms/templates/emails/assignment_submission.html
Normal file
10
lms/templates/emails/assignment_submission.html
Normal file
@@ -0,0 +1,10 @@
|
||||
<p>
|
||||
{{ _("{0} has submitted the assignment {1}").format(frappe.bold(member_name), frappe.bold(assignment_title)) }}
|
||||
</p>
|
||||
<br>
|
||||
<p> {{ _(" Please evaluate and grade it.") }} </p>
|
||||
<br>`
|
||||
<a href="/assignment-submission/{{ assignment_name }}/{{ submission_name }}">
|
||||
{{ _("Open Assignment") }}
|
||||
</a>
|
||||
|
||||
Reference in New Issue
Block a user