diff --git a/lms/hooks.py b/lms/hooks.py index a7f3b43d..a6b3e24c 100644 --- a/lms/hooks.py +++ b/lms/hooks.py @@ -63,6 +63,8 @@ after_sync = "lms.install.after_sync" after_uninstall = "lms.install.after_uninstall" +setup_wizard_requires = "assets/lms/js/setup_wizard.js" + # Desk Notifications # ------------------ # See frappe.core.notifications.get_notification_config @@ -285,4 +287,6 @@ profile_url_prefix = "/users/" signup_form_template = "lms.plugins.show_custom_signup" -on_login = "lms.overrides.user.set_country_from_ip" +on_login = "lms.overrides.user.on_login" + +on_session_creation = "lms.overrides.user.on_session_creation" diff --git a/lms/lms/doctype/lms_course_enrollment/lms_course_enrollment.js b/lms/lms/doctype/lms_course_enrollment/lms_course_enrollment.js deleted file mode 100644 index 7d8ffed3..00000000 --- a/lms/lms/doctype/lms_course_enrollment/lms_course_enrollment.js +++ /dev/null @@ -1,7 +0,0 @@ -// Copyright (c) 2021, FOSS United and contributors -// For license information, please see license.txt - -frappe.ui.form.on("LMS Course Enrollment", { - // refresh: function(frm) { - // } -}); diff --git a/lms/lms/doctype/lms_course_enrollment/lms_course_enrollment.json b/lms/lms/doctype/lms_course_enrollment/lms_course_enrollment.json deleted file mode 100644 index 71e15f73..00000000 --- a/lms/lms/doctype/lms_course_enrollment/lms_course_enrollment.json +++ /dev/null @@ -1,61 +0,0 @@ -{ - "actions": [], - "creation": "2021-03-03 11:24:08.220185", - "doctype": "DocType", - "editable_grid": 1, - "engine": "InnoDB", - "field_order": [ - "course", - "user" - ], - "fields": [ - { - "fieldname": "course", - "fieldtype": "Link", - "label": "Course", - "options": "LMS Course" - }, - { - "fieldname": "user", - "fieldtype": "Data", - "label": "User", - "options": "Email" - } - ], - "index_web_pages_for_search": 1, - "links": [], - "modified": "2021-03-05 12:59:22.973826", - "modified_by": "Administrator", - "module": "LMS", - "name": "LMS Course Enrollment", - "owner": "Administrator", - "permissions": [ - { - "create": 1, - "delete": 1, - "email": 1, - "export": 1, - "print": 1, - "read": 1, - "report": 1, - "role": "System Manager", - "share": 1, - "write": 1 - }, - { - "create": 1, - "delete": 1, - "email": 1, - "export": 1, - "print": 1, - "read": 1, - "report": 1, - "role": "Student", - "share": 1, - "write": 1 - } - ], - "sort_field": "modified", - "sort_order": "DESC", - "track_changes": 1 -} \ No newline at end of file diff --git a/lms/lms/doctype/lms_course_enrollment/lms_course_enrollment.py b/lms/lms/doctype/lms_course_enrollment/lms_course_enrollment.py deleted file mode 100644 index ffe29ea2..00000000 --- a/lms/lms/doctype/lms_course_enrollment/lms_course_enrollment.py +++ /dev/null @@ -1,9 +0,0 @@ -# Copyright (c) 2021, FOSS United and contributors -# For license information, please see license.txt - -# import frappe -from frappe.model.document import Document - - -class LMSCourseEnrollment(Document): - pass diff --git a/lms/lms/doctype/lms_course_enrollment/test_lms_course_enrollment.py b/lms/lms/doctype/lms_course_enrollment/test_lms_course_enrollment.py deleted file mode 100644 index b52ed9ca..00000000 --- a/lms/lms/doctype/lms_course_enrollment/test_lms_course_enrollment.py +++ /dev/null @@ -1,9 +0,0 @@ -# Copyright (c) 2021, FOSS United and Contributors -# See license.txt - -# import frappe -import unittest - - -class TestLMSCourseEnrollment(unittest.TestCase): - pass diff --git a/lms/lms/doctype/lms_settings/lms_settings.json b/lms/lms/doctype/lms_settings/lms_settings.json index b178e61f..3a2a3ac6 100644 --- a/lms/lms/doctype/lms_settings/lms_settings.json +++ b/lms/lms/doctype/lms_settings/lms_settings.json @@ -7,6 +7,7 @@ "field_order": [ "search_placeholder", "portal_course_creation", + "is_onboarding_complete", "column_break_2", "custom_certificate_template", "livecode_url", @@ -137,12 +138,19 @@ "fieldtype": "Link", "label": "Custom Certificate Template", "options": "Web Template" + }, + { + "default": "0", + "fieldname": "is_onboarding_complete", + "fieldtype": "Check", + "label": "Is Onboarding Complete", + "read_only": 1 } ], "index_web_pages_for_search": 1, "issingle": 1, "links": [], - "modified": "2022-12-15 10:23:08.638117", + "modified": "2022-12-20 11:44:06.317159", "modified_by": "Administrator", "module": "LMS", "name": "LMS Settings", diff --git a/lms/lms/md.py b/lms/lms/md.py index e7830722..1a6b9ed7 100644 --- a/lms/lms/md.py +++ b/lms/lms/md.py @@ -114,7 +114,7 @@ def sanitize_html(html, macro): any broken tags. This makes sures that all those things are fixed before passing to the etree parser. """ - soup = BeautifulSoup(html, features="html5lib") + soup = BeautifulSoup(html, features="lxml") nodes = soup.body.children classname = "" if macro == "YouTubeVideo": diff --git a/lms/lms/doctype/lms_course_enrollment/__init__.py b/lms/lms/page/__init__.py similarity index 100% rename from lms/lms/doctype/lms_course_enrollment/__init__.py rename to lms/lms/page/__init__.py diff --git a/lms/lms/page/lms_home/__init__.py b/lms/lms/page/lms_home/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/lms/lms/page/lms_home/lms_home.js b/lms/lms/page/lms_home/lms_home.js new file mode 100644 index 00000000..4521b64d --- /dev/null +++ b/lms/lms/page/lms_home/lms_home.js @@ -0,0 +1,3 @@ +frappe.pages["lms-home"].on_page_load = function (wrapper) { + window.location.href = "/courses"; +}; diff --git a/lms/lms/page/lms_home/lms_home.json b/lms/lms/page/lms_home/lms_home.json new file mode 100644 index 00000000..f38e3502 --- /dev/null +++ b/lms/lms/page/lms_home/lms_home.json @@ -0,0 +1,19 @@ +{ + "content": null, + "creation": "2022-12-15 13:45:06.602567", + "docstatus": 0, + "doctype": "Page", + "idx": 0, + "modified": "2022-12-15 13:45:06.602567", + "modified_by": "Administrator", + "module": "LMS", + "name": "lms-home", + "owner": "Administrator", + "page_name": "lms-home", + "roles": [], + "script": null, + "standard": "Yes", + "style": null, + "system_page": 1, + "title": "LMS" +} \ No newline at end of file diff --git a/lms/lms/web_template/course_cards/course_cards.html b/lms/lms/web_template/course_cards/course_cards.html index 7d8dc4f1..16aa2b8f 100644 --- a/lms/lms/web_template/course_cards/course_cards.html +++ b/lms/lms/web_template/course_cards/course_cards.html @@ -1,5 +1,4 @@
- {% include "public/icons/symbol-defs.svg" %}

