2018-10-08 17:18:11 +05:30
|
|
|
from __future__ import unicode_literals
|
2018-10-17 12:41:50 +05:30
|
|
|
import erpnext.education.utils as utils
|
2018-10-08 17:18:11 +05:30
|
|
|
import frappe
|
|
|
|
|
|
|
|
|
|
|
|
def get_context(context):
|
2018-10-12 15:22:16 +05:30
|
|
|
if frappe.form_dict['course']:
|
2018-10-18 15:44:08 +05:30
|
|
|
# Save form_dict variables
|
|
|
|
program_name = frappe.form_dict["program"]
|
|
|
|
course_name = frappe.form_dict["course"]
|
|
|
|
content_name = frappe.form_dict["content"]
|
|
|
|
content_type = frappe.form_dict["type"]
|
2018-10-12 15:22:16 +05:30
|
|
|
|
2018-10-18 15:44:08 +05:30
|
|
|
# Get the required doctypes
|
|
|
|
current_course = frappe.get_doc("Course", course_name)
|
|
|
|
current_content = frappe.get_doc(content_type, content_name)
|
2018-10-12 15:22:16 +05:30
|
|
|
|
2018-10-18 15:44:08 +05:30
|
|
|
# Saving context variables for Jinja
|
2018-10-18 16:19:33 +05:30
|
|
|
context.content = current_content
|
2018-10-18 15:44:08 +05:30
|
|
|
context.course_name = course_name
|
|
|
|
context.program_name = program_name
|
|
|
|
context.content_type = content_type
|
|
|
|
context.next_content_type, context.next_content = get_next_content(content_name, content_type, current_course.get_content_info())
|
2018-10-18 18:04:28 +05:30
|
|
|
if content_type == "Quiz":
|
|
|
|
context.questions = current_content.get_questions()
|
2018-10-18 15:44:08 +05:30
|
|
|
|
|
|
|
def get_next_content(c_name, c_type, content_list):
|
|
|
|
try:
|
|
|
|
next = content_list[content_list.index([c_type, c_name]) + 1]
|
|
|
|
return next[0], next[1]
|
|
|
|
except IndexError:
|
|
|
|
return None, None
|