Merge pull request #319 from pateljannat/certification
This commit is contained in:
@@ -244,7 +244,7 @@ const create_certificate = (e) => {
|
||||
e.preventDefault();
|
||||
course = $(".title").attr("data-course");
|
||||
frappe.call({
|
||||
method: "lms.lms.doctype.lms_certification.lms_certification.create_certificate",
|
||||
method: "lms.lms.doctype.lms_certificate.lms_certificate.create_certificate",
|
||||
args: {
|
||||
"course": course
|
||||
},
|
||||
|
||||
@@ -1,24 +1,21 @@
|
||||
{% extends "templates/base.html" %}
|
||||
{% from "www/macros/common_macro.html" import MentorsSection %}
|
||||
|
||||
{% block title %} {{ student.full_name }} - {{ course.title }} {% endblock %}
|
||||
{% block title %} {{ member.full_name }} - {{ course.title }} {% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<div class="common-page-style">
|
||||
<div class="container certificate-page">
|
||||
|
||||
<div class="breadcrumb">
|
||||
<a class="dark-links" href="/courses">All Courses</a>
|
||||
<img class="ml-1 mr-1" src="/assets/lms/icons/chevron-right.svg">
|
||||
<a class="dark-links" href="/courses/{{ course.name }}">{{ course.title }}</a>
|
||||
</div>
|
||||
|
||||
{% if certificate.student == frappe.session.user %}
|
||||
<div class="d-flex justify-content-end mb-5">
|
||||
<div class="button is-secondary pull-right" id="export-as-pdf" data-certificate="{{ certificate.name }}"
|
||||
data-certificate-name="{{ student.full_name }} - {{ course.title }}">Export</div>
|
||||
</div>
|
||||
{% if certificate.member == frappe.session.user %}
|
||||
<div class="button is-secondary pull-right mt-4" id="export-as-pdf" data-certificate="{{ certificate.name }}"
|
||||
data-certificate-name="{{ member.full_name }} - {{ course.title }}">{{ _("Export") }}</div>
|
||||
{% endif %}
|
||||
|
||||
<div class="breadcrumb">
|
||||
<a class="dark-links" href="/courses">{{ _("All Courses") }}</a>
|
||||
<img class="ml-1 mr-1" src="/assets/lms/icons/chevron-right.svg">
|
||||
<a class="dark-links" href="/courses/{{ course.name }}">{{ course.title }}</a>
|
||||
</div>
|
||||
|
||||
{% include "lms/templates/certificate.html" %}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -9,8 +9,8 @@ def get_context(context):
|
||||
except KeyError:
|
||||
redirect_to_course_list()
|
||||
|
||||
context.certificate = frappe.db.get_value("LMS Certification", certificate_name,
|
||||
["name", "student", "issue_date", "expiry_date", "course"], as_dict=True)
|
||||
context.certificate = frappe.db.get_value("LMS Certificate", certificate_name,
|
||||
["name", "member", "issue_date", "expiry_date", "course"], as_dict=True)
|
||||
|
||||
if context.certificate.course != course_name:
|
||||
redirect_to_course_list()
|
||||
@@ -21,7 +21,7 @@ def get_context(context):
|
||||
context.instructor = frappe.db.get_value("User", context.course.instructor,
|
||||
["full_name", "username"], as_dict=True)
|
||||
|
||||
context.student = frappe.db.get_value("User", context.certificate.student,
|
||||
context.member = frappe.db.get_value("User", context.certificate.member,
|
||||
["full_name"], as_dict=True)
|
||||
|
||||
context.logo = frappe.db.get_single_value("Website Settings", "banner_image")
|
||||
|
||||
@@ -105,6 +105,12 @@
|
||||
{{ _("You have opted to be notified for this course. You will receive an email when the course becomes available.") }}
|
||||
</div>
|
||||
|
||||
{% if certificate_request %}
|
||||
<p class="mb-2"> <b>{{ _("Evaluation On: ") }}</b>
|
||||
{{ _("{0} at {1}").format(frappe.utils.format_date(certificate_request.date, "medium"),
|
||||
frappe.utils.format_time(certificate_request.start_time, "short")) }} </p>
|
||||
{% endif %}
|
||||
|
||||
{% if course.status == "Under Review" %}
|
||||
<div class="mb-4">
|
||||
{{ _("Your course is currently under review. Once the review is complete, the System Admins will publish it on the website.") }}
|
||||
@@ -125,7 +131,7 @@
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
<div class="vertically-center mb-2">
|
||||
<div class="vertically-center justify-content-center mb-2">
|
||||
<div class="">
|
||||
<svg class="icon icon-md mr-1">
|
||||
<use class="" href="#icon-users">
|
||||
@@ -145,6 +151,12 @@
|
||||
{% endif %}
|
||||
</div>
|
||||
|
||||
{% if course.paid_certificate %}
|
||||
<div class="certificate-price">
|
||||
{{ _("Certificate Price:") }} {{ frappe.utils.fmt_money(course.price_certificate, 2, course.currency) }}
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
{% set lesson_index = get_lesson_index(membership.current_lesson) if membership and
|
||||
membership.current_lesson
|
||||
else '1.1' %}
|
||||
@@ -155,7 +167,7 @@
|
||||
<img class="ml-2" src="/assets/lms/icons/white-arrow.svg" />
|
||||
</div>
|
||||
|
||||
{% elif is_instructor(course.name) and not course.published and course.status != "Under Review" %}
|
||||
{% elif is_instructor(course.name) and not course.published and course.status == "Under 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/lms/icons/white-arrow.svg" />
|
||||
@@ -167,12 +179,6 @@
|
||||
{{ _("Checkout Course") }} <img class="ml-2" src="/assets/lms/icons/white-arrow.svg" />
|
||||
</a>
|
||||
|
||||
{% 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/lms/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}}">
|
||||
@@ -185,22 +191,73 @@
|
||||
style="color: inherit;">
|
||||
{{ _("Manage the course") }}
|
||||
</a>
|
||||
|
||||
{% 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/lms/icons/white-arrow.svg" />
|
||||
</a>
|
||||
{% endif %}
|
||||
|
||||
{% set certificate = is_certified(course.name) %}
|
||||
{% set progress = frappe.utils.cint(membership.progress) %}
|
||||
{% if membership and course.enable_certification %}
|
||||
{% if certificate %}
|
||||
<a class="button wide-button is-secondary mt-2" href="/courses/{{ course.name }}/{{ certificate }}">
|
||||
{{ _("Get Certificate") }}
|
||||
</a>
|
||||
{% elif course.enable_certification and progress == 100 %}
|
||||
{% elif course.grant_certificate_after == "Evaluation" and not certificate_request %}
|
||||
<a class="button wide-button is-secondary mt-2" id="apply-certificate" data-course="{{ course.name }}">
|
||||
{{ _("Apply for Certificate") }}
|
||||
</a>
|
||||
{% elif progress == 100 %}
|
||||
<div class="button wide-button is-secondary mt-4" id="certification" data-course="{{ course.name }}">
|
||||
{{ _("Get Certificate") }}
|
||||
</div>
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="modal fade" id="slot-modal" tabindex="-1" role="dialog" aria-hidden="true">
|
||||
<div class="modal-dialog" role="document">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<div class="font-weight-bold">{{ _("Pick a Slot") }}</div>
|
||||
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
|
||||
<span aria-hidden="true">×</span>
|
||||
</button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<form id="slot-form">
|
||||
<p class="">{{ _("This course requires you to complete an evaluation to get certified. Please pick a slot based on your convenience for the evaluations. ") }}</p>
|
||||
<div class="form-group">
|
||||
<div class="clearfix">
|
||||
<label class="control-label reqd" style="padding-right: 0px;">{{ _("Date") }}</label>
|
||||
</div>
|
||||
<div class="control-input-wrapper">
|
||||
<div class="control-input">
|
||||
<input type="date" class="input-with-feedback form-control bold" data-fieldtype="Date"
|
||||
id="slot-date" min="{{ frappe.utils.format_date(frappe.utils.getdate(), 'yyyy-mm-dd') }}">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<div class="clearfix">
|
||||
<label class="control-label reqd slot-label hide" style="padding-right: 0px;">{{ _("Slots") }}</label>
|
||||
</div>
|
||||
<div class="control-input-wrapper">
|
||||
<div class="control-input">
|
||||
<div class="slots"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<p id="no-slots-message" class="small text-danger hide"> {{ _("There are no slots available on this day.") }} </p>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endmacro %}
|
||||
|
||||
|
||||
@@ -1,50 +1,62 @@
|
||||
frappe.ready(() => {
|
||||
|
||||
hide_wrapped_mentor_cards();
|
||||
hide_wrapped_mentor_cards();
|
||||
|
||||
$("#cancel-request").click((e) => {
|
||||
cancel_mentor_request(e);
|
||||
});
|
||||
$("#cancel-request").click((e) => {
|
||||
cancel_mentor_request(e);
|
||||
});
|
||||
|
||||
$(".join-batch").click((e) => {
|
||||
join_course(e)
|
||||
});
|
||||
$(".join-batch").click((e) => {
|
||||
join_course(e)
|
||||
});
|
||||
|
||||
$(".view-all-mentors").click((e) => {
|
||||
view_all_mentors(e);
|
||||
});
|
||||
$(".view-all-mentors").click((e) => {
|
||||
view_all_mentors(e);
|
||||
});
|
||||
|
||||
$(".review-link").click((e) => {
|
||||
show_review_dialog(e);
|
||||
});
|
||||
$(".review-link").click((e) => {
|
||||
show_review_dialog(e);
|
||||
});
|
||||
|
||||
$(".icon-rating").click((e) => {
|
||||
highlight_rating(e);
|
||||
});
|
||||
$(".icon-rating").click((e) => {
|
||||
highlight_rating(e);
|
||||
});
|
||||
|
||||
$("#submit-review").click((e) => {
|
||||
submit_review(e);
|
||||
})
|
||||
$("#submit-review").click((e) => {
|
||||
submit_review(e);
|
||||
})
|
||||
|
||||
$("#notify-me").click((e) => {
|
||||
notify_user(e);
|
||||
})
|
||||
$("#notify-me").click((e) => {
|
||||
notify_user(e);
|
||||
})
|
||||
|
||||
$("#certification").click((e) => {
|
||||
create_certificate(e);
|
||||
});
|
||||
$("#certification").click((e) => {
|
||||
create_certificate(e);
|
||||
});
|
||||
|
||||
$("#submit-for-review").click((e) => {
|
||||
submit_for_review(e);
|
||||
});
|
||||
$("#submit-for-review").click((e) => {
|
||||
submit_for_review(e);
|
||||
});
|
||||
|
||||
$(document).scroll(function() {
|
||||
let timer;
|
||||
clearTimeout(timer);
|
||||
timer = setTimeout(() => { handle_overlay_display.apply(this, arguments); }, 500);
|
||||
});
|
||||
$("#apply-certificate").click((e) => {
|
||||
apply_cetificate(e);
|
||||
});
|
||||
|
||||
})
|
||||
$("#slot-date").on("change", (e) => {
|
||||
display_slots(e);
|
||||
});
|
||||
|
||||
$(document).on("click", ".slot", (e) => {
|
||||
submit_slot(e);
|
||||
});
|
||||
|
||||
$(document).scroll(function() {
|
||||
let timer;
|
||||
clearTimeout(timer);
|
||||
timer = setTimeout(() => { handle_overlay_display.apply(this, arguments); }, 500);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
var hide_wrapped_mentor_cards = () => {
|
||||
var offset_top_prev;
|
||||
@@ -185,7 +197,7 @@ const create_certificate = (e) => {
|
||||
e.preventDefault();
|
||||
course = $(e.currentTarget).attr("data-course");
|
||||
frappe.call({
|
||||
method: "lms.lms.doctype.lms_certification.lms_certification.create_certificate",
|
||||
method: "lms.lms.doctype.lms_certificate.lms_certificate.create_certificate",
|
||||
args: {
|
||||
"course": course
|
||||
},
|
||||
@@ -236,4 +248,63 @@ const submit_for_review = (e) => {
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
};
|
||||
|
||||
const apply_cetificate = (e) => {
|
||||
frappe.call({
|
||||
method: "lms.lms.doctype.course_evaluator.course_evaluator.get_schedule",
|
||||
args: {
|
||||
"course": $(e.currentTarget).data("course")
|
||||
},
|
||||
callback: (data) => {
|
||||
let options = "";
|
||||
data.message.forEach((obj) => {
|
||||
options += `<button type="button" class="btn btn-sm btn-secondary mr-3 slot hide"
|
||||
data-course="${$(e.currentTarget).data("course")}"
|
||||
data-day="${obj.day}" data-start="${obj.start_time}" data-end="${obj.end_time}">
|
||||
${obj.day} ${obj.start_time} - ${obj.end_time}</button>`;
|
||||
});
|
||||
e.preventDefault();
|
||||
$("#slot-modal .slots").html(options);
|
||||
$("#slot-modal").modal("show");
|
||||
}
|
||||
})
|
||||
};
|
||||
|
||||
const submit_slot = (e) => {
|
||||
e.preventDefault();
|
||||
const slot = $(e.currentTarget);
|
||||
frappe.call({
|
||||
method: "lms.lms.doctype.lms_certificate_request.lms_certificate_request.create_certificate_request",
|
||||
args: {
|
||||
"course": slot.data("course"),
|
||||
"date": $("#slot-date").val(),
|
||||
"day": slot.data("day"),
|
||||
"start_time": slot.data("start"),
|
||||
"end_time": slot.data("end")
|
||||
},
|
||||
callback: (data) => {
|
||||
$("#slot-modal").modal("hide");
|
||||
frappe.msgprint(__("Your slot has been booked. Prepare well for the evaluations."));
|
||||
setTimeout(() => {
|
||||
window.location.reload();
|
||||
}, 2000);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
const display_slots = (e) => {
|
||||
const weekday = ["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"];
|
||||
const day = weekday[new Date($(e.currentTarget).val()).getDay()]
|
||||
|
||||
$(".slot").addClass("hide");
|
||||
$(".slot-label").addClass("hide");
|
||||
|
||||
if ($(`[data-day='${day}']`).length) {
|
||||
$(".slot-label").removeClass("hide");
|
||||
$(`[data-day='${day}']`).removeClass("hide");
|
||||
$("#no-slots-message").addClass("hide");
|
||||
} else {
|
||||
$("#no-slots-message").removeClass("hide");
|
||||
}
|
||||
};
|
||||
|
||||
@@ -12,8 +12,8 @@ def get_context(context):
|
||||
raise frappe.Redirect
|
||||
|
||||
course = frappe.db.get_value("LMS Course", course_name,
|
||||
["name", "title", "image", "short_introduction", "description", "published", "upcoming",
|
||||
"disable_self_learning", "video_link", "enable_certification", "status"],
|
||||
["name", "title", "image", "short_introduction", "description", "published", "upcoming", "disable_self_learning", "status",
|
||||
"video_link", "enable_certification", "grant_certificate_after", "paid_certificate", "price_certificate", "currency"],
|
||||
as_dict=True)
|
||||
|
||||
if course is None:
|
||||
@@ -30,10 +30,19 @@ def get_context(context):
|
||||
membership = get_membership(course.name, frappe.session.user)
|
||||
context.course.query_parameter = "?batch=" + membership.batch if membership and membership.batch else ""
|
||||
context.membership = membership
|
||||
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.restriction)
|
||||
context.certificate_request = frappe.db.get_value("LMS Certificate Request",
|
||||
{
|
||||
"course": course.name,
|
||||
"member": frappe.session.user
|
||||
},
|
||||
["date", "start_time", "end_time"],
|
||||
as_dict=True)
|
||||
|
||||
if context.course.upcoming:
|
||||
context.is_user_interested = get_user_interest(context.course.name)
|
||||
|
||||
context.metatags = {
|
||||
"title": course.title,
|
||||
"image": course.image,
|
||||
|
||||
@@ -15,7 +15,8 @@ def get_context(context):
|
||||
def get_courses():
|
||||
courses = frappe.get_all("LMS Course",
|
||||
filters={"published": True},
|
||||
fields=["name", "upcoming", "title", "image", "enable_certification"])
|
||||
fields=["name", "upcoming", "title", "image", "enable_certification",
|
||||
"paid_certificate", "price_certificate", "currency"])
|
||||
|
||||
live_courses, upcoming_courses = [], []
|
||||
for course in courses:
|
||||
|
||||
@@ -9,7 +9,7 @@ def get_common_context(context):
|
||||
batch_name = None
|
||||
|
||||
course = frappe.db.get_value("LMS Course",
|
||||
frappe.form_dict["course"], ["name", "title", "video_link"], as_dict=True)
|
||||
frappe.form_dict["course"], ["name", "title", "video_link", "enable_certification"], as_dict=True)
|
||||
if not course:
|
||||
context.template = "www/404.html"
|
||||
return
|
||||
|
||||
Reference in New Issue
Block a user