refactor: added lesson to exercise
usualy to know which lesson an exercise is part of by looking at the exercise.
This commit is contained in:
@@ -14,7 +14,8 @@
|
|||||||
"course",
|
"course",
|
||||||
"hints",
|
"hints",
|
||||||
"tests",
|
"tests",
|
||||||
"image"
|
"image",
|
||||||
|
"lesson"
|
||||||
],
|
],
|
||||||
"fields": [
|
"fields": [
|
||||||
{
|
{
|
||||||
@@ -32,7 +33,7 @@
|
|||||||
{
|
{
|
||||||
"columns": 4,
|
"columns": 4,
|
||||||
"fieldname": "description",
|
"fieldname": "description",
|
||||||
"fieldtype": "Markdown Editor",
|
"fieldtype": "Small Text",
|
||||||
"in_list_view": 1,
|
"in_list_view": 1,
|
||||||
"label": "Description"
|
"label": "Description"
|
||||||
},
|
},
|
||||||
@@ -54,7 +55,7 @@
|
|||||||
{
|
{
|
||||||
"columns": 4,
|
"columns": 4,
|
||||||
"fieldname": "hints",
|
"fieldname": "hints",
|
||||||
"fieldtype": "Markdown Editor",
|
"fieldtype": "Small Text",
|
||||||
"label": "Hints"
|
"label": "Hints"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -68,11 +69,17 @@
|
|||||||
"fieldtype": "Code",
|
"fieldtype": "Code",
|
||||||
"label": "Image",
|
"label": "Image",
|
||||||
"read_only": 1
|
"read_only": 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "lesson",
|
||||||
|
"fieldtype": "Link",
|
||||||
|
"label": "Lesson",
|
||||||
|
"options": "Lesson"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"index_web_pages_for_search": 1,
|
"index_web_pages_for_search": 1,
|
||||||
"links": [],
|
"links": [],
|
||||||
"modified": "2021-05-19 18:27:40.475515",
|
"modified": "2021-05-20 13:23:12.340928",
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"module": "LMS",
|
"module": "LMS",
|
||||||
"name": "Exercise",
|
"name": "Exercise",
|
||||||
|
|||||||
@@ -11,6 +11,11 @@ class Lesson(Document):
|
|||||||
def before_save(self):
|
def before_save(self):
|
||||||
sections = SectionParser().parse(self.body or "")
|
sections = SectionParser().parse(self.body or "")
|
||||||
self.sections = [self.make_lms_section(i, s) for i, s in enumerate(sections)]
|
self.sections = [self.make_lms_section(i, s) for i, s in enumerate(sections)]
|
||||||
|
for s in self.sections:
|
||||||
|
if s.type == "exercise":
|
||||||
|
e = s.get_exercise()
|
||||||
|
e.lesson = self.name
|
||||||
|
e.save()
|
||||||
|
|
||||||
def get_sections(self):
|
def get_sections(self):
|
||||||
return sorted(self.get('sections'), key=lambda s: s.index)
|
return sorted(self.get('sections'), key=lambda s: s.index)
|
||||||
|
|||||||
Reference in New Issue
Block a user