2019-05-19 16:01:45 +05:30
|
|
|
from __future__ import unicode_literals
|
|
|
|
import erpnext.education.utils as utils
|
|
|
|
import frappe
|
|
|
|
|
|
|
|
no_cache = 1
|
|
|
|
|
|
|
|
def get_context(context):
|
|
|
|
context.education_settings = frappe.get_single("Education Settings")
|
2019-05-30 16:37:15 +05:30
|
|
|
context.program = get_program(frappe.form_dict['program'])
|
2019-06-05 13:08:53 +05:30
|
|
|
context.courses = [frappe.get_doc("Course", course.course) for course in context.program.courses]
|
2019-05-30 16:37:15 +05:30
|
|
|
context.has_access = utils.allowed_program_access(frappe.form_dict['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:
|
2019-06-05 13:08:53 +05:30
|
|
|
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
|