Files
enlight-lms/lms/www/assignments/assignment.py
2023-05-30 22:11:14 +05:30

24 lines
611 B
Python

import frappe
from frappe import _
from lms.lms.utils import can_create_courses
def get_context(context):
context.no_cache = 1
if not can_create_courses():
message = "You do not have permission to access this page."
if frappe.session.user == "Guest":
message = "Please login to access this page."
raise frappe.PermissionError(_(message))
assignment = frappe.form_dict["assignment"]
if assignment == "new-assignment":
context.assignment = frappe._dict()
else:
context.assignment = frappe.db.get_value(
"LMS Assignment", assignment, ["title", "name", "type", "question"], as_dict=1
)