2019-05-19 16:01:45 +05:30
|
|
|
from __future__ import unicode_literals
|
|
|
|
import erpnext.education.utils as utils
|
|
|
|
import frappe
|
2019-06-05 19:43:51 +05:30
|
|
|
from frappe import _
|
2019-05-19 16:01:45 +05:30
|
|
|
|
|
|
|
no_cache = 1
|
|
|
|
|
|
|
|
def get_context(context):
|
2019-06-12 16:01:02 +05:30
|
|
|
try:
|
|
|
|
program = frappe.form_dict['program']
|
|
|
|
except KeyError:
|
|
|
|
frappe.local.flags.redirect_location = '/lms'
|
|
|
|
raise frappe.Redirect
|
|
|
|
|
2019-05-19 16:01:45 +05:30
|
|
|
context.education_settings = frappe.get_single("Education Settings")
|
2019-06-12 16:01:02 +05:30
|
|
|
context.program = get_program(program)
|
2019-06-05 13:08:53 +05:30
|
|
|
context.courses = [frappe.get_doc("Course", course.course) for course in context.program.courses]
|
2019-06-12 16:01:02 +05:30
|
|
|
context.has_access = utils.allowed_program_access(program)
|
2019-06-05 13:08:53 +05:30
|
|
|
context.progress = get_course_progress(context.courses, context.program)
|
2019-05-19 16:01:45 +05:30
|
|
|
|
|
|
|
def get_program(program_name):
|
|
|
|
try:
|
|
|
|
return frappe.get_doc('Program', program_name)
|
|
|
|
except frappe.DoesNotExistError:
|
2020-01-29 15:06:18 +05:30
|
|
|
frappe.throw(_("Program {0} does not exist.").format(program_name))
|
2019-06-05 13:08:53 +05:30
|
|
|
|
|
|
|
def get_course_progress(courses, program):
|
2019-06-05 17:29:48 +05:30
|
|
|
progress = {course.name: utils.get_course_progress(course, program) for course in courses}
|
2021-03-09 15:05:24 -03:00
|
|
|
return progress or {}
|