diff --git a/community/lms/doctype/lms_course/lms_course.py b/community/lms/doctype/lms_course/lms_course.py index ac93ac86..73b1d5e3 100644 --- a/community/lms/doctype/lms_course/lms_course.py +++ b/community/lms/doctype/lms_course/lms_course.py @@ -133,6 +133,8 @@ class LMSCourse(Document): "status": "Complete" }) precision = cint(frappe.db.get_default("float_precision")) or 3 + if not lesson_count: + return 0 return flt(((completed_lessons/lesson_count) * 100), precision) def get_batch(self, batch_name): diff --git a/community/lms/md.py b/community/lms/md.py index 0658ca82..73be75d9 100644 --- a/community/lms/md.py +++ b/community/lms/md.py @@ -93,11 +93,11 @@ class MacroInlineProcessor(InlineProcessor): macro = m.group(1) arg = m.group(2) html = render_macro(macro, arg) - html = sanitize_html(str(html)) + html = sanitize_html(str(html), macro) e = etree.fromstring(html) return e, m.start(0), m.end(0) -def sanitize_html(html): +def sanitize_html(html, macro): """Sanotize the html using BeautifulSoup. The markdown processor request the correct markup and crashes on @@ -106,4 +106,7 @@ def sanitize_html(html): """ soup = BeautifulSoup(html, features="lxml") nodes = soup.body.children - return "