feat: added course progress apis

This commit is contained in:
Shivam Mishra
2019-06-05 13:08:53 +05:30
parent 6d4c666476
commit 570161b978
4 changed files with 70 additions and 19 deletions

View File

@@ -7,10 +7,16 @@ no_cache = 1
def get_context(context):
context.education_settings = frappe.get_single("Education Settings")
context.program = get_program(frappe.form_dict['program'])
context.courses = [frappe.get_doc("Course", course.course) for course in context.program.courses]
context.has_access = utils.allowed_program_access(frappe.form_dict['program'])
context.progress = get_course_progress(context.courses, context.program)
def get_program(program_name):
try:
return frappe.get_doc('Program', program_name)
except frappe.DoesNotExistError:
frappe.throw(_("Program {0} does not exist.".format(program_name)))
frappe.throw(_("Program {0} does not exist.".format(program_name)))
def get_course_progress(courses, program):
progress = {course.name: utils.get_student_course_details(course, program) for course in courses}
return progress