diff --git a/lms/lms/doctype/lms_batch/lms_batch.py b/lms/lms/doctype/lms_batch/lms_batch.py index 5b13fbeb..ea368a7e 100644 --- a/lms/lms/doctype/lms_batch/lms_batch.py +++ b/lms/lms/doctype/lms_batch/lms_batch.py @@ -396,15 +396,6 @@ def get_timetable_details(timetable): return timetable -@frappe.whitelist() -def send_email_to_students(batch, subject, reply_to, message): - frappe.only_for("Moderator") - students = frappe.get_all("Batch Student", {"parent": batch}, pluck="student") - frappe.sendmail( - recipients=students, subject=subject, reply_to=reply_to, message=message - ) - - @frappe.whitelist() def is_milestone_complete(idx, batch): previous_rows = frappe.get_all( diff --git a/lms/public/css/style.css b/lms/public/css/style.css index acc05bee..c6c9e99d 100644 --- a/lms/public/css/style.css +++ b/lms/public/css/style.css @@ -2478,4 +2478,8 @@ select { .questions-table .row-index { display: none; +} + +.text-color { + color: var(--text-color); } \ No newline at end of file diff --git a/lms/www/batches/batch.html b/lms/www/batches/batch.html index 86cb1202..cda89302 100644 --- a/lms/www/batches/batch.html +++ b/lms/www/batches/batch.html @@ -75,14 +75,6 @@ - {% if is_moderator %} -
- -
- {% endif %} - {% if batch_info.custom_component %}
{{ batch_info.custom_component }} @@ -140,6 +132,15 @@ + + {% endif %} {% if batch_students | length and (is_moderator or is_student) %} @@ -192,6 +193,10 @@
{{ AssessmentsSection(batch_info) }}
+ +
+ {{ EmailsSection() }} +
{% endif %} {% if batch_students | length and (is_moderator or is_student or is_evaluator) %} @@ -376,6 +381,41 @@ {% endmacro %} + +{% macro EmailsSection() %} +
+ +
+
+ {% for email in batch_emails %} +
+
+ + + {% set member = frappe.db.get_value("User", email.sender, ["full_name", "username", "name", "user_image"], as_dict=1) %} + {{ widgets.Avatar(member=member, avatar_class="avatar-small") }} + + + {{ member.full_name }} +
+ + {{ frappe.utils.pretty_date(email.communication_date) }} + +
+
+
+
+
+ {{ email.content }} +
+
+ {% endfor %} +
+{% endmacro %} + + {% macro AssessmentList(assessments) %} {% if assessments | length %}
diff --git a/lms/www/batches/batch.js b/lms/www/batches/batch.js index fa05c159..74395a2b 100644 --- a/lms/www/batches/batch.js +++ b/lms/www/batches/batch.js @@ -831,12 +831,33 @@ const email_to_students = () => { const send_email = (values) => { frappe.call({ - method: "lms.lms.doctype.lms_batch.lms_batch.send_email_to_students", + method: "frappe.client.get_list", args: { - batch: $(".class-details").data("batch"), + doctype: "Batch Student", + parent: "LMS Batch", + fields: ["student"], + filters: { + parent: $(".class-details").data("batch"), + }, + }, + callback: (data) => { + send_email_to_students(data.message, values); + }, + }); +}; + +const send_email_to_students = (students, values) => { + students = students.map((row) => row.student); + frappe.call({ + method: "frappe.core.doctype.communication.email.make", + args: { + recipients: students.join(", "), + cc: values.reply_to, subject: values.subject, - reply_to: values.reply_to, - message: values.message, + content: values.message, + doctype: "LMS Batch", + name: $(".class-details").data("batch"), + send_email: 1, }, callback: (r) => { this.email_dialog.hide(); @@ -844,6 +865,9 @@ const send_email = (values) => { message: __("Email sent successfully"), indicator: "green", }); + setTimeout(() => { + window.location.reload(); + }, 2000); }, }); }; diff --git a/lms/www/batches/batch.py b/lms/www/batches/batch.py index bb3ad307..3f45ef8d 100644 --- a/lms/www/batches/batch.py +++ b/lms/www/batches/batch.py @@ -71,6 +71,13 @@ def get_context(context): ) context.course_name_list = [course.course for course in context.batch_courses] context.assessments = get_assessments(batch_name) + context.batch_emails = frappe.get_all( + "Communication", + filters={"reference_doctype": "LMS Batch", "reference_name": batch_name}, + fields=["subject", "content", "recipients", "cc", "communication_date", "sender"], + order_by="communication_date desc", + ) + context.batch_students = get_class_student_details( batch_students, batch_courses, context.assessments )