2019-06-05 11:59:48 +00:00
|
|
|
import frappe
|
|
|
|
|
|
|
|
import erpnext.education.utils as utils
|
2021-09-02 11:14:59 +00:00
|
|
|
|
2019-06-05 11:59:48 +00:00
|
|
|
no_cache = 1
|
|
|
|
|
|
|
|
def get_context(context):
|
2019-06-05 12:08:12 +00:00
|
|
|
if frappe.session.user == "Guest":
|
|
|
|
frappe.local.flags.redirect_location = '/lms'
|
|
|
|
raise frappe.Redirect
|
|
|
|
|
2019-06-05 11:59:48 +00:00
|
|
|
context.student = utils.get_current_student()
|
2019-06-05 12:08:12 +00:00
|
|
|
if not context.student:
|
|
|
|
context.student = frappe.get_doc('User', frappe.session.user)
|
2019-06-05 11:59:48 +00:00
|
|
|
context.progress = get_program_progress(context.student.name)
|
|
|
|
|
|
|
|
def get_program_progress(student):
|
|
|
|
enrolled_programs = frappe.get_all("Program Enrollment", filters={'student':student}, fields=['program'])
|
|
|
|
student_progress = []
|
|
|
|
for list_item in enrolled_programs:
|
|
|
|
program = frappe.get_doc("Program", list_item.program)
|
|
|
|
progress = utils.get_program_progress(program)
|
|
|
|
completion = utils.get_program_completion(program)
|
|
|
|
student_progress.append({'program': program.program_name, 'name': program.name, 'progress':progress, 'completion': completion})
|
|
|
|
|
2019-06-05 12:08:12 +00:00
|
|
|
return student_progress
|