Merge pull request #534 from pateljannat/onboarding-redirects
fix: Onboarding redirects
This commit is contained in:
@@ -240,6 +240,7 @@ jinja = {
|
||||
"lms.lms.utils.show_start_learing_cta",
|
||||
"lms.lms.utils.can_create_courses",
|
||||
"lms.lms.utils.get_telemetry_boot_info",
|
||||
"lms.lms.utils.is_onboarding_complete",
|
||||
],
|
||||
"filters": [],
|
||||
}
|
||||
|
||||
@@ -714,3 +714,22 @@ def get_telemetry_boot_info():
|
||||
"posthog_project_id": frappe.conf.get(POSTHOG_PROJECT_FIELD),
|
||||
"enable_telemetry": 1,
|
||||
}
|
||||
|
||||
|
||||
def is_onboarding_complete():
|
||||
course_created = frappe.db.a_row_exists("LMS Course")
|
||||
chapter_created = frappe.db.a_row_exists("Course Chapter")
|
||||
lesson_created = frappe.db.a_row_exists("Course Lesson")
|
||||
|
||||
if course_created and chapter_created and lesson_created:
|
||||
frappe.db.set_single_value("LMS Settings", "is_onboarding_complete", 1)
|
||||
|
||||
return {
|
||||
"is_onboarded": frappe.db.get_single_value("LMS Settings", "is_onboarding_complete"),
|
||||
"course_created": course_created,
|
||||
"chapter_created": chapter_created,
|
||||
"lesson_created": lesson_created,
|
||||
"first_course": frappe.get_all("LMS Course", limit=1, order_by=None, pluck="name")[0]
|
||||
if course_created
|
||||
else None,
|
||||
}
|
||||
|
||||
@@ -1,13 +1,6 @@
|
||||
{% 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 onboarding_status = is_onboarding_complete() %}
|
||||
|
||||
{% 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 %}
|
||||
{% if has_course_moderator_role() and not onboarding_status.is_onboarded %}
|
||||
<div class="onboarding-parent">
|
||||
<div class="container">
|
||||
<div class="onboarding-skip">{{ _("Skip") }}</div>
|
||||
@@ -18,34 +11,27 @@
|
||||
{{ _("Lets start setting up your content on the LMS so that you can reclaim time and focus on growth.") }}
|
||||
</div>
|
||||
<div class="onboarding-steps">
|
||||
<a class="onboarding-steps-link" href="/courses/new-course">
|
||||
<svg class="icon icon-md">
|
||||
<use href="{% if course_created %} #icon-green-check-circled {% else %} #icon-disabled-check {% endif %}">
|
||||
<a class="onboarding-steps-link" href="/courses/new-course/edit">
|
||||
<svg class="icon icon-md mr-2">
|
||||
<use href="{% if onboarding_status.course_created %} #icon-green-check-circled {% else %} #icon-disabled-check {% endif %}">
|
||||
</use>
|
||||
</svg>
|
||||
{{ _("Create a Course") }}
|
||||
</a>
|
||||
<a class="onboarding-steps-link" {% if course_created %} href="/courses/{{ first_course }}?edit=1" {% else %} disabled {% endif %}>
|
||||
<svg class="icon icon-md">
|
||||
<use href="{% if chapter_created %} #icon-green-check-circled {% else %} #icon-disabled-check {% endif %}">
|
||||
<a class="onboarding-steps-link" {% if onboarding_status.course_created %} href="/courses/{{ onboarding_status.first_course }}/outline" {% else %} disabled {% endif %}>
|
||||
<svg class="icon icon-md mr-2">
|
||||
<use href="{% if onboarding_status.chapter_created %} #icon-green-check-circled {% else %} #icon-disabled-check {% endif %}">
|
||||
</use>
|
||||
</svg>
|
||||
{{ _("Add a Chapter") }}
|
||||
</a>
|
||||
<a class="onboarding-steps-link" {% if chapter_created %} href="/courses/{{ first_course }}?edit=1" {% endif %}>
|
||||
<svg class="icon icon-md">
|
||||
<use href="{% if lesson_created %} #icon-green-check-circled {% else %} #icon-disabled-check {% endif %}">
|
||||
<a class="onboarding-steps-link" {% if onboarding_status.chapter_created %} href="/courses/{{ onboarding_status.first_course }}/learn/1.1/edit" {% endif %}>
|
||||
<svg class="icon icon-md mr-2">
|
||||
<use href="{% if onboarding_status.lesson_created %} #icon-green-check-circled {% else %} #icon-disabled-check {% endif %}">
|
||||
</use>
|
||||
</svg>
|
||||
{{ _("Add a Lesson") }}
|
||||
</a>
|
||||
<a class="onboarding-steps-link" {% if lesson_created %} href="/quizzes/new-quiz" {% endif %}>
|
||||
<svg class="icon icon-md">
|
||||
<use href="{% if quiz_created %} #icon-green-check-circled {% else %} #icon-disabled-check {% endif %}">
|
||||
</use>
|
||||
</svg>
|
||||
{{ _("Create a Quiz") }}
|
||||
</a>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
{% endif %}
|
||||
{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
{% block page_content %}
|
||||
<main class="common-page-style">
|
||||
{{ Header() }}
|
||||
<div class="container form-width" id="course-outline" {% if course.name %} data-course="{{ course.name }}" {% endif %}>
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
{{ course.title if course and course.title else _("New Course") }}
|
||||
{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
{% block page_content %}
|
||||
<main class="common-page-style">
|
||||
{{ Header() }}
|
||||
<div class="container form-width">
|
||||
|
||||
Reference in New Issue
Block a user