feat: learning modes
This commit is contained in:
@@ -11,7 +11,7 @@
|
||||
{% block content %}
|
||||
|
||||
<div class="container">
|
||||
{{ widgets.BatchTabs(course=course, batch=batch) }}
|
||||
{{ widgets.BatchTabs(course=course, membership=membership) }}
|
||||
<div class="messages-container mt-5">
|
||||
{{ widgets.BatchHeader(batch_name=batch.title, member_count=member_count)}}
|
||||
<ol class="messages">
|
||||
|
||||
@@ -4,5 +4,5 @@ from . import utils
|
||||
def get_context(context):
|
||||
utils.get_common_context(context)
|
||||
context.messages = context.batch.get_messages()
|
||||
if not context.batch:
|
||||
if not context.membership:
|
||||
utils.redirect_to_lesson(context.course)
|
||||
|
||||
@@ -8,15 +8,13 @@
|
||||
{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
{% set invite_link = frappe.utils.get_url() + "/courses/" + course.name + "/join?batch=" + batch.name %}
|
||||
<div class="container mt-5">
|
||||
{{ widgets.BatchTabs(course=course, batch=batch) }}
|
||||
<!-- <div>
|
||||
<h1 class="mt-5">{{ batch.title }}</h1>
|
||||
</div> -->
|
||||
{{ widgets.BatchTabs(course=course, membership=membership) }}
|
||||
<div class="course-details mt-5">
|
||||
{{ widgets.CourseOutline(course=course, batch=batch, show_link=True, show_progress=True) }}
|
||||
</div>
|
||||
|
||||
{% if batch %}
|
||||
<div class="w-25">
|
||||
<h3>Batch Schedule</h3>
|
||||
{{ widgets.RenderBatch(course=course, batch=batch) }}
|
||||
@@ -28,8 +26,9 @@
|
||||
{{ frappe.utils.md_to_html(batch.description) }}
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
{% endif %}
|
||||
{% if course.is_mentor(frappe.session.user) %}
|
||||
{% set invite_link = frappe.utils.get_url() + "/courses/" + course.name + "/join?batch=" + batch.name %}
|
||||
<div class="">
|
||||
<h3> Invite Members </h3>
|
||||
<a href="" class="" id="invite-link" data-link="{{ invite_link }}">Get Batch Invitation
|
||||
|
||||
@@ -3,5 +3,3 @@ from . import utils
|
||||
|
||||
def get_context(context):
|
||||
utils.get_common_context(context)
|
||||
if not context.batch:
|
||||
utils.redirect_to_lesson(context.course)
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
<link rel="stylesheet" href="/assets/frappe/css/hljs-night-owl.css">
|
||||
|
||||
{% for ext in page_extensions %}
|
||||
{{ ext.render_header() }}
|
||||
{{ ext.render_header() }}
|
||||
{% endfor %}
|
||||
|
||||
{% endblock %}
|
||||
@@ -22,17 +22,18 @@
|
||||
{% block content %}
|
||||
|
||||
<div class="container">
|
||||
{{ widgets.BatchTabs(course=course, batch=batch) }}
|
||||
{{ widgets.BatchTabs(course=course, membership=membership) }}
|
||||
<div class="lesson-page">
|
||||
|
||||
<h2 class="title {% if course.is_mentor(frappe.session.user) %} is_mentor {% endif %}" data-name="{{ lesson.name }}" {% if batch %} data-batch="{{ batch.name }}" {% endif %}>{{ lesson.title }}</h2>
|
||||
<h2 class="title {% if course.is_mentor(frappe.session.user) %} is_mentor {% endif %}" data-name="{{ lesson.name }}"
|
||||
{% if batch %} data-batch="{{ batch.name }}" {% endif %}>{{ lesson.title }}</h2>
|
||||
|
||||
{% if batch or lesson.include_in_preview %}
|
||||
{% if membership or lesson.include_in_preview %}
|
||||
{{ lesson.render_html() }}
|
||||
{% else %}
|
||||
<div class="no-preview-message">
|
||||
<span>This lesson is not available for Preview. Please join a batch to access the complete course.</span>
|
||||
<a href="/courses/{{ course.name }}">Checkout Upcoming Batches</a>
|
||||
<span>This lesson is not available for Preview. Please join the course to access this lesson.</span>
|
||||
<a href="/courses/{{ course.name }}">Checkout Course Details.</a>
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
@@ -61,7 +62,26 @@
|
||||
{%- block script %}
|
||||
{{ super() }}
|
||||
{% for ext in page_extensions %}
|
||||
{{ ext.render_footer() }}
|
||||
{{ ext.render_footer() }}
|
||||
{% endfor %}
|
||||
|
||||
<script>
|
||||
var membership = {{ membership }};
|
||||
var is_mentor = {{ course.is_mentor(frappe.session.user) }};
|
||||
console.log(is_mentor)
|
||||
if (membership && !is_mentor) {
|
||||
frappe.call({
|
||||
method: "community.lms.doctype.lesson.lesson.save_progress",
|
||||
args: {
|
||||
lesson: "{{ lesson.name }}",
|
||||
course: "{{ course.name }}"
|
||||
}
|
||||
})
|
||||
}
|
||||
if (membership) {
|
||||
frappe.call("community.lms.api.save_current_lesson", {
|
||||
"course_name": "{{ course.name }}",
|
||||
"lesson_name": "{{ lesson.name }}"
|
||||
})
|
||||
}
|
||||
</script>
|
||||
{%- endblock %}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
frappe.ready(() => {
|
||||
if ($(".title").attr("data-batch") && !$(".title").hasClass("is_mentor")) {
|
||||
/* if ($(".title").attr("data-batch") && !$(".title").hasClass("is_mentor")) {
|
||||
frappe.call({
|
||||
method: "community.lms.doctype.lesson.lesson.save_progress",
|
||||
args: {
|
||||
@@ -13,5 +13,5 @@ frappe.ready(() => {
|
||||
"batch_name": $(".title").attr("data-batch"),
|
||||
"lesson_name": $(".title").attr("data-name")
|
||||
})
|
||||
}
|
||||
} */
|
||||
})
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
{% block content %}
|
||||
|
||||
<div class="container">
|
||||
{{ widgets.BatchTabs(course=course, batch=batch) }}
|
||||
{{ widgets.BatchTabs(course=course, membership=membership) }}
|
||||
{{ MembersList(members)}}
|
||||
</div>
|
||||
{% endblock %}
|
||||
|
||||
@@ -3,5 +3,5 @@ from . import utils
|
||||
|
||||
def get_context(context):
|
||||
utils.get_common_context(context)
|
||||
if not context.batch:
|
||||
if not context.membership:
|
||||
utils.redirect_to_lesson(context.course)
|
||||
|
||||
@@ -11,11 +11,16 @@ def get_common_context(context):
|
||||
context.template = "www/404.html"
|
||||
return
|
||||
|
||||
batch_name = course.get_current_batch(frappe.session.user)
|
||||
batch = course.get_batch(batch_name)
|
||||
context.batch = batch
|
||||
if batch_name:
|
||||
context.members = batch.get_mentors() + batch.get_students()
|
||||
membership = course.get_current_membership(frappe.session.user)
|
||||
|
||||
if membership:
|
||||
context.membership = membership
|
||||
batch = course.get_batch(membership.batch)
|
||||
|
||||
if batch:
|
||||
context.batch = batch
|
||||
|
||||
context.members = course.get_mentors(membership.batch) + course.get_students(membership.batch)
|
||||
context.member_count = len(context.members)
|
||||
|
||||
|
||||
|
||||
@@ -12,7 +12,12 @@
|
||||
<div class="mb-5">
|
||||
<a class="anchor_style" href="/courses">Courses</a> / <span class="text-muted">{{ course.title }}</span>
|
||||
</div>
|
||||
<h2 id="course-title" data-course="{{course.name}}">{{course.title}}</h2>
|
||||
<div class="d-flex justify-content-between align-items-end">
|
||||
<h2 id="course-title" data-course="{{course.name}}">{{course.title}}</h2>
|
||||
<div>
|
||||
<button class="btn btn-primary join-batch" data-course="{{ course.name | urlencode }}"> Join the Course</button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="course-short-intro">{{ course.short_introduction }}</div>
|
||||
</div>
|
||||
|
||||
@@ -96,8 +101,8 @@
|
||||
</div>
|
||||
{% endfor %}
|
||||
</div>
|
||||
{% else %}
|
||||
<div class="mt-5 upcoming">There are no Upcoming Batches for this course currently.</div>
|
||||
{% endif %}
|
||||
{% else %}
|
||||
<div class="mt-5 upcoming">There are no Upcoming Batches for this course currently.</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
{% endmacro %}
|
||||
|
||||
@@ -57,11 +57,13 @@ frappe.ready(() => {
|
||||
window.location.href = `/login?redirect-to=/courses/${course}`;
|
||||
return;
|
||||
}
|
||||
batch = decodeURIComponent($(e.currentTarget).attr("data-batch"))
|
||||
var batch = $(e.currentTarget).attr("data-batch");
|
||||
batch = batch ? decodeURIComponent(batch) : "";
|
||||
frappe.call({
|
||||
"method": "community.lms.doctype.lms_batch_membership.lms_batch_membership.create_membership",
|
||||
"args": {
|
||||
"batch": batch
|
||||
"batch": batch ? batch : "",
|
||||
"course": course
|
||||
},
|
||||
"callback": (data) => {
|
||||
if (data.message == "OK") {
|
||||
|
||||
Reference in New Issue
Block a user