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

fix: misc batch flow changes #1304

Merged
merged 3 commits into from
Feb 12, 2025
Merged
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
4 changes: 3 additions & 1 deletion frontend/src/components/Assignment.vue
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,6 @@ watch(submissionResource, () => {
if (submissionResource.doc.answer) {
answer.value = submissionResource.doc.answer
}

if (submissionResource.isDirty) {
isDirty.value = true
} else if (showUploader() && !submissionFile.value) {
Expand Down Expand Up @@ -309,6 +308,7 @@ const submitAssignment = () => {
submissionResource.setValue.submit(
{
...submissionResource.doc,
assignment_attachment: submissionFile.value?.file_url,
evaluator: evaluator,
},
{
Expand Down Expand Up @@ -351,6 +351,7 @@ const addNewSubmission = () => {
}

const saveSubmission = (file) => {
isDirty.value = true
submissionFile.value = file
}

Expand Down Expand Up @@ -401,6 +402,7 @@ const validateFile = (file) => {
}

const removeSubmission = () => {
isDirty.value = true
submissionFile.value = null
}

Expand Down
31 changes: 29 additions & 2 deletions frontend/src/components/BatchStudents.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
{{ __('Statistics') }}
</div>
</div>
<div class="grid grid-cols-3 gap-5 mb-8">
<div class="grid grid-cols-4 gap-5 mb-8">
<div
class="flex items-center border py-2 px-3 rounded-md text-ink-gray-7"
>
Expand All @@ -22,6 +22,22 @@
</div>
</div>

<div
class="flex items-center border py-2 px-3 rounded-md text-ink-gray-7"
>
<div class="p-2 rounded-md bg-surface-gray-2 mr-3">
<GraduationCap class="w-5 h-5 stroke-1.5" />
</div>
<div class="flex items-center space-x-2">
<span class="font-semibold">
{{ certificationCount.data }}
</span>
<span class="">
{{ __('Certified') }}
</span>
</div>
</div>

<div
class="flex items-center border py-2 px-3 rounded-md text-ink-gray-7"
>
Expand Down Expand Up @@ -210,7 +226,7 @@ import {
} from 'frappe-ui'
import {
BookOpen,
Clipboard,
GraduationCap,
Plus,
ShieldCheck,
Trash2,
Expand Down Expand Up @@ -410,6 +426,17 @@ watch(students, () => {
assessmentCount.value = Object.keys(students.data?.[0].assessments).length
}
})

const certificationCount = createResource({
url: 'frappe.client.get_count',
params: {
doctype: 'LMS Certificate',
filters: {
batch_name: props.batch.name,
},
},
auto: true,
})
</script>
<style>
.apexcharts-legend {
Expand Down
13 changes: 5 additions & 8 deletions frontend/src/components/Modals/AnnouncementModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@
{{ __('Announcement') }}
</div>
<TextEditor
:bubbleMenu="true"
:fixedMenu="true"
@change="(val) => (announcement.announcement = val)"
editorClass="prose-sm py-2 px-2 min-h-[200px] border-outline-gray-2 hover:border-outline-gray-3 rounded-md bg-surface-gray-3"
editorClass="prose-sm py-2 px-2 min-h-[200px] border-outline-gray-2 hover:border-outline-gray-3 rounded-b-md bg-surface-gray-3"
/>
</div>
</div>
Expand Down Expand Up @@ -67,16 +67,13 @@ const announcement = reactive({
})

const announcementResource = createResource({
url: 'frappe.core.doctype.communication.email.make',
url: 'lms.lms.api.make_announcement',
makeParams(values) {
return {
recipients: props.students.join(', '),
students: props.students,
cc: announcement.replyTo,
subject: announcement.subject,
content: announcement.announcement,
doctype: 'LMS Batch',
name: props.batch,
send_email: 1,
}
},
})
Expand All @@ -102,7 +99,7 @@ const makeAnnouncement = (close) => {
)
},
onError(err) {
showToast(__('Error'), __(err.messages?.[0] || err), 'check')
showToast(__('Error'), __(err.messages?.[0] || err), 'alert-circle')
},
}
)
Expand Down
13 changes: 13 additions & 0 deletions lms/lms/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -1225,3 +1225,16 @@ def get_notifications(filters):
@frappe.whitelist(allow_guest=True)
def is_guest_allowed():
return frappe.get_cached_value("LMS Settings", None, "allow_guest_access")


@frappe.whitelist()
def make_announcement(students, cc, subject, content):
for student in students:
frappe.sendmail(
recipients=student,
cc=cc,
subject=subject,
message=content,
header=[subject, "green"],
retry=3,
)
10 changes: 9 additions & 1 deletion lms/lms/doctype/lms_batch/lms_batch.json
Original file line number Diff line number Diff line change
Expand Up @@ -325,9 +325,17 @@
{
"link_doctype": "LMS Batch Enrollment",
"link_fieldname": "batch"
},
{
"link_doctype": "LMS Certificate Evaluation",
"link_fieldname": "batch_name"
},
{
"link_doctype": "LMS Certificate",
"link_fieldname": "batch_name"
}
],
"modified": "2025-02-10 12:01:22.476325",
"modified": "2025-02-12 11:59:35.312487",
"modified_by": "Administrator",
"module": "LMS",
"name": "LMS Batch",
Expand Down
5 changes: 3 additions & 2 deletions lms/lms/doctype/lms_batch_enrollment/lms_batch_enrollment.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ def validate(self):

def validate_duplicate_members(self):
if frappe.db.exists(
"LMS Batch Enrollment", {"batch": self.batch, "member": self.member}
"LMS Batch Enrollment",
{"batch": self.batch, "member": self.member, "name": ["!=", self.name]},
):
frappe.throw(_("Member already enrolled in this batch"))

Expand Down Expand Up @@ -70,7 +71,7 @@ def send_confirmation_email(doc):
if not doc.confirmation_email_sent and (
outgoing_email_account or frappe.conf.get("mail_login")
):
doc.send_mail()
send_mail(doc)
doc.db_set("confirmation_email_sent", 1)


Expand Down
Loading