Added class functions
This commit is contained in:
parent
cc166c01eb
commit
892b0c23fc
@ -19,27 +19,17 @@ class Course(Document):
|
|||||||
if total_weightage != 100:
|
if total_weightage != 100:
|
||||||
frappe.throw(_("Total Weightage of all Assessment Criteria must be 100%"))
|
frappe.throw(_("Total Weightage of all Assessment Criteria must be 100%"))
|
||||||
|
|
||||||
def get_content_value(self, data):
|
def get_contents(self):
|
||||||
try:
|
try:
|
||||||
course_content_list = self.get_all_children()
|
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]
|
content_data = [frappe.get_doc(course_content.content_type, course_content.content) for course_content in course_content_list]
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(e)
|
print(e)
|
||||||
return None
|
return None
|
||||||
return content_data
|
return content_data
|
||||||
|
|
||||||
def get_content_info(self):
|
def get_first_content(self):
|
||||||
try:
|
return self.get_contents()[0]
|
||||||
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):
|
def get_last_content(self):
|
||||||
'''
|
return self.get_contents()[-1]
|
||||||
returns all the course content for the given course object.
|
|
||||||
'''
|
|
||||||
content_title = self.get_content_value("title")
|
|
||||||
return content_title
|
|
@ -8,7 +8,24 @@ from frappe.model.document import Document
|
|||||||
|
|
||||||
class CourseEnrollment(Document):
|
class CourseEnrollment(Document):
|
||||||
|
|
||||||
|
def get_linked_activity(self):
|
||||||
|
course_activity_list = frappe.get_all("Course Activity", filters={'enrollment':self.name})
|
||||||
|
course_activity = [frappe.get_doc("Course Activity", activity.name) for activity in course_activity_list]
|
||||||
|
quiz_activity_list = frappe.get_all("Quiz Activity", filters={'enrollment':self.name})
|
||||||
|
quiz_activity = [frappe.get_doc("Quiz Activity", activity.name) for activity in quiz_activity_list]
|
||||||
|
return course_activity, quiz_activity
|
||||||
|
|
||||||
def get_all_activity(self):
|
def get_all_activity(self):
|
||||||
course_activity_list = frappe.get_all("Course Activity", filters={'enrollment':self.name}, fields=['content', 'content_type', 'modified'], order_by='modified')
|
courses, quizes = self.get_linked_activity()
|
||||||
quiz_activity_list = frappe.get_all("Quiz Activity", filters={'enrollment':self.name}, fields=['quiz', 'status', 'modified'], order_by='modified')
|
joined = courses + quizes
|
||||||
return course_activity_list, quiz_activity_list
|
activity = sorted(joined, key = lambda i: i.modified) # Sorting based on modified timestamp
|
||||||
|
return activity
|
||||||
|
|
||||||
|
def check_course_completion(self):
|
||||||
|
pass
|
||||||
|
|
||||||
|
def get_last_activity(self):
|
||||||
|
if len(self.get_all_activity()) == 0:
|
||||||
|
return None
|
||||||
|
else:
|
||||||
|
return self.get_all_activity()[-1]
|
Loading…
x
Reference in New Issue
Block a user