LMS: Added functions to get LMS contents
Co-authored-by: Chinmay Pai <chinmaydpai@gmail.com>
This commit is contained in:
parent
82df4378de
commit
fa2db3c41b
@ -113,39 +113,6 @@
|
|||||||
"translatable": 0,
|
"translatable": 0,
|
||||||
"unique": 1
|
"unique": 1
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"allow_bulk_edit": 0,
|
|
||||||
"allow_in_quick_entry": 0,
|
|
||||||
"allow_on_submit": 0,
|
|
||||||
"bold": 0,
|
|
||||||
"collapsible": 0,
|
|
||||||
"columns": 0,
|
|
||||||
"default": "0",
|
|
||||||
"fieldname": "is_published",
|
|
||||||
"fieldtype": "Check",
|
|
||||||
"hidden": 0,
|
|
||||||
"ignore_user_permissions": 0,
|
|
||||||
"ignore_xss_filter": 0,
|
|
||||||
"in_filter": 0,
|
|
||||||
"in_global_search": 0,
|
|
||||||
"in_list_view": 0,
|
|
||||||
"in_standard_filter": 0,
|
|
||||||
"label": "Is Published",
|
|
||||||
"length": 0,
|
|
||||||
"no_copy": 0,
|
|
||||||
"permlevel": 0,
|
|
||||||
"precision": "",
|
|
||||||
"print_hide": 0,
|
|
||||||
"print_hide_if_no_value": 0,
|
|
||||||
"read_only": 0,
|
|
||||||
"remember_last_selected_value": 0,
|
|
||||||
"report_hide": 0,
|
|
||||||
"reqd": 0,
|
|
||||||
"search_index": 0,
|
|
||||||
"set_only_once": 0,
|
|
||||||
"translatable": 0,
|
|
||||||
"unique": 0
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"allow_bulk_edit": 0,
|
"allow_bulk_edit": 0,
|
||||||
"allow_in_quick_entry": 0,
|
"allow_in_quick_entry": 0,
|
||||||
@ -548,7 +515,7 @@
|
|||||||
"issingle": 0,
|
"issingle": 0,
|
||||||
"istable": 0,
|
"istable": 0,
|
||||||
"max_attachments": 0,
|
"max_attachments": 0,
|
||||||
"modified": "2018-10-16 13:03:35.328063",
|
"modified": "2018-10-16 15:50:59.193504",
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"module": "Education",
|
"module": "Education",
|
||||||
"name": "Content",
|
"name": "Content",
|
||||||
|
@ -133,19 +133,68 @@ def check_entry_exists(program):
|
|||||||
try:
|
try:
|
||||||
activity_name = frappe.get_all("Course Activity", filters={"student_id": get_student_id(frappe.session.user), "program_name": program})[0]
|
activity_name = frappe.get_all("Course Activity", filters={"student_id": get_student_id(frappe.session.user), "program_name": program})[0]
|
||||||
except IndexError:
|
except IndexError:
|
||||||
print("------ Got No Doc ------")
|
|
||||||
return True, None
|
return True, None
|
||||||
else:
|
else:
|
||||||
print("------ Got A Doc ------")
|
|
||||||
return None, frappe.get_doc("Course Activity", activity_name)
|
return None, frappe.get_doc("Course Activity", activity_name)
|
||||||
|
|
||||||
|
def get_contents_in_course(course_name):
|
||||||
|
try:
|
||||||
|
course_doc = frappe.get_doc("Course", {"name":course_name, "is_published": True})
|
||||||
|
return [frappe.get_doc("Content", content.content) for content in course_doc.get_all_children()]
|
||||||
|
except frappe.DoesNotExistError:
|
||||||
|
return None
|
||||||
|
|
||||||
|
def get_courses_in_program(program):
|
||||||
|
try:
|
||||||
|
program_doc = frappe.get_doc("Program", program)
|
||||||
|
if program_doc.is_published:
|
||||||
|
course_list = [frappe.get_doc("Course", course.course_name) for course in program_doc.get_all_children()]
|
||||||
|
return [course for course in course_list if course.is_published == True]
|
||||||
|
else:
|
||||||
|
return None
|
||||||
|
except frappe.DoesNotExistError:
|
||||||
|
return None
|
||||||
|
|
||||||
|
def get_program():
|
||||||
|
program_list = frappe.get_list("Program", filters={"is_published": is_published})
|
||||||
|
if program_list:
|
||||||
|
return program_list
|
||||||
|
else:
|
||||||
|
return None
|
||||||
|
|
||||||
|
def get_featured_program():
|
||||||
|
featured_list = frappe.get_list("Program", filters={"is_published": True, "is_featured": True})
|
||||||
|
if featured_list:
|
||||||
|
return featured_list
|
||||||
|
else:
|
||||||
|
return None
|
||||||
|
|
||||||
|
@frappe.whitelist()
|
||||||
|
def add_course_enrollment(course, email):
|
||||||
|
student_id = get_student_id(email)
|
||||||
|
if not get_course_enrollment(course, email):
|
||||||
|
enrollment = frappe.get_doc({
|
||||||
|
"doctype": "Course Enrollment",
|
||||||
|
"student": student_id,
|
||||||
|
"course": course
|
||||||
|
})
|
||||||
|
enrollment.save()
|
||||||
|
frappe.db.commit()
|
||||||
|
return enrollment
|
||||||
|
|
||||||
|
def get_course_enrollment(course, email):
|
||||||
|
student_id = get_student_id(email)
|
||||||
|
try:
|
||||||
|
return frappe.get_list("Course Enrollment", filters={'course':course, 'student':student_id})[0]
|
||||||
|
except IndexError:
|
||||||
|
return None
|
||||||
|
|
||||||
def get_student_id(email):
|
def get_student_id(email):
|
||||||
"""Returns Student ID, example EDU-STU-2018-00001 from email address
|
"""Returns Student ID, example EDU-STU-2018-00001 from email address
|
||||||
|
|
||||||
:params email: email address of the student"""
|
:params email: email address of the student"""
|
||||||
try:
|
try:
|
||||||
student = frappe.get_list('Student', filters={'student_email_id': email})[0].name
|
return frappe.get_list('Student', filters={'student_email_id': email})[0].name
|
||||||
return student
|
|
||||||
except IndexError:
|
except IndexError:
|
||||||
frappe.throw("Student Account with email:{0} does not exist".format(email))
|
frappe.throw("Student Account with email:{0} does not exist".format(email))
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user