From 66afd0fcddc1c5aa21c6356695a1d20f0dfd4b4b Mon Sep 17 00:00:00 2001 From: pateljannat Date: Thu, 30 Sep 2021 16:20:44 +0530 Subject: [PATCH 1/2] fix: remove unused doctype --- community/patches.txt | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/community/patches.txt b/community/patches.txt index 0ab8479a..f57a0b6e 100644 --- a/community/patches.txt +++ b/community/patches.txt @@ -12,3 +12,8 @@ community.patches.v0_0.course_instructor_update execute:frappe.delete_doc("DocType", "Discussion Message") execute:frappe.delete_doc("DocType", "Discussion Thread") community.patches.v0_0.rename_chapters_and_lessons_doctype +execute:frappe.delete_doc("DocType", "Chapters") +execute:frappe.delete_doc("DocType", "Lessons") +execute:frappe.delete_doc("DocType", "Chapter") +execute:frappe.delete_doc("DocType", "Lesson") +execute:frappe.delete_doc("DocType", "LMS Topic") From c717b3ba9d652403c2e59fd2bc4e03da1ba70afa Mon Sep 17 00:00:00 2001 From: pateljannat Date: Thu, 30 Sep 2021 17:54:59 +0530 Subject: [PATCH 2/2] fix: removed unused folders --- community/lms/doctype/chapter/__init__.py | 0 community/lms/doctype/chapter/chapter.js | 16 --- community/lms/doctype/chapter/chapter.json | 86 ---------------- community/lms/doctype/chapter/chapter.py | 10 -- community/lms/doctype/chapter/test_chapter.py | 10 -- community/lms/doctype/lesson/__init__.py | 0 community/lms/doctype/lesson/lesson.js | 57 ----------- community/lms/doctype/lesson/lesson.json | 97 ------------------- community/lms/doctype/lesson/lesson.py | 96 ------------------ community/lms/doctype/lesson/test_lesson.py | 10 -- 10 files changed, 382 deletions(-) delete mode 100644 community/lms/doctype/chapter/__init__.py delete mode 100644 community/lms/doctype/chapter/chapter.js delete mode 100644 community/lms/doctype/chapter/chapter.json delete mode 100644 community/lms/doctype/chapter/chapter.py delete mode 100644 community/lms/doctype/chapter/test_chapter.py delete mode 100644 community/lms/doctype/lesson/__init__.py delete mode 100644 community/lms/doctype/lesson/lesson.js delete mode 100644 community/lms/doctype/lesson/lesson.json delete mode 100644 community/lms/doctype/lesson/lesson.py delete mode 100644 community/lms/doctype/lesson/test_lesson.py diff --git a/community/lms/doctype/chapter/__init__.py b/community/lms/doctype/chapter/__init__.py deleted file mode 100644 index e69de29b..00000000 diff --git a/community/lms/doctype/chapter/chapter.js b/community/lms/doctype/chapter/chapter.js deleted file mode 100644 index 9b895f9e..00000000 --- a/community/lms/doctype/chapter/chapter.js +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright (c) 2021, FOSS United and contributors -// For license information, please see license.txt - -frappe.ui.form.on('Chapter', { - - onload: function (frm) { - frm.set_query("lesson", "lessons", function () { - return { - filters: { - "chapter": frm.doc.name, - } - }; - }); - } - -}); diff --git a/community/lms/doctype/chapter/chapter.json b/community/lms/doctype/chapter/chapter.json deleted file mode 100644 index 5e0559dd..00000000 --- a/community/lms/doctype/chapter/chapter.json +++ /dev/null @@ -1,86 +0,0 @@ -{ - "actions": [], - "allow_rename": 1, - "autoname": "format:{####} {title}", - "creation": "2021-05-03 05:49:08.383057", - "doctype": "DocType", - "editable_grid": 1, - "engine": "InnoDB", - "field_order": [ - "course", - "title", - "column_break_3", - "description", - "section_break_5", - "lessons" - ], - "fields": [ - { - "fieldname": "title", - "fieldtype": "Data", - "in_list_view": 1, - "label": "Title", - "reqd": 1 - }, - { - "fieldname": "description", - "fieldtype": "Small Text", - "label": "Description" - }, - { - "fieldname": "course", - "fieldtype": "Link", - "in_list_view": 1, - "label": "Course", - "options": "LMS Course", - "reqd": 1 - }, - { - "fieldname": "lessons", - "fieldtype": "Table", - "label": "Lessons", - "options": "Lesson Reference" - }, - { - "fieldname": "column_break_3", - "fieldtype": "Column Break" - }, - { - "fieldname": "section_break_5", - "fieldtype": "Section Break" - } - ], - "index_web_pages_for_search": 1, - "links": [ - { - "group": "Lessons", - "link_doctype": "Lesson", - "link_fieldname": "chapter" - } - ], - "modified": "2021-09-20 10:58:47.241660", - "modified_by": "Administrator", - "module": "LMS", - "name": "Chapter", - "naming_rule": "Expression", - "owner": "Administrator", - "permissions": [ - { - "create": 1, - "delete": 1, - "email": 1, - "export": 1, - "print": 1, - "read": 1, - "report": 1, - "role": "System Manager", - "share": 1, - "write": 1 - } - ], - "search_fields": "title", - "sort_field": "modified", - "sort_order": "DESC", - "title_field": "title", - "track_changes": 1 -} diff --git a/community/lms/doctype/chapter/chapter.py b/community/lms/doctype/chapter/chapter.py deleted file mode 100644 index 8e0f3f82..00000000 --- a/community/lms/doctype/chapter/chapter.py +++ /dev/null @@ -1,10 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright (c) 2021, FOSS United and contributors -# For license information, please see license.txt - -from __future__ import unicode_literals -import frappe -from frappe.model.document import Document - -class Chapter(Document): - pass diff --git a/community/lms/doctype/chapter/test_chapter.py b/community/lms/doctype/chapter/test_chapter.py deleted file mode 100644 index 444f741f..00000000 --- a/community/lms/doctype/chapter/test_chapter.py +++ /dev/null @@ -1,10 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright (c) 2021, FOSS United and Contributors -# See license.txt -from __future__ import unicode_literals - -# import frappe -import unittest - -class TestChapter(unittest.TestCase): - pass diff --git a/community/lms/doctype/lesson/__init__.py b/community/lms/doctype/lesson/__init__.py deleted file mode 100644 index e69de29b..00000000 diff --git a/community/lms/doctype/lesson/lesson.js b/community/lms/doctype/lesson/lesson.js deleted file mode 100644 index 43a11795..00000000 --- a/community/lms/doctype/lesson/lesson.js +++ /dev/null @@ -1,57 +0,0 @@ -// Copyright (c) 2021, FOSS United and contributors -// For license information, please see license.txt - -frappe.ui.form.on('Lesson', { - setup: function (frm) { - frm.trigger('setup_help'); - }, - setup_help(frm) { - frm.get_field('help').html(` -

You can add some more additional content to the lesson using a special syntax. The table below mentions all types of dynamic content that you can add to the lessons and the syntax for the same.

-
-
- Content Type -
-
- Syntax -
-
- -
-
- Video -
-
- {{ Video("url_of_source") }} -
-
- -
-
- YouTube Video -
-
- {{ YouTubeVideo("unique_embed_id") }} -
-
- -
-
- Exercise -
-
- {{ Exercise("exercise_name") }} -
-
- -
-
- Quiz -
-
- {{ Quiz("lms_quiz_name") }} -
-
-`); - } -}); diff --git a/community/lms/doctype/lesson/lesson.json b/community/lms/doctype/lesson/lesson.json deleted file mode 100644 index 84ca8120..00000000 --- a/community/lms/doctype/lesson/lesson.json +++ /dev/null @@ -1,97 +0,0 @@ -{ - "actions": [], - "allow_rename": 1, - "autoname": "format:{####} {title}", - "creation": "2021-05-03 06:21:12.995987", - "doctype": "DocType", - "editable_grid": 1, - "engine": "InnoDB", - "field_order": [ - "chapter", - "include_in_preview", - "column_break_4", - "title", - "index_label", - "section_break_6", - "body", - "help_section", - "help" - ], - "fields": [ - { - "fieldname": "chapter", - "fieldtype": "Link", - "in_list_view": 1, - "label": "Chapter", - "options": "Chapter", - "reqd": 1 - }, - { - "fieldname": "title", - "fieldtype": "Data", - "in_list_view": 1, - "label": "Title", - "reqd": 1 - }, - { - "fieldname": "body", - "fieldtype": "Markdown Editor", - "label": "Body", - "reqd": 1 - }, - { - "fieldname": "index_label", - "fieldtype": "Data", - "label": "Index Label", - "read_only": 1 - }, - { - "default": "0", - "fieldname": "include_in_preview", - "fieldtype": "Check", - "label": "Include In Preview" - }, - { - "fieldname": "section_break_6", - "fieldtype": "Section Break" - }, - { - "fieldname": "column_break_4", - "fieldtype": "Column Break" - }, - { - "fieldname": "help_section", - "fieldtype": "Section Break", - "label": "Help" - }, - { - "fieldname": "help", - "fieldtype": "HTML" - } - ], - "index_web_pages_for_search": 1, - "links": [], - "modified": "2021-09-20 10:52:29.116536", - "modified_by": "Administrator", - "module": "LMS", - "name": "Lesson", - "naming_rule": "Expression", - "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", - "track_changes": 1 -} \ No newline at end of file diff --git a/community/lms/doctype/lesson/lesson.py b/community/lms/doctype/lesson/lesson.py deleted file mode 100644 index 75f00576..00000000 --- a/community/lms/doctype/lesson/lesson.py +++ /dev/null @@ -1,96 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright (c) 2021, FOSS United and contributors -# For license information, please see license.txt - -from __future__ import unicode_literals -import frappe -from frappe.model.document import Document -from ...md import markdown_to_html, find_macros - -class Lesson(Document): - def on_update(self): - dynamic_documents = ["Exercise", "Quiz"] - for section in dynamic_documents: - self.update_lesson_name_in_document(section) - - def update_lesson_name_in_document(self, section): - doctype_map= { - "Exercise": "Exercise", - "Quiz": "LMS Quiz" - } - macros = find_macros(self.body) - documents = [value for name, value in macros if name == section] - index = 1 - for name in documents: - e = frappe.get_doc(doctype_map[section], name) - e.lesson = self.name - e.index_ = index - e.save() - index += 1 - self.update_orphan_documents(doctype_map[section], documents) - - def update_orphan_documents(self, doctype, documents): - """Updates the documents that were previously part of this lesson, - but not any more. - """ - linked_documents = {row['name'] for row in frappe.get_all(doctype, {"lesson": self.name})} - active_documents = set(documents) - orphan_documents = linked_documents - active_documents - for name in orphan_documents: - ex = frappe.get_doc(doctype, name) - ex.lesson = None - ex.index_ = 0 - ex.index_label = "" - ex.save() - - def render_html(self): - return markdown_to_html(self.body) - - def get_exercises(self): - if not self.body: - return [] - - macros = find_macros(self.body) - exercises = [value for name, value in macros if name == "Exercise"] - return [frappe.get_doc("Exercise", name) for name in exercises] - - def get_progress(self): - return frappe.db.get_value("LMS Course Progress", - {"lesson": self.name, "owner": frappe.session.user}, "status") - - def get_slugified_class(self): - if self.get_progress(): - return ("").join([ s for s in self.get_progress().lower().split() ]) - return - -@frappe.whitelist() -def save_progress(lesson, course, status): - if not frappe.db.exists("LMS Batch Membership", - { - "member": frappe.session.user, - "course": course - }): - return - - if frappe.db.exists("LMS Course Progress", - { - "lesson": lesson, - "owner": frappe.session.user, - "course": course - }): - doc = frappe.get_doc("LMS Course Progress", - { - "lesson": lesson, - "owner": frappe.session.user, - "course": course - }) - doc.status = status - doc.save(ignore_permissions=True) - else: - frappe.get_doc({ - "doctype": "LMS Course Progress", - "lesson": lesson, - "status": status, - }).save(ignore_permissions=True) - course_details = frappe.get_doc("LMS Course", course) - return course_details.get_course_progress() diff --git a/community/lms/doctype/lesson/test_lesson.py b/community/lms/doctype/lesson/test_lesson.py deleted file mode 100644 index 86c86ba2..00000000 --- a/community/lms/doctype/lesson/test_lesson.py +++ /dev/null @@ -1,10 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright (c) 2021, FOSS United and Contributors -# See license.txt -from __future__ import unicode_literals - -# import frappe -import unittest - -class TestLesson(unittest.TestCase): - pass