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({
|
const assessmentCount = createResource({
|
||||||
url: 'lms.lms.utils.get_batch_assessment_count',
|
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,
|
auto: true,
|
||||||
})
|
})
|
||||||
|
|
||||||
const chartData = createResource({
|
const chartData = createResource({
|
||||||
url: 'lms.lms.utils.get_batch_chart_data',
|
url: 'lms.lms.utils.get_batch_chart_data',
|
||||||
|
cache: ['batch_chart_data', props.batch?.data?.name],
|
||||||
params: { batch: props.batch?.data?.name },
|
params: { batch: props.batch?.data?.name },
|
||||||
auto: true,
|
auto: true,
|
||||||
})
|
})
|
||||||
|
|
||||||
const certificationCount = createResource({
|
const certificationCount = createResource({
|
||||||
url: 'frappe.client.get_count',
|
url: 'frappe.client.get_count',
|
||||||
|
cache: ['batch_certificate_count', props.batch?.data?.name],
|
||||||
params: {
|
params: {
|
||||||
doctype: 'LMS Certificate',
|
doctype: 'LMS Certificate',
|
||||||
filters: { batch_name: props.batch?.data?.name },
|
filters: { batch_name: props.batch?.data?.name },
|
||||||
|
|||||||
@@ -88,8 +88,8 @@
|
|||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
</ListSelectBanner>
|
</ListSelectBanner>
|
||||||
<div class="mt-4">
|
<div class="mt-4" v-if="students.hasNextPage">
|
||||||
<Button v-if="students.hasNextPage" @click="students.next()">
|
<Button @click="students.next()">
|
||||||
{{ __('Load More') }}
|
{{ __('Load More') }}
|
||||||
</Button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
@@ -146,10 +146,11 @@ const props = defineProps({
|
|||||||
})
|
})
|
||||||
|
|
||||||
const studentCount = createResource({
|
const studentCount = createResource({
|
||||||
url: 'lms.lms.utils.get_batch_student_count',
|
url: 'frappe.client.get_count',
|
||||||
cache: ['batch_student_count', props.batch?.data?.name],
|
cache: ['batch_student_count', props.batch?.data?.name],
|
||||||
params: {
|
params: {
|
||||||
batch: props.batch?.data?.name,
|
doctype: 'LMS Batch Enrollment',
|
||||||
|
filters: { batch: props.batch?.data?.name },
|
||||||
},
|
},
|
||||||
auto: true,
|
auto: true,
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -1355,6 +1355,13 @@ def get_exercise_details(assessment, member):
|
|||||||
assessment.edit_url = f"/exercises/{assessment.assessment_name}/submission/new"
|
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()
|
@frappe.whitelist()
|
||||||
def get_batch_students(filters, offset=0, limit_start=0, limit_page_length=None, limit=None):
|
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
|
# 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
|
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):
|
def get_course_completion_stats(batch):
|
||||||
"""Get completion counts per course in batch"""
|
"""Get completion counts per course in batch"""
|
||||||
BatchCourse = frappe.qb.DocType("Batch Course")
|
BatchCourse = frappe.qb.DocType("Batch Course")
|
||||||
|
|||||||
Reference in New Issue
Block a user