fix: Profile page cards
- Only show attempted quizzes
- Show 0 percent complete if program is enrolled but unattempted
diff --git a/erpnext/public/js/education/lms/components/ScoreCard.vue b/erpnext/public/js/education/lms/components/ScoreCard.vue
index 5a6aee5..cbb6a04 100644
--- a/erpnext/public/js/education/lms/components/ScoreCard.vue
+++ b/erpnext/public/js/education/lms/components/ScoreCard.vue
@@ -1,5 +1,5 @@
<template>
- <div class='card-deck mt-3'>
+ <div v-if="quizData" class='card-deck mt-3'>
<div class="card">
<div class='card-body'>
<div class="row">
diff --git a/erpnext/www/lms.py b/erpnext/www/lms.py
index 12c742f..f8e7340 100644
--- a/erpnext/www/lms.py
+++ b/erpnext/www/lms.py
@@ -241,10 +241,16 @@
if meta['flag'] == "Completed":
is_complete = True
progress.append({'course_name': course.course_name, 'name': course.course, 'is_complete': is_complete})
+
program_meta['progress'] = progress
program_meta['name'] = program_name
program_meta['program'] = program.program_name
- program_meta['percentage'] = math.ceil((sum([item['is_complete'] for item in progress] * 100)/len(progress)))
+
+ try:
+ program_meta['percentage'] = math.ceil((sum([item['is_complete'] for item in progress] * 100)/len(progress)))
+ except ZeroDivisionError:
+ program_meta['percentage'] = 0
+
return program_meta
@frappe.whitelist()
@@ -270,6 +276,8 @@
if progress_item['content_type'] == "Quiz":
progress_item['course'] = course.course_name
progress_list.append(progress_item)
+ if not progress_list:
+ return None
quiz_meta.quiz_attempt = progress_list
quiz_meta.name = program_name
quiz_meta.program = program.program_name