def get_contents(topic, course, program): student = utils.get_current_student() if student: 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"): if student: status = utils.check_content_completion(content.name, content.doctype, course_enrollment.name) else: status = True progress.append({"content": content, "content_type": content.doctype, "completed": status}) elif content.doctype == "Quiz": if student: status, score, result, time_taken = utils.check_quiz_completion( content, course_enrollment.name ) else: status = False score = None result = None progress.append( { "content": content, "content_type": content.doctype, "completed": status, "score": score, "result": result, } ) return progress
def get_context(context): context.education_settings = frappe.get_single("Education Settings") if not context.education_settings.enable_lms: frappe.local.flags.redirect_location = '/' raise frappe.Redirect context.featured_programs = get_featured_programs() context.student = utils.get_current_student()
def get_context(context): if frappe.session.user == "Guest": frappe.local.flags.redirect_location = "/lms" raise frappe.Redirect context.student = utils.get_current_student() if not context.student: context.student = frappe.get_doc("User", frappe.session.user) context.progress = get_program_progress(context.student.name)
def get_context(context): try: program = frappe.form_dict['program'] except KeyError: frappe.local.flags.redirect_location = '/lms' raise frappe.Redirect context.education_settings = frappe.get_single("Education Settings") context.program = get_program(program) context.courses = [ frappe.get_doc("Course", course.course) for course in context.program.courses ] context.has_access = utils.allowed_program_access(program) context.has_super_access = utils.has_super_access() context.progress = get_course_progress(context.courses, program) context.student = utils.get_current_student()
def get_contents(topic, course, program): student = utils.get_current_student() if student: course_enrollment = utils.get_or_create_course_enrollment( course, program) contents = topic.get_contents() progress = [] if contents: for content in contents: content_data = frappe.get_doc(content.doctype, content.name).as_dict() publish_date = content_data.publish_date if content_data.publish_date is not None else date.today( ) if content.doctype in ('Article', 'Video'): if student: status = utils.check_content_completion( content.name, content.doctype, course_enrollment.name) else: status = True progress.append({ 'content': content, 'content_type': content.doctype, 'completed': status, 'publish_date': publish_date }) elif content.doctype == 'Quiz': if student: status, score, result, max_points = check_quiz_completion( content, course_enrollment.name) else: status = False score = None result = None max_points = None progress.append({ 'content': content, 'content_type': content.doctype, 'completed': status, 'score': score, 'result': result, 'max_points': max_points, 'publish_date': publish_date }) return progress
def get_context(context): try: program = frappe.form_dict['program'] course_name = frappe.form_dict['name'] except KeyError: frappe.local.flags.redirect_location = '/lms' raise frappe.Redirect context.education_settings = frappe.get_single("Education Settings") course = frappe.get_doc('Course', course_name) context.program = program context.course = course context.student = utils.get_current_student() context.topics = course.get_topics() context.has_access = utils.allowed_program_access(context.program) context.has_super_access = utils.has_super_access() context.progress = get_topic_progress(context.topics, course, context.program) context.ongoing_topic = get_ongoing_topic(context.topics,context.progress) context.total_progress = utils.get_total_program_progress(context.topics, course_name, context.student)
def get_context(context): try: course = frappe.form_dict['course'] program = frappe.form_dict['program'] topic = frappe.form_dict['topic'] except KeyError: frappe.local.flags.redirect_location = '/lms' raise frappe.Redirect context.program = program context.course = course context.topic = frappe.get_doc("Topic", topic) context.student = utils.get_current_student() course_details = frappe.get_doc('Course', course) context.course_topics = course_details.get_topics() context.contents = get_contents(context.topic, course, program) context.has_access = utils.allowed_program_access(program) context.has_super_access = utils.has_super_access() context.ongoing_topic = get_ongoing_topic(context.contents) context.total_progress = utils.get_total_program_progress( context.course_topics, course, context.student) # Get all topics content_list = [] for t in context.course_topics: for topic_content in t.topic_content: content_list.append({ 'content_type': topic_content.content_type, 'content': topic_content.content }) context.length = len(content_list) context.completed_topics = utils.get_completed_topic_list(course) # Set context for progress numbers context.position = len(context.completed_topics) # Set context for navigation context.previous = utils.get_previous_content(content_list, context.position) context.next = utils.get_next_content(content_list, context.position - 1)
def get_contents(topic, course, program): student = utils.get_current_student() if student: 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'): if student: status = utils.check_content_completion( content.name, content.doctype, course_enrollment.name) else: status = True progress.append({ 'content': content, 'content_type': content.doctype, 'completed': status }) elif content.doctype == 'Quiz': if student: status, score, result, time_taken = utils.check_quiz_completion( content, course_enrollment.name) else: status = False score = None result = None progress.append({ 'content': content, 'content_type': content.doctype, 'completed': status, 'score': score, 'result': result }) return progress