From 09cd46fa0b340098fae0fe8734076fa6db2423c6 Mon Sep 17 00:00:00 2001 From: Shivam Mishra Date: Thu, 6 Jun 2019 14:02:49 +0530 Subject: [PATCH] fix: minor bugs --- erpnext/education/utils.py | 2 +- erpnext/www/lms/topic.py | 17 ++++++++++++----- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/erpnext/education/utils.py b/erpnext/education/utils.py index 433ef9f829..0e02712acb 100644 --- a/erpnext/education/utils.py +++ b/erpnext/education/utils.py @@ -308,7 +308,7 @@ def get_program_completion(program): from `tabcourse topic`, `tabprogram course` where `tabcourse topic`.parent = `tabprogram course`.course - and `tabprogram course`.parent = %(program)s""", {'program': program}) + and `tabprogram course`.parent = %s""", program.name) progress = [] for topic in topics: diff --git a/erpnext/www/lms/topic.py b/erpnext/www/lms/topic.py index d2c6da387d..0af0778312 100644 --- a/erpnext/www/lms/topic.py +++ b/erpnext/www/lms/topic.py @@ -17,18 +17,25 @@ def get_context(context): def get_contents(topic, course, program): student = utils.get_current_student() - if not student: - return None - course_enrollment = utils.get_or_create_course_enrollment(course, program) + if student: + course_enrollment = utils.get_or_create_course_enrollment(course, program) contents = topic.get_contents() progress = [] if contents: for content in contents: if content.doctype in ('Article', 'Video'): - status = utils.check_content_completion(content.name, content.doctype, course_enrollment.name) + if student: + status = utils.check_content_completion(content.name, content.doctype, course_enrollment.name) + else: + status = True progress.append({'content': content, 'content_type': content.doctype, 'completed': status}) elif content.doctype == 'Quiz': - status, score, result = utils.check_quiz_completion(content, course_enrollment.name) + if student: + status, score, result = utils.check_quiz_completion(content, course_enrollment.name) + else: + status = False + score = None + result = None progress.append({'content': content, 'content_type': content.doctype, 'completed': status, 'score': score, 'result': result}) return progress \ No newline at end of file