refactor: renamed app to school

This commit is contained in:
Jannat Patel
2021-10-11 20:31:27 +05:30
parent 13022e0bcc
commit d07dbcc50a
466 changed files with 2497 additions and 146 deletions

35
school/www/batch/utils.py Normal file
View File

@@ -0,0 +1,35 @@
import frappe
from school.lms.models import Course
def get_common_context(context):
context.no_cache = 1
course_name = frappe.form_dict["course"]
try:
batch_name = frappe.form_dict["batch"]
except KeyError:
batch_name = None
course = frappe.get_doc("LMS Course", course_name)
if not course:
context.template = "www/404.html"
return
context.course = course
context.lessons = course.get_lessons()
membership = course.get_membership(frappe.session.user, batch_name)
context.membership = membership
if membership:
batch = course.get_batch(membership.batch)
if batch:
context.batch = batch
context.course.query_parameter = "?batch=" + membership.batch if membership and membership.batch else ""
context.livecode_url = get_livecode_url()
def get_livecode_url():
return frappe.db.get_single_value("LMS Settings", "livecode_url")
def redirect_to_lesson(course, index_="1.1"):
frappe.local.flags.redirect_location = course.get_learn_url(index_) + course.query_parameter
raise frappe.Redirect