From e6e8718bb44e499158f0a8d54304d6d1f7945190 Mon Sep 17 00:00:00 2001 From: Jannat Patel Date: Tue, 23 Apr 2024 17:29:16 +0530 Subject: [PATCH] feat: certified participants --- frontend/src/pages/CertifiedParticipants.vue | 54 +++++++++++++++++++ frontend/src/router.js | 5 ++ frontend/src/utils/index.js | 14 ++++- lms/lms/api.py | 32 +++++++++++ .../doctype/lms_live_class/lms_live_class.py | 2 +- 5 files changed, 105 insertions(+), 2 deletions(-) create mode 100644 frontend/src/pages/CertifiedParticipants.vue diff --git a/frontend/src/pages/CertifiedParticipants.vue b/frontend/src/pages/CertifiedParticipants.vue new file mode 100644 index 00000000..93bba06a --- /dev/null +++ b/frontend/src/pages/CertifiedParticipants.vue @@ -0,0 +1,54 @@ + + diff --git a/frontend/src/router.js b/frontend/src/router.js index 5b7fcddb..fab065d7 100644 --- a/frontend/src/router.js +++ b/frontend/src/router.js @@ -125,6 +125,11 @@ const routes = [ component: () => import('@/pages/AssignmentSubmission.vue'), props: true, }, + { + path: '/certified-participants', + name: 'CertifiedParticipants', + component: () => import('@/pages/CertifiedParticipants.vue'), + }, ] let router = createRouter({ diff --git a/frontend/src/utils/index.js b/frontend/src/utils/index.js index a0f4cf27..66765c50 100644 --- a/frontend/src/utils/index.js +++ b/frontend/src/utils/index.js @@ -1,6 +1,12 @@ import { toast } from 'frappe-ui' import { useTimeAgo } from '@vueuse/core' -import { BookOpen, Users, TrendingUp, Briefcase } from 'lucide-vue-next' +import { + BookOpen, + Users, + TrendingUp, + Briefcase, + GraduationCap, +} from 'lucide-vue-next' import { Quiz } from '@/utils/quiz' import { Upload } from '@/utils/upload' import Header from '@editorjs/header' @@ -325,6 +331,12 @@ export function getSidebarLinks() { to: 'Batches', activeFor: ['Batches', 'BatchDetail', 'Batch'], }, + { + label: 'Certified Participants', + icon: GraduationCap, + to: 'CertifiedParticipants', + activeFor: ['CertifiedParticipants'], + }, { label: 'Jobs', icon: Briefcase, diff --git a/lms/lms/api.py b/lms/lms/api.py index eaac2c1a..22b653c1 100644 --- a/lms/lms/api.py +++ b/lms/lms/api.py @@ -325,3 +325,35 @@ def get_evaluator_details(evaluator): "calendar": calendar.name, "is_authorised": calendar.authorization_code, } + + +@frappe.whitelist(allow_guest=True) +def get_certified_participants(): + participants = frappe.db.sql( + """ + SELECT DISTINCT lc.member + FROM `tabLMS Certificate` lc + WHERE lc.published = 1 + ORDER BY lc.creation desc + """, + as_dict=1, + ) + + participant_details = [] + for participant in participants: + details = frappe.db.get_value( + "User", + participant.member, + ["name", "full_name", "username", "user_image"], + as_dict=True, + ) + course_names = frappe.get_all( + "LMS Certificate", {"member": participant.member}, pluck="course" + ) + courses = [] + for course in course_names: + courses.append(frappe.db.get_value("LMS Course", course, "title")) + details.courses = courses + participant_details.append(details) + + return participant_details diff --git a/lms/lms/doctype/lms_live_class/lms_live_class.py b/lms/lms/doctype/lms_live_class/lms_live_class.py index 872f2a06..8ebdea3f 100644 --- a/lms/lms/doctype/lms_live_class/lms_live_class.py +++ b/lms/lms/doctype/lms_live_class/lms_live_class.py @@ -34,7 +34,7 @@ class LMSLiveClass(Document): def add_event_participants(self, event, calendar): participants = frappe.get_all( - "Batch Student", {"parent": self.class_name}, pluck="student" + "Batch Student", {"parent": self.batch_name}, pluck="student" ) participants.append(frappe.session.user)