dashboard and patch for lesson
This commit is contained in:
@@ -159,36 +159,45 @@
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
{% set lesson_index = get_lesson_index(membership.current_lesson) if membership and
|
||||
membership.current_lesson
|
||||
else '1.1' %}
|
||||
|
||||
{% if not course.disable_self_learning and not membership and not course.upcoming and not restriction.restrict %}
|
||||
<div class="button wide-button start-learning is-primary join-batch" data-course="{{ course.name | urlencode }}">
|
||||
{% if show_start_learing_cta %}
|
||||
<div class="button wide-button is-primary join-batch" data-course="{{ course.name | urlencode }}">
|
||||
{{ _("Start Learning") }}
|
||||
<img class="ml-2" src="/assets/school/icons/white-arrow.svg" />
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
{% if membership %}
|
||||
{% set lesson_index = get_lesson_index(membership.current_lesson) if membership and
|
||||
membership.current_lesson
|
||||
else '1.1' %}
|
||||
{% elif is_instructor(course.name) and not course.is_published and status != "Ready for Review" %}
|
||||
<div class="button wide-button is-primary" id="submit-for-review" data-course="{{ course.name | urlencode }}">
|
||||
{{ _("Submit for Review") }}
|
||||
<img class="ml-2" src="/assets/school/icons/white-arrow.svg" />
|
||||
</div>
|
||||
|
||||
{% elif is_instructor(course.name) %}
|
||||
<a class="button wide-button is-primary" id="continue-learning"
|
||||
href="{{ get_lesson_url(course.name, lesson_index) }}{{ course.query_parameter }}">
|
||||
Continue Learning <img class="ml-2" src="/assets/school/icons/white-arrow.svg" />
|
||||
{{ _("Checkout Course") }} <img class="ml-2" src="/assets/school/icons/white-arrow.svg" />
|
||||
</a>
|
||||
{% endif %}
|
||||
|
||||
{% if course.upcoming and not is_user_interested %}
|
||||
{% elif membership %}
|
||||
<a class="button wide-button is-primary" id="continue-learning"
|
||||
href="{{ get_lesson_url(course.name, lesson_index) }}{{ course.query_parameter }}">
|
||||
{{ _("Continue Learning") }} <img class="ml-2" src="/assets/school/icons/white-arrow.svg" />
|
||||
</a>
|
||||
|
||||
{% elif course.upcoming and not is_user_interested %}
|
||||
<div class="button wide-button is-default"
|
||||
id="notify-me" data-course="{{course.name | urlencode}}">
|
||||
Notify me when available
|
||||
{{ _("Notify me when available") }}
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
{% if is_cohort_staff(course.name, frappe.session.user) %}
|
||||
{% elif is_cohort_staff(course.name, frappe.session.user) %}
|
||||
<a class="button wide-button is-secondary"
|
||||
href="/courses/{{course.name}}/manage"
|
||||
style="color: inherit;">
|
||||
Manage the course
|
||||
{{ _("Manage the course") }}
|
||||
</a>
|
||||
{% endif %}
|
||||
|
||||
@@ -252,12 +261,10 @@
|
||||
<div class="slider-controls">
|
||||
<a class="carousel-control-prev" href="#carouselExampleControls" role="button" data-slide="prev">
|
||||
<span class="carousel-control-prev-icon" aria-hidden="true"></span>
|
||||
<span class="sr-only">Previous</span>
|
||||
</a>
|
||||
|
||||
<a class="carousel-control-next" href="#carouselExampleControls" role="button" data-slide="next">
|
||||
<span class="carousel-control-next-icon" aria-hidden="true"></span>
|
||||
<span class="sr-only">Next</span>
|
||||
</a>
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
@@ -41,6 +41,10 @@ frappe.ready(() => {
|
||||
create_certificate(e);
|
||||
});
|
||||
|
||||
$("#submit-for-review").click((e) => {
|
||||
submit_for_review(e);
|
||||
});
|
||||
|
||||
$(document).scroll(function() {
|
||||
let timer;
|
||||
clearTimeout(timer);
|
||||
@@ -237,7 +241,7 @@ const create_certificate = (e) => {
|
||||
const element_not_in_viewport = (el) => {
|
||||
const rect = el.getBoundingClientRect();
|
||||
return rect.bottom < 0 || rect.right < 0 || rect.left > window.innerWidth || rect.top > window.innerHeight;
|
||||
}
|
||||
};
|
||||
|
||||
const handle_overlay_display = () => {
|
||||
const element = $(".related-courses").length && $(".related-courses")[0];
|
||||
@@ -255,4 +259,22 @@ const handle_overlay_display = () => {
|
||||
"bottom": "5%"
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
const submit_for_review = (e) => {
|
||||
let course = $(e.currentTarget).data("course");
|
||||
frappe.call({
|
||||
method: "school.lms.doctype.lms_course.lms_course.submit_for_review",
|
||||
args: {
|
||||
"course": course
|
||||
},
|
||||
callback: (data) => {
|
||||
if (data.message == "No Chp") {
|
||||
frappe.msgprint(__(`There are no chapters in this course.
|
||||
Please add chapters and lessons to your course before you submit it for review.`));
|
||||
} else if (data.message == "OK") {
|
||||
frappe.msgprint(__("Your course has been submitted for review."))
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import frappe
|
||||
from school.lms.doctype.lms_settings.lms_settings import check_profile_restriction
|
||||
from school.lms.utils import get_membership
|
||||
from school.lms.utils import get_membership, is_instructor
|
||||
|
||||
def get_context(context):
|
||||
context.no_cache = 1
|
||||
@@ -33,6 +33,7 @@ def get_context(context):
|
||||
if context.course.upcoming:
|
||||
context.is_user_interested = get_user_interest(context.course.name)
|
||||
context.restriction = check_profile_restriction()
|
||||
context.show_start_learing_cta = show_start_learing_cta(course, membership)
|
||||
context.metatags = {
|
||||
"title": course.title,
|
||||
"image": course.image,
|
||||
@@ -46,3 +47,6 @@ def get_user_interest(course):
|
||||
"course": course,
|
||||
"user": frappe.session.user
|
||||
})
|
||||
|
||||
def show_start_learing_cta(course, membership):
|
||||
return not course.disable_self_learning and not membership and not course.upcoming and not restriction.restrict and not is_instructor(course.name)
|
||||
|
||||
0
school/www/dashboard/__init__.py
Normal file
0
school/www/dashboard/__init__.py
Normal file
32
school/www/dashboard/index.html
Normal file
32
school/www/dashboard/index.html
Normal file
@@ -0,0 +1,32 @@
|
||||
{% extends "templates/base.html" %}
|
||||
{% block title %}{{ _("Dashboard")}}
|
||||
{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<div class="common-page-style dashboard">
|
||||
<div class="container">
|
||||
<ul class="nav mb-8">
|
||||
<li class="nav-item">
|
||||
<a class="nav-link active" data-toggle="tab" href="#courses-enrolled"> {{ _("Courses Enrolled") }} </a>
|
||||
</li>
|
||||
{% if frappe.db.get_single_value("LMS Settings", "portal_course_creation") %}
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" data-toggle="tab" href="#courses-created">{{ _("Courses Created") }}</a>
|
||||
</li>
|
||||
{% endif %}
|
||||
</ul>
|
||||
<div class="tab-content">
|
||||
<div class="tab-pane active" id="courses-enrolled" role="tabpanel" aria-labelledby="courses-enrolled">
|
||||
{% include "school/lms/web_template/courses_enrolled/courses_enrolled.html" %}
|
||||
</div>
|
||||
{% if frappe.db.get_single_value("LMS Settings", "portal_course_creation") %}
|
||||
<div class="tab-pane fade" id="courses-created" role="tabpanel" aria-labelledby="courses-created">
|
||||
{% include "school/templates/courses_created.html" %}
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
|
||||
<script src="//maxcdn.bootstrapcdn.com/bootstrap/3.2.0/js/bootstrap.min.js"></script>
|
||||
{% endblock %}
|
||||
@@ -29,7 +29,7 @@
|
||||
|
||||
{% macro ProfileBanner(member) %}
|
||||
{% set cover_image = member.cover_image if member.cover_image else "/assets/school/images/profile-banner.png" %}
|
||||
{% set enrollment = member.get_course_membership("Student") | length %}
|
||||
{% set enrollment = get_course_membership(member_type="Student") | length %}
|
||||
{% set enrollment_suffix = _("Courses") if enrollment > 1 else _("Course") %}
|
||||
<div class="container">
|
||||
<div class="profile-banner" style="background-image: url({{ cover_image }})">
|
||||
@@ -77,9 +77,7 @@
|
||||
<div class="course-home-headings"> {{ _("Courses Created") }} </div>
|
||||
<div class="cards-parent">
|
||||
{% for course in authored_courses %}
|
||||
{% set course_details = frappe.db.get_value("LMS Course", course,
|
||||
["name", "upcoming", "title", "image", "enable_certification"], as_dict=True) %}
|
||||
{{ widgets.CourseCard(course=course_details, read_only=read_only) }}
|
||||
{{ widgets.CourseCard(course=course, read_only=read_only) }}
|
||||
{% endfor %}
|
||||
</div>
|
||||
</div>
|
||||
@@ -100,7 +98,7 @@
|
||||
{% endmacro %}
|
||||
|
||||
{% macro CoursesEnrolled(member, read_only) %}
|
||||
{% set enrolled = member.get_enrolled_courses() %}
|
||||
{% set enrolled = get_enrolled_courses() %}
|
||||
|
||||
{% if enrolled.completed | length %}
|
||||
<div class="profile-courses">
|
||||
|
||||
Reference in New Issue
Block a user