mirror of
https://github.com/frappe/erpnext.git
synced 2026-05-21 14:09:19 +00:00
feat: added topic page
This commit is contained in:
34
erpnext/www/lms/topic.py
Normal file
34
erpnext/www/lms/topic.py
Normal file
@@ -0,0 +1,34 @@
|
||||
from __future__ import unicode_literals
|
||||
import erpnext.education.utils as utils
|
||||
import frappe
|
||||
|
||||
no_cache = 1
|
||||
|
||||
def get_context(context):
|
||||
course = frappe.form_dict['course']
|
||||
program = frappe.form_dict['program']
|
||||
topic = frappe.form_dict['topic']
|
||||
|
||||
context.program = program
|
||||
context.course = course
|
||||
context.topic = frappe.get_doc("Topic", topic)
|
||||
context.contents = get_contents(context.topic, course, program)
|
||||
context.has_access = utils.allowed_program_access(program)
|
||||
|
||||
def get_contents(topic, course, program):
|
||||
student = utils.get_current_student()
|
||||
if not student:
|
||||
return None
|
||||
course_enrollment = utils.get_or_create_course_enrollment(course, program)
|
||||
contents = topic.get_contents()
|
||||
progress = []
|
||||
if contents:
|
||||
for content in contents:
|
||||
if content.doctype in ('Article', 'Video'):
|
||||
status = utils.check_content_completion(content.name, content.doctype, course_enrollment.name)
|
||||
progress.append({'content': content, 'content_type': content.doctype, 'completed': status})
|
||||
elif content.doctype == 'Quiz':
|
||||
status, score, result = utils.check_quiz_completion(content, course_enrollment.name)
|
||||
progress.append({'content': content, 'content_type': content.doctype, 'completed': status, 'score': score, 'result': result})
|
||||
|
||||
return progress
|
||||
Reference in New Issue
Block a user