refactor(batch): simplify dashboard with get_count and conditional rendering
This commit is contained in:
@@ -82,18 +82,23 @@ const studentCount = createResource({
|
||||
|
||||
const assessmentCount = createResource({
|
||||
url: 'lms.lms.utils.get_batch_assessment_count',
|
||||
params: { batch: props.batch?.data?.name },
|
||||
cache: ['batch_assessment_count', props.batch?.data?.name],
|
||||
params: {
|
||||
batch: props.batch?.data?.name,
|
||||
},
|
||||
auto: true,
|
||||
})
|
||||
|
||||
const chartData = createResource({
|
||||
url: 'lms.lms.utils.get_batch_chart_data',
|
||||
cache: ['batch_chart_data', props.batch?.data?.name],
|
||||
params: { batch: props.batch?.data?.name },
|
||||
auto: true,
|
||||
})
|
||||
|
||||
const certificationCount = createResource({
|
||||
url: 'frappe.client.get_count',
|
||||
cache: ['batch_certificate_count', props.batch?.data?.name],
|
||||
params: {
|
||||
doctype: 'LMS Certificate',
|
||||
filters: { batch_name: props.batch?.data?.name },
|
||||
|
||||
@@ -88,8 +88,8 @@
|
||||
</div>
|
||||
</template>
|
||||
</ListSelectBanner>
|
||||
<div class="mt-4">
|
||||
<Button v-if="students.hasNextPage" @click="students.next()">
|
||||
<div class="mt-4" v-if="students.hasNextPage">
|
||||
<Button @click="students.next()">
|
||||
{{ __('Load More') }}
|
||||
</Button>
|
||||
</div>
|
||||
@@ -146,10 +146,11 @@ const props = defineProps({
|
||||
})
|
||||
|
||||
const studentCount = createResource({
|
||||
url: 'lms.lms.utils.get_batch_student_count',
|
||||
url: 'frappe.client.get_count',
|
||||
cache: ['batch_student_count', props.batch?.data?.name],
|
||||
params: {
|
||||
batch: props.batch?.data?.name,
|
||||
doctype: 'LMS Batch Enrollment',
|
||||
filters: { batch: props.batch?.data?.name },
|
||||
},
|
||||
auto: true,
|
||||
})
|
||||
|
||||
@@ -1355,6 +1355,13 @@ def get_exercise_details(assessment, member):
|
||||
assessment.edit_url = f"/exercises/{assessment.assessment_name}/submission/new"
|
||||
|
||||
|
||||
@frappe.whitelist()
|
||||
def get_batch_assessment_count(batch):
|
||||
if not frappe.db.exists("LMS Batch", batch):
|
||||
frappe.throw(_("The specified batch does not exist."))
|
||||
return frappe.db.count("LMS Assessment", {"parent": batch})
|
||||
|
||||
|
||||
@frappe.whitelist()
|
||||
def get_batch_students(filters, offset=0, limit_start=0, limit_page_length=None, limit=None):
|
||||
# limit_start and limit_page_length are used for backward compatibility
|
||||
@@ -1383,27 +1390,6 @@ def get_batch_students(filters, offset=0, limit_start=0, limit_page_length=None,
|
||||
return students
|
||||
|
||||
|
||||
@frappe.whitelist()
|
||||
def get_batch_student_count(batch):
|
||||
if not frappe.db.exists("LMS Batch", batch):
|
||||
frappe.throw(_("The specified batch does not exist."))
|
||||
return frappe.db.count("LMS Batch Enrollment", filters={"batch": batch})
|
||||
|
||||
|
||||
@frappe.whitelist()
|
||||
def get_batch_certificate_count(batch):
|
||||
if not frappe.db.exists("LMS Batch", batch):
|
||||
frappe.throw(_("The specified batch does not exist."))
|
||||
return frappe.db.count("LMS Certificate", filters={"batch_name": batch})
|
||||
|
||||
|
||||
@frappe.whitelist()
|
||||
def get_batch_assessment_count(batch):
|
||||
if not frappe.db.exists("LMS Batch", batch):
|
||||
frappe.throw(_("The specified batch does not exist."))
|
||||
return frappe.db.count("LMS Assessment", filters={"parent": batch})
|
||||
|
||||
|
||||
def get_course_completion_stats(batch):
|
||||
"""Get completion counts per course in batch"""
|
||||
BatchCourse = frappe.qb.DocType("Batch Course")
|
||||
|
||||
Reference in New Issue
Block a user