{{ _(title) }}

{% if subtitle %}

{{ _(subtitle) }}

diff --git a/lms/overrides/user.py b/lms/overrides/user.py index 6e5051c5..72dbd5ab 100644 --- a/lms/overrides/user.py +++ b/lms/overrides/user.py @@ -8,7 +8,6 @@ from frappe import _ from frappe.core.doctype.user.user import User from frappe.utils import cint, escape_html, random_string from frappe.website.utils import is_signup_disabled - from lms.lms.utils import validate_image from lms.widgets import Widgets @@ -295,6 +294,14 @@ def get_country_code(): return +def on_login(login_manager): + set_country_from_ip() + + +def on_session_creation(login_manager): + frappe.local.response["home_page"] = "/courses" + + @frappe.whitelist(allow_guest=True) def search_users(start=0, text=""): or_filters = get_or_filters(text) diff --git a/lms/patches.txt b/lms/patches.txt index 2f4e6bbc..275ee47a 100644 --- a/lms/patches.txt +++ b/lms/patches.txt @@ -42,3 +42,4 @@ lms.patches.v0_0.quiz_submission_result lms.patches.v0_0.skill_to_user_skill lms.patches.v0_0.rename_instructor_role lms.patches.v0_0.change_course_creation_settings #12-12-2022 +lms.patches.v0_0.check_onboarding_status #21-12-2022 diff --git a/lms/patches/v0_0/check_onboarding_status.py b/lms/patches/v0_0/check_onboarding_status.py new file mode 100644 index 00000000..c1686819 --- /dev/null +++ b/lms/patches/v0_0/check_onboarding_status.py @@ -0,0 +1,11 @@ +import frappe + + +def execute(): + if ( + frappe.db.count("LMS Course") + and frappe.db.count("Course Chapter") + and frappe.db.count("Course Lesson") + and frappe.db.count("LMS Quiz") + ): + frappe.db.set_value("LMS Settings", None, "is_onboarding_complete", True) diff --git a/lms/public/css/style.css b/lms/public/css/style.css index 6445ae04..1f9ea4ac 100644 --- a/lms/public/css/style.css +++ b/lms/public/css/style.css @@ -130,6 +130,10 @@ input[type=checkbox] { stroke: none; } +.onboarding-parent .icon { + stroke: none; +} + .course-card-content { padding: 1rem; display: flex; @@ -1883,3 +1887,34 @@ select { .clickable-row { cursor: pointer; } + +.onboarding-parent { + background-color: var(--primary-light); + padding: 2rem 0; +} + +.onboarding-steps { + display: flex; + justify-content: space-between; + padding-top: 1.5rem; + font-weight: 500; + color: var(--gray-900); +} + +.onboarding-steps-link { + display: flex; + align-items: center; + color: inherit; +} + +.onboarding-steps-link:hover { + text-decoration: none; + color: inherit; +} + +.onboarding-skip { + font-size: var(--text-sm); + float: right; + cursor: pointer; + margin-right: 1rem; +} diff --git a/lms/public/icons/symbol-defs.svg b/lms/public/icons/symbol-defs.svg index 17af9ab2..4e249cdf 100644 --- a/lms/public/icons/symbol-defs.svg +++ b/lms/public/icons/symbol-defs.svg @@ -64,4 +64,12 @@ + + + + + + + + diff --git a/lms/public/js/setup_wizard.js b/lms/public/js/setup_wizard.js new file mode 100644 index 00000000..e6f362bf --- /dev/null +++ b/lms/public/js/setup_wizard.js @@ -0,0 +1,5 @@ +frappe.provide("lms.setup"); + +// redirect to desk page 'lms' after setup wizard is complete +// 'lms' desk page redirects to '/courses' +frappe.setup.welcome_page = "/app/lms-home"; diff --git a/lms/templates/lms_base.html b/lms/templates/lms_base.html new file mode 100644 index 00000000..a37775ad --- /dev/null +++ b/lms/templates/lms_base.html @@ -0,0 +1,10 @@ +{% extends "templates/base.html" %} + + +{% block content %} + {% include "public/icons/symbol-defs.svg" %} + {% include "lms/templates/onboarding_header.html" %} + {% block page_content %} + Hello, world! + {% endblock %} +{% endblock %} diff --git a/lms/templates/onboarding_header.html b/lms/templates/onboarding_header.html new file mode 100644 index 00000000..362349c5 --- /dev/null +++ b/lms/templates/onboarding_header.html @@ -0,0 +1,77 @@ +{% set onboarding_settings = frappe.db.get_single_value("LMS Settings", "is_onboarding_complete") %} +{% set course_created = frappe.db.count("LMS Course") %} +{% set chapter_created = frappe.db.count("Course Chapter") %} +{% set lesson_created = frappe.db.count("Course Lesson") %} +{% set quiz_created = frappe.db.count("LMS Quiz") %} +{% set first_course = frappe.db.get_all("LMS Course", order_by="creation", pluck="name")[0] %} + +{% set is_onboarding_complete = onboarding_settings or (course_created and chapter_created and lesson_created and quiz_created) %} + +{% if has_course_moderator_role() and not is_onboarding_complete %} +
+
+
{{ _("Skip") }}
+

