Shivam Mishra | 16b4129 | 2019-06-05 17:29:48 +0530 | [diff] [blame] | 1 | import frappe |
| 2 | |
Chillar Anand | 915b343 | 2021-09-02 16:44:59 +0530 | [diff] [blame] | 3 | import erpnext.education.utils as utils |
| 4 | |
Shivam Mishra | 16b4129 | 2019-06-05 17:29:48 +0530 | [diff] [blame] | 5 | no_cache = 1 |
| 6 | |
| 7 | def get_context(context): |
Shivam Mishra | bd499fc | 2019-06-05 17:38:12 +0530 | [diff] [blame] | 8 | if frappe.session.user == "Guest": |
| 9 | frappe.local.flags.redirect_location = '/lms' |
| 10 | raise frappe.Redirect |
| 11 | |
Shivam Mishra | 16b4129 | 2019-06-05 17:29:48 +0530 | [diff] [blame] | 12 | context.student = utils.get_current_student() |
Shivam Mishra | bd499fc | 2019-06-05 17:38:12 +0530 | [diff] [blame] | 13 | if not context.student: |
| 14 | context.student = frappe.get_doc('User', frappe.session.user) |
Shivam Mishra | 16b4129 | 2019-06-05 17:29:48 +0530 | [diff] [blame] | 15 | context.progress = get_program_progress(context.student.name) |
| 16 | |
| 17 | def get_program_progress(student): |
| 18 | enrolled_programs = frappe.get_all("Program Enrollment", filters={'student':student}, fields=['program']) |
| 19 | student_progress = [] |
| 20 | for list_item in enrolled_programs: |
| 21 | program = frappe.get_doc("Program", list_item.program) |
| 22 | progress = utils.get_program_progress(program) |
| 23 | completion = utils.get_program_completion(program) |
| 24 | student_progress.append({'program': program.program_name, 'name': program.name, 'progress':progress, 'completion': completion}) |
| 25 | |
Ankush Menat | 4551d7d | 2021-08-19 13:41:10 +0530 | [diff] [blame] | 26 | return student_progress |