diff --git a/lms/hooks.py b/lms/hooks.py index c9078ef3..8e07bec6 100644 --- a/lms/hooks.py +++ b/lms/hooks.py @@ -144,6 +144,10 @@ website_route_rules = [ "from_route": "/courses//learn/.", "to_route": "batch/learn", }, + { + "from_route": "/courses//learn/./edit", + "to_route": "batch/edit", + }, {"from_route": "/quizzes", "to_route": "batch/quiz_list"}, {"from_route": "/quizzes/", "to_route": "batch/quiz"}, {"from_route": "/classes/", "to_route": "classes/class"}, diff --git a/lms/lms/md.py b/lms/lms/md.py index 1a6b9ed7..770f556d 100644 --- a/lms/lms/md.py +++ b/lms/lms/md.py @@ -42,6 +42,7 @@ def find_macros(text): if not text: return [] macros = re.findall(MACRO_RE, text) + print(macros) # remove the quotes around the argument return [(name, _remove_quotes(arg)) for name, arg in macros] diff --git a/lms/lms/utils.py b/lms/lms/utils.py index 3a22fbdf..8ee47043 100644 --- a/lms/lms/utils.py +++ b/lms/lms/utils.py @@ -269,6 +269,7 @@ def get_progress(course, lesson): def render_html(lesson): + print(lesson) youtube = lesson.youtube quiz_id = lesson.quiz_id body = lesson.body diff --git a/lms/plugins.py b/lms/plugins.py index cc4fb359..72c2259d 100644 --- a/lms/plugins.py +++ b/lms/plugins.py @@ -138,6 +138,7 @@ def youtube_video_renderer(video_id): def video_renderer(src): + print(src) return f"" diff --git a/lms/public/js/editor.js b/lms/public/js/editor.js new file mode 100644 index 00000000..6b30eb64 --- /dev/null +++ b/lms/public/js/editor.js @@ -0,0 +1,5 @@ +import EditorJS from "@editorjs/editorjs"; + +const editor = new EditorJS("body"); + +console.log(editor); diff --git a/lms/public/js/website.bundle.js b/lms/public/js/website.bundle.js index 7d1dfd83..51b30e76 100644 --- a/lms/public/js/website.bundle.js +++ b/lms/public/js/website.bundle.js @@ -1,3 +1,4 @@ import "./profile.js"; import "./common_functions.js"; +import "./editor.js"; import "../../../../frappe/frappe/public/js/frappe/ui/chart.js"; diff --git a/lms/www/batch/edit.html b/lms/www/batch/edit.html new file mode 100644 index 00000000..8281851a --- /dev/null +++ b/lms/www/batch/edit.html @@ -0,0 +1,25 @@ +{% extends "lms/templates/lms_base.html" %} + +{% block title %} +{% if lesson.title %} +{{ lesson.title }} - {{ course.title }} +{% else %} +{{ _("New Lesson") }} +{% endif %} +{% endblock %} + +{% block content %} +
+
+
+
+ {{ _("Title") }} +
+
+ {{ _("Something short and concise.") }} +
+ +
+
+
+{% endblock %} \ No newline at end of file diff --git a/lms/www/batch/edit.py b/lms/www/batch/edit.py new file mode 100644 index 00000000..e7199149 --- /dev/null +++ b/lms/www/batch/edit.py @@ -0,0 +1,10 @@ +import frappe +from lms.www.utils import get_current_lesson_details, get_common_context + + +def get_context(context): + get_common_context(context) + chapter_index = frappe.form_dict.get("chapter") + lesson_index = frappe.form_dict.get("lesson") + lesson_number = f"{chapter_index}.{lesson_index}" + context.lesson = get_current_lesson_details(lesson_number, context) diff --git a/lms/www/batch/learn.js b/lms/www/batch/learn.js index 1d932d58..03873329 100644 --- a/lms/www/batch/learn.js +++ b/lms/www/batch/learn.js @@ -593,7 +593,7 @@ const build_attachment_table = (file_doc) => { }; const make_editor = () => { - this.code_field_group = new frappe.ui.FieldGroup({ + /* this.code_field_group = new frappe.ui.FieldGroup({ fields: [ { fieldname: "code_md", @@ -606,7 +606,7 @@ const make_editor = () => { this.code_field_group.make(); $("#body .form-section:last").removeClass("empty-section"); $("#body .frappe-control").removeClass("hide-control"); - $("#body .form-column").addClass("p-0"); + $("#body .form-column").addClass("p-0"); */ }; const set_file_type = () => { diff --git a/lms/www/batch/learn.py b/lms/www/batch/learn.py index a076cdf8..3b37d21c 100644 --- a/lms/www/batch/learn.py +++ b/lms/www/batch/learn.py @@ -3,7 +3,11 @@ from frappe import _ from frappe.utils import cstr, flt from lms.lms.utils import get_lesson_url, has_course_moderator_role, is_instructor -from lms.www.utils import get_common_context, redirect_to_lesson +from lms.www.utils import ( + get_common_context, + redirect_to_lesson, + get_current_lesson_details, +) def get_context(context): @@ -62,20 +66,6 @@ def get_context(context): } -def get_current_lesson_details(lesson_number, context): - details_list = list(filter(lambda x: cstr(x.number) == lesson_number, context.lessons)) - - if not len(details_list): - if frappe.form_dict.get("edit"): - return None - else: - redirect_to_lesson(context.course) - - lesson_info = details_list[0] - lesson_info.body = lesson_info.body.replace('"', "'") - return lesson_info - - def get_url(lesson_number, course): return ( get_lesson_url(course.name, lesson_number) diff --git a/lms/www/utils.py b/lms/www/utils.py index 74bc6f88..0ed23bce 100644 --- a/lms/www/utils.py +++ b/lms/www/utils.py @@ -1,6 +1,7 @@ import frappe from lms.lms.utils import get_lesson_url, get_lessons, get_membership +from frappe.utils import cstr def get_common_context(context): @@ -40,3 +41,17 @@ def redirect_to_lesson(course, index_="1.1"): get_lesson_url(course.name, index_) + course.query_parameter ) raise frappe.Redirect + + +def get_current_lesson_details(lesson_number, context): + details_list = list(filter(lambda x: cstr(x.number) == lesson_number, context.lessons)) + + if not len(details_list): + if frappe.form_dict.get("edit"): + return None + else: + redirect_to_lesson(context.course) + + lesson_info = details_list[0] + lesson_info.body = lesson_info.body.replace('"', "'") + return lesson_info