feat: lesson assignment
This commit is contained in:
@@ -8,6 +8,9 @@ from frappe.model.document import Document
|
||||
from ...md import markdown_to_html, find_macros
|
||||
|
||||
class CourseLesson(Document):
|
||||
def validate(self):
|
||||
self.check_and_create_folder()
|
||||
|
||||
def on_update(self):
|
||||
dynamic_documents = ["Exercise", "Quiz"]
|
||||
for section in dynamic_documents:
|
||||
@@ -43,8 +46,18 @@ class CourseLesson(Document):
|
||||
ex.index_label = ""
|
||||
ex.save()
|
||||
|
||||
def check_and_create_folder(self):
|
||||
course = frappe.db.get_value("Chapter", self.chapter, "course")
|
||||
args = {
|
||||
"doctype": "File",
|
||||
"is_folder": True,
|
||||
"file_name": f"{self.name} {course}"
|
||||
}
|
||||
if not frappe.db.exists(args):
|
||||
folder = frappe.get_doc(args)
|
||||
folder.save(ignore_permissions=True)
|
||||
|
||||
def render_html(self):
|
||||
print(self.body)
|
||||
return markdown_to_html(self.body)
|
||||
|
||||
def get_exercises(self):
|
||||
|
||||
0
school/lms/doctype/lesson_assignment/__init__.py
Normal file
0
school/lms/doctype/lesson_assignment/__init__.py
Normal file
@@ -0,0 +1,8 @@
|
||||
// Copyright (c) 2021, Frappe and contributors
|
||||
// For license information, please see license.txt
|
||||
|
||||
frappe.ui.form.on('Lesson Assignment', {
|
||||
// refresh: function(frm) {
|
||||
|
||||
// }
|
||||
});
|
||||
70
school/lms/doctype/lesson_assignment/lesson_assignment.json
Normal file
70
school/lms/doctype/lesson_assignment/lesson_assignment.json
Normal file
@@ -0,0 +1,70 @@
|
||||
{
|
||||
"actions": [],
|
||||
"allow_rename": 1,
|
||||
"creation": "2021-12-21 16:15:22.651658",
|
||||
"doctype": "DocType",
|
||||
"editable_grid": 1,
|
||||
"engine": "InnoDB",
|
||||
"field_order": [
|
||||
"lesson",
|
||||
"user",
|
||||
"column_break_3",
|
||||
"assignment",
|
||||
"id"
|
||||
],
|
||||
"fields": [
|
||||
{
|
||||
"fieldname": "lesson",
|
||||
"fieldtype": "Link",
|
||||
"in_list_view": 1,
|
||||
"in_standard_filter": 1,
|
||||
"label": "Lesson",
|
||||
"options": "Course Lesson"
|
||||
},
|
||||
{
|
||||
"fieldname": "user",
|
||||
"fieldtype": "Link",
|
||||
"in_list_view": 1,
|
||||
"in_standard_filter": 1,
|
||||
"label": "User",
|
||||
"options": "User"
|
||||
},
|
||||
{
|
||||
"fieldname": "column_break_3",
|
||||
"fieldtype": "Column Break"
|
||||
},
|
||||
{
|
||||
"fieldname": "id",
|
||||
"fieldtype": "Data",
|
||||
"label": "ID"
|
||||
},
|
||||
{
|
||||
"fieldname": "assignment",
|
||||
"fieldtype": "Attach",
|
||||
"label": "Assignment"
|
||||
}
|
||||
],
|
||||
"index_web_pages_for_search": 1,
|
||||
"links": [],
|
||||
"modified": "2021-12-22 11:17:08.390615",
|
||||
"modified_by": "Administrator",
|
||||
"module": "LMS",
|
||||
"name": "Lesson Assignment",
|
||||
"owner": "Administrator",
|
||||
"permissions": [
|
||||
{
|
||||
"create": 1,
|
||||
"delete": 1,
|
||||
"email": 1,
|
||||
"export": 1,
|
||||
"print": 1,
|
||||
"read": 1,
|
||||
"report": 1,
|
||||
"role": "System Manager",
|
||||
"share": 1,
|
||||
"write": 1
|
||||
}
|
||||
],
|
||||
"sort_field": "modified",
|
||||
"sort_order": "DESC"
|
||||
}
|
||||
35
school/lms/doctype/lesson_assignment/lesson_assignment.py
Normal file
35
school/lms/doctype/lesson_assignment/lesson_assignment.py
Normal file
@@ -0,0 +1,35 @@
|
||||
# Copyright (c) 2021, Frappe and contributors
|
||||
# For license information, please see license.txt
|
||||
|
||||
import frappe
|
||||
from frappe.model.document import Document
|
||||
from frappe.handler import upload_file
|
||||
|
||||
class LessonAssignment(Document):
|
||||
pass
|
||||
|
||||
@frappe.whitelist()
|
||||
def upload_assignment(assignment, lesson, identifier):
|
||||
lesson_work = frappe.get_doc({
|
||||
"doctype": "Lesson Assignment",
|
||||
"lesson": lesson,
|
||||
"user": frappe.session.user,
|
||||
"assignment": assignment,
|
||||
"id": identifier
|
||||
})
|
||||
lesson_work.save(ignore_permissions=True)
|
||||
return lesson_work.name
|
||||
|
||||
@frappe.whitelist()
|
||||
def get_assignment(lesson):
|
||||
assignments = frappe.get_all("Lesson Assignment",
|
||||
{
|
||||
"lesson": lesson,
|
||||
"user": frappe.session.user
|
||||
},
|
||||
["lesson", "user", "id", "assignment"])
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
# Copyright (c) 2021, Frappe and Contributors
|
||||
# See license.txt
|
||||
|
||||
# import frappe
|
||||
import unittest
|
||||
|
||||
class TestLessonAssignment(unittest.TestCase):
|
||||
pass
|
||||
Reference in New Issue
Block a user