Shivam Mishra | 16b4129 | 2019-06-05 17:29:48 +0530 | [diff] [blame^] | 1 | from __future__ import unicode_literals |
| 2 | import erpnext.education.utils as utils |
| 3 | import frappe |
| 4 | |
| 5 | no_cache = 1 |
| 6 | |
| 7 | def get_context(context): |
| 8 | context.student = utils.get_current_student() |
| 9 | context.progress = get_program_progress(context.student.name) |
| 10 | |
| 11 | def get_program_progress(student): |
| 12 | enrolled_programs = frappe.get_all("Program Enrollment", filters={'student':student}, fields=['program']) |
| 13 | student_progress = [] |
| 14 | for list_item in enrolled_programs: |
| 15 | program = frappe.get_doc("Program", list_item.program) |
| 16 | progress = utils.get_program_progress(program) |
| 17 | completion = utils.get_program_completion(program) |
| 18 | student_progress.append({'program': program.program_name, 'name': program.name, 'progress':progress, 'completion': completion}) |
| 19 | |
| 20 | return student_progress |
| 21 | |
| 22 | |
| 23 | |
| 24 | |