LMS:Added class methods for course, program and student doctypes
Co-authored-by: Chinmay Pai <chinmaydpai@gmail.com>
diff --git a/erpnext/education/doctype/course/course.py b/erpnext/education/doctype/course/course.py
index 68d666c..1e42709 100644
--- a/erpnext/education/doctype/course/course.py
+++ b/erpnext/education/doctype/course/course.py
@@ -19,7 +19,7 @@
if total_weightage != 100:
frappe.throw(_("Total Weightage of all Assessment Criteria must be 100%"))
- def get_content_data(self, data):
+ def get_content_value(self, data):
try:
course_content_list = self.get_all_children()
content_data = [frappe.get_value(course_content.content_type, course_content.content, data) for course_content in course_content_list]
@@ -28,9 +28,18 @@
return None
return content_data
+ def get_content_info(self):
+ try:
+ course_content_list = self.get_all_children()
+ content_data = [[course_content.content_type, course_content.content] for course_content in course_content_list]
+ except Exception as e:
+ print(e)
+ return None
+ return content_data
+
def get_content_title(self):
'''
returns all the course content for the given course object.
'''
- content_title = self.get_content_data("title")
- return content_title
+ content_title = self.get_content_value("title")
+ return content_title
\ No newline at end of file
diff --git a/erpnext/education/doctype/program/program.py b/erpnext/education/doctype/program/program.py
index f626880..38bdb81 100644
--- a/erpnext/education/doctype/program/program.py
+++ b/erpnext/education/doctype/program/program.py
@@ -7,4 +7,8 @@
from frappe.model.document import Document
class Program(Document):
- pass
\ No newline at end of file
+
+ def get_course_list(self):
+ course_content_list = self.get_all_children()
+ course_list = [frappe.get_doc("Course", course_item.course) for course_item in course_content_list]
+ return course_list
\ No newline at end of file
diff --git a/erpnext/education/doctype/student/student.py b/erpnext/education/doctype/student/student.py
index 53bf6f7..59c1a49 100644
--- a/erpnext/education/doctype/student/student.py
+++ b/erpnext/education/doctype/student/student.py
@@ -44,6 +44,16 @@
if self.student_applicant:
frappe.db.set_value("Student Applicant", self.student_applicant, "application_status", "Admitted")
+ def get_course_enrollments(self):
+ """Returns a list of course enrollments linked with the current student"""
+ enrollments_name_list = frappe.get_list("Course Enrollment", filters={"student": self.name}, fields=['name'])
+ if not enrollments_name_list:
+ frappe.throw("Student {0} has not enrolled in any course".format(self.name))
+ return None
+ else:
+ enrollments= [frappe.get_doc("Course Enrollment", enrollment.name) for enrollment in enrollments_name_list]
+ return enrollments
+
def get_timeline_data(doctype, name):
'''Return timeline for attendance'''
return dict(frappe.db.sql('''select unix_timestamp(`date`), count(*)