{{ _("Welcome") }} 🎉

+
+ {{ _("Lets start setting up your content on the LMS so that you can reclaim time and focus on growth.") }} +
+ + +
+
+{% endif %} + + diff --git a/lms/www/batch/learn.html b/lms/www/batch/learn.html index 4987bbca..19cd430d 100644 --- a/lms/www/batch/learn.html +++ b/lms/www/batch/learn.html @@ -1,29 +1,26 @@ -{% extends "templates/base.html" %} +{% extends "lms/templates/lms_base.html" %} {% from "www/macros/livecode.html" import LiveCodeEditorJS, LiveCodeEditor with context %} -{% block title %} +{% block title %} {% if lesson.title %} {{ lesson.title }} - {{ course.title }} {% else %} {{ _("New Lesson") }} {% endif %} - {% endblock %} {% block head_include %} -{% include "public/icons/symbol-defs.svg" %} {% for ext in page_extensions %} {{ ext.render_header() }} {% endfor %} - {% endblock %} -{% block content %} +{% block page_content %}
{{ BreadCrumb(course, lesson) }} diff --git a/lms/www/batch/quiz.html b/lms/www/batch/quiz.html index 26a2ca7f..12309243 100644 --- a/lms/www/batch/quiz.html +++ b/lms/www/batch/quiz.html @@ -4,11 +4,6 @@ {% endblock %} -{% block head_include %} - {% include "public/icons/symbol-defs.svg" %} -{% endblock %} - - {% block content %}
diff --git a/lms/www/batch/quiz_list.html b/lms/www/batch/quiz_list.html index eecd28c8..b6f4fe3e 100644 --- a/lms/www/batch/quiz_list.html +++ b/lms/www/batch/quiz_list.html @@ -4,11 +4,6 @@ {% endblock %} -{% block head_include %} - {% include "public/icons/symbol-defs.svg" %} -{% endblock %} - - {% block content %}
diff --git a/lms/www/classes/class.html b/lms/www/classes/class.html index 7362d35c..fad13613 100644 --- a/lms/www/classes/class.html +++ b/lms/www/classes/class.html @@ -1,10 +1,10 @@ -{% extends "templates/base.html" %} +{% extends "lms/templates/lms_base.html" %} {% block title %} {{ _(class_info.title) }} {% endblock %} -{% block content %} +{% block page_content %}
{{ BreadCrumb(class_info) }} diff --git a/lms/www/classes/index.html b/lms/www/classes/index.html index 4f20a534..22684ef4 100644 --- a/lms/www/classes/index.html +++ b/lms/www/classes/index.html @@ -1,9 +1,9 @@ -{% extends "templates/base.html" %} +{% extends "lms/templates/lms_base.html" %} {% block title %} {{ _("All Classes") }} {% endblock %} -{% block content %} +{% block page_content %}
{% if has_course_moderator_role() %} diff --git a/lms/www/classes/progress.html b/lms/www/classes/progress.html index 094b5736..3eec51ef 100644 --- a/lms/www/classes/progress.html +++ b/lms/www/classes/progress.html @@ -1,15 +1,10 @@ -{% extends "templates/base.html" %} +{% extends "lms/templates/lms_base.html" %} {% block title %} {{ student.first_name }} 's {{ _("Progress") }} {% endblock %} -{% block head_include %} - {% include "public/icons/symbol-defs.svg" %} -{% endblock %} - - -{% block content %} +{% block page_content %}
{{ BreadCrumb(class_info, student) }} diff --git a/lms/www/community/index.html b/lms/www/community/index.html index f073a39e..3c30bffc 100644 --- a/lms/www/community/index.html +++ b/lms/www/community/index.html @@ -1,35 +1,44 @@ -{% extends "templates/base.html" %} -{% block title %}{{ _('Community') }}{% endblock %} +{% extends "lms/templates/lms_base.html" %} +{% block title %} +{{ _('Community') }} +{% endblock %} -{% block content %} + +{% block page_content %}
-
+
- + +
{{ _("People") }}
-
{{ _("Community") }}
+
+ × +
+ +
+
+
+ {{ _("No results found") }} +
+
+ {{ _("Try some other keyword or explore our community") }} +
+
+
-
- × -
- -
-
-
{{ _("No results found") }}
-
{{ _("Try some other keyword or explore our community") }}
-
-
+
+ {% for user in users %} + {{ widgets.MemberCard(member=user, show_course_count=False, avatar_class="avatar-large") }} + {% endfor %} +
-
- {% for user in users %} - {{ widgets.MemberCard(member=user, show_course_count=False, avatar_class="avatar-large") }} - {% endfor %} -
- {% if user_count > user_details | length %} -
-
{{ _("Load More") }}
-
- {% endif %} -
+ {% if user_count > user_details | length %} +
+
+ {{ _("Load More") }} +
+
+ {% endif %} +
{% endblock %} diff --git a/lms/www/courses/course.html b/lms/www/courses/course.html index 7b28e66e..98d1e165 100644 --- a/lms/www/courses/course.html +++ b/lms/www/courses/course.html @@ -1,15 +1,10 @@ -{% extends "templates/base.html" %} +{% extends "lms/templates/lms_base.html" %} {% block title %} {{ course.title if course.title else _("New Course") }} {% endblock %} -{% block head_include %} - {% include "public/icons/symbol-defs.svg" %} -{% endblock %} - - -{% block content %} +{% block page_content %}
{{ CourseHomeHeader(course) }} diff --git a/lms/www/courses/index.html b/lms/www/courses/index.html index 4940c100..1d618468 100644 --- a/lms/www/courses/index.html +++ b/lms/www/courses/index.html @@ -1,4 +1,4 @@ -{% extends "templates/base.html" %} +{% extends "lms/templates/lms_base.html" %} {% block title %} @@ -6,12 +6,7 @@ {% endblock %} -{% block head_include %} -{% include "public/icons/symbol-defs.svg" %} -{% endblock %} - - -{% block content %} +{% block page_content %}
{% if restriction %} diff --git a/lms/www/jobs/index.html b/lms/www/jobs/index.html index d1b448fa..1c464a59 100644 --- a/lms/www/jobs/index.html +++ b/lms/www/jobs/index.html @@ -1,11 +1,8 @@ -{% extends "templates/base.html" %} +{% extends "lms/templates/lms_base.html" %} {% block title %}{{ _('Job Openings') }}{% endblock %} -{% block head_include %} -{% include "public/icons/symbol-defs.svg" %} -{% endblock %} -{% block content %} +{% block page_content %}
diff --git a/lms/www/jobs/job.html b/lms/www/jobs/job.html index b64a0962..04d0c267 100644 --- a/lms/www/jobs/job.html +++ b/lms/www/jobs/job.html @@ -1,11 +1,8 @@ -{% extends "templates/base.html" %} +{% extends "lms/templates/lms_base.html" %} {% block title %}{{ _(job.job_title) }}{% endblock %} -{% block head_include %} -{% include "public/icons/symbol-defs.svg" %} -{% endblock %} -{% block content %} +{% block page_content %}
diff --git a/lms/www/profiles/profile.html b/lms/www/profiles/profile.html index e355db95..fbac9736 100644 --- a/lms/www/profiles/profile.html +++ b/lms/www/profiles/profile.html @@ -205,9 +205,9 @@
{{ _("Role Settings") }}