fix: batch ui and ux
This commit is contained in:
@@ -196,6 +196,10 @@ website_route_rules = [
|
||||
"from_route": "/batches/details/<batchname>",
|
||||
"to_route": "batches/batch_details",
|
||||
},
|
||||
{
|
||||
"from_route": "/certified-participants",
|
||||
"to_route": "certified_participants/certified_participants",
|
||||
},
|
||||
]
|
||||
|
||||
website_redirects = [
|
||||
|
||||
@@ -17,7 +17,7 @@ def add_pages_to_nav():
|
||||
pages = [
|
||||
{"label": "Explore", "idx": 1},
|
||||
{"label": "Courses", "url": "/courses", "parent": "Explore", "idx": 2},
|
||||
{"label": "Classes", "url": "/classes", "parent": "Explore", "idx": 3},
|
||||
{"label": "Batches", "url": "/batches", "parent": "Explore", "idx": 3},
|
||||
{"label": "Statistics", "url": "/statistics", "parent": "Explore", "idx": 4},
|
||||
{"label": "Jobs", "url": "/jobs", "parent": "Explore", "idx": 5},
|
||||
{"label": "People", "url": "/community", "parent": "Explore", "idx": 6},
|
||||
|
||||
@@ -37,8 +37,8 @@ class CourseEvaluator(Document):
|
||||
|
||||
|
||||
@frappe.whitelist()
|
||||
def get_schedule(course, date, class_name=None):
|
||||
evaluator = get_evaluator(course, class_name)
|
||||
def get_schedule(course, date, batch=None):
|
||||
evaluator = get_evaluator(course, batch)
|
||||
|
||||
all_slots = frappe.get_all(
|
||||
"Evaluator Schedule",
|
||||
|
||||
@@ -238,3 +238,25 @@ def fetch_lessons(courses):
|
||||
lessons.extend(get_lessons(course.get("course")))
|
||||
|
||||
return lessons
|
||||
|
||||
|
||||
@frappe.whitelist()
|
||||
def add_course(course, parent, name=None, evaluator=None):
|
||||
frappe.only_for("Moderator")
|
||||
if name:
|
||||
doc = frappe.get_doc("Batch Course", name)
|
||||
else:
|
||||
doc = frappe.new_doc("Batch Course")
|
||||
|
||||
doc.update(
|
||||
{
|
||||
"course": course,
|
||||
"evaluator": evaluator,
|
||||
"parent": parent,
|
||||
"parentfield": "courses",
|
||||
"parenttype": "LMS Batch",
|
||||
}
|
||||
)
|
||||
doc.save()
|
||||
|
||||
return doc.name
|
||||
|
||||
@@ -104,9 +104,7 @@ def update_meeting_details(eval, event, calendar):
|
||||
|
||||
|
||||
@frappe.whitelist()
|
||||
def create_certificate_request(
|
||||
course, date, day, start_time, end_time, class_name=None
|
||||
):
|
||||
def create_certificate_request(course, date, day, start_time, end_time, batch=None):
|
||||
is_member = frappe.db.exists(
|
||||
{"doctype": "LMS Enrollment", "course": course, "member": frappe.session.user}
|
||||
)
|
||||
@@ -117,13 +115,13 @@ def create_certificate_request(
|
||||
eval.update(
|
||||
{
|
||||
"course": course,
|
||||
"evaluator": get_evaluator(course, class_name),
|
||||
"evaluator": get_evaluator(course, batch),
|
||||
"member": frappe.session.user,
|
||||
"date": date,
|
||||
"day": day,
|
||||
"start_time": start_time,
|
||||
"end_time": end_time,
|
||||
"class_name": class_name,
|
||||
"batch": batch,
|
||||
}
|
||||
)
|
||||
eval.save(ignore_permissions=True)
|
||||
|
||||
@@ -20,6 +20,7 @@ class LMSCourse(Document):
|
||||
self.image = validate_image(self.image)
|
||||
|
||||
def validate_instructors(self):
|
||||
print(self.is_new(), not self.instructors)
|
||||
if self.is_new() and not self.instructors:
|
||||
frappe.get_doc(
|
||||
{
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
"default_currency",
|
||||
"column_break_cfcv",
|
||||
"razorpay_secret",
|
||||
"apply_gst",
|
||||
"signup_settings_tab",
|
||||
"signup_settings_section",
|
||||
"terms_of_use",
|
||||
@@ -188,6 +189,7 @@
|
||||
"default": "0",
|
||||
"fieldname": "allow_student_progress",
|
||||
"fieldtype": "Check",
|
||||
"hidden": 1,
|
||||
"label": "Allow students to see each others progress in class"
|
||||
},
|
||||
{
|
||||
@@ -223,12 +225,18 @@
|
||||
"fieldname": "razorpay_secret",
|
||||
"fieldtype": "Password",
|
||||
"label": "Razorpay Secret"
|
||||
},
|
||||
{
|
||||
"default": "0",
|
||||
"fieldname": "apply_gst",
|
||||
"fieldtype": "Check",
|
||||
"label": "Apply GST for India"
|
||||
}
|
||||
],
|
||||
"index_web_pages_for_search": 1,
|
||||
"issingle": 1,
|
||||
"links": [],
|
||||
"modified": "2023-08-02 18:59:01.267732",
|
||||
"modified": "2023-08-29 09:54:48.030823",
|
||||
"modified_by": "Administrator",
|
||||
"module": "LMS",
|
||||
"name": "LMS Settings",
|
||||
|
||||
@@ -795,13 +795,13 @@ def has_graded_assessment(submission):
|
||||
return False if status == "Not Graded" else True
|
||||
|
||||
|
||||
def get_evaluator(course, class_name=None):
|
||||
def get_evaluator(course, batch=None):
|
||||
evaluator = None
|
||||
|
||||
if class_name:
|
||||
if batch:
|
||||
evaluator = frappe.db.get_value(
|
||||
"Batch Course",
|
||||
{"parent": class_name, "course": course},
|
||||
{"parent": batch, "course": course},
|
||||
"evaluator",
|
||||
)
|
||||
|
||||
@@ -871,11 +871,11 @@ def get_details(doctype, docname):
|
||||
details = frappe.db.get_value(
|
||||
"LMS Batch",
|
||||
docname,
|
||||
["name", "title", "paid_class", "currency", "amount"],
|
||||
["name", "title", "paid_batch", "currency", "amount"],
|
||||
as_dict=True,
|
||||
)
|
||||
if not details.paid_class:
|
||||
frappe.throw(_("To join this class, please contact the Administrator."))
|
||||
if not details.paid_batch:
|
||||
frappe.throw(_("To join this batch, please contact the Administrator."))
|
||||
|
||||
return details
|
||||
|
||||
@@ -939,7 +939,7 @@ def verify_payment(response, doctype, docname, address, order_id):
|
||||
if doctype == "LMS Course":
|
||||
return create_membership(docname, payment)
|
||||
else:
|
||||
return add_student_to_class(docname, payment)
|
||||
return add_student_to_batch(docname, payment)
|
||||
|
||||
|
||||
def record_payment(address, response, client, doctype, docname):
|
||||
@@ -967,10 +967,7 @@ def record_payment(address, response, client, doctype, docname):
|
||||
|
||||
|
||||
def get_payment_details(client, response, doctype, docname):
|
||||
try:
|
||||
payment = client.payment.fetch(response["razorpay_payment_id"])
|
||||
except Exception as e:
|
||||
frappe.log_error(e, "Error during payment fetch")
|
||||
payment = client.payment.fetch(response["razorpay_payment_id"])
|
||||
|
||||
if payment:
|
||||
amount = payment["amount"] / 100
|
||||
@@ -995,16 +992,16 @@ def create_membership(course, payment):
|
||||
return f"/courses/{course}/learn/1.1"
|
||||
|
||||
|
||||
def add_student_to_class(classname, payment):
|
||||
def add_student_to_batch(batchname, payment):
|
||||
student = frappe.new_doc("Batch Student")
|
||||
student.update(
|
||||
{
|
||||
"student": frappe.session.user,
|
||||
"payment": payment,
|
||||
"parent": classname,
|
||||
"parent": batchname,
|
||||
"parenttype": "LMS Batch",
|
||||
"parentfield": "students",
|
||||
}
|
||||
)
|
||||
student.save(ignore_permissions=True)
|
||||
return f"/classes/{classname}"
|
||||
return f"/batches/{batchname}"
|
||||
|
||||
@@ -3,7 +3,7 @@ frappe.ready(function () {
|
||||
let data = frappe.web_form.get_values();
|
||||
if (data.class) {
|
||||
setTimeout(() => {
|
||||
window.location.href = `/classes/${data.class}`;
|
||||
window.location.href = `/batches/${data.class}`;
|
||||
}, 2000);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -65,4 +65,5 @@ lms.patches.v1_0.paid_certificate_to_paid_course #18-08-2023
|
||||
lms.patches.v1_0.revert_class_registration #18-08-2023
|
||||
lms.patches.v1_0.rename_lms_batch_doctype
|
||||
lms.patches.v1_0.rename_lms_batch_membership_doctype
|
||||
lms.patches.v1_0.rename_lms_class_to_lms_batch
|
||||
lms.patches.v1_0.rename_lms_class_to_lms_batch
|
||||
lms.patches.v1_0.rename_classes_in_navbar
|
||||
12
lms/patches/v1_0/rename_classes_in_navbar.py
Normal file
12
lms/patches/v1_0/rename_classes_in_navbar.py
Normal file
@@ -0,0 +1,12 @@
|
||||
import frappe
|
||||
|
||||
|
||||
def execute():
|
||||
frappe.db.set_value(
|
||||
"Top Bar Item",
|
||||
{"url": "/classes"},
|
||||
{
|
||||
"label": "Batches",
|
||||
"url": "/batches",
|
||||
},
|
||||
)
|
||||
@@ -911,7 +911,7 @@ input[type=checkbox] {
|
||||
.profile-name-section {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
margin: 1rem 0 0.25rem;
|
||||
margin: 0.5rem 0 0.25rem;
|
||||
}
|
||||
|
||||
@media (max-width: 550px) {
|
||||
@@ -2194,15 +2194,6 @@ select {
|
||||
grid-gap: 1rem;
|
||||
}
|
||||
|
||||
.btn-remove-course {
|
||||
opacity: 0;
|
||||
margin-top: 0.25rem;
|
||||
}
|
||||
|
||||
.btn-remove-course:hover {
|
||||
opacity: 1;
|
||||
}
|
||||
|
||||
.rows .grid-row .data-row,
|
||||
.rows .grid-row .grid-footer-toolbar,
|
||||
.grid-form-heading {
|
||||
@@ -2344,4 +2335,8 @@ select {
|
||||
grid-template-columns: 1fr 1fr;
|
||||
grid-gap: 0.5rem;
|
||||
margin-bottom: 1rem;
|
||||
}
|
||||
|
||||
.batch-course-list .cards-parent {
|
||||
row-gap: 3rem
|
||||
}
|
||||
@@ -6,7 +6,7 @@
|
||||
{% set course = frappe.db.get_value("LMS Course", certificate.course, ["title", "name", "image"], as_dict=True) %}
|
||||
|
||||
<div class="common-card-style column-card medium">
|
||||
<div class="font-weight-bold">
|
||||
<div class="bold-heading">
|
||||
{{ course.title }}
|
||||
</div>
|
||||
<div>
|
||||
|
||||
@@ -29,8 +29,8 @@
|
||||
{% endif %}
|
||||
</div>
|
||||
<div class="vertically-center small">
|
||||
<a class="dark-links" href="/classes">
|
||||
{{ _("All Classes") }}
|
||||
<a class="dark-links" href="/batches">
|
||||
{{ _("All Batches") }}
|
||||
</a>
|
||||
<img class="icon icon-sm mr-0" src="/assets/lms/icons/chevron-right.svg">
|
||||
<span class="breadcrumb-destination">{{ _("Assignment Submission") }}</span>
|
||||
@@ -51,13 +51,18 @@
|
||||
|
||||
{% macro SubmissionForm(assignment) %}
|
||||
<article class="field-parent">
|
||||
{% if submission.name and is_moderator %}
|
||||
<div class="field-group">
|
||||
<div class="field-label">
|
||||
{{ _("Student Name") }}
|
||||
{% if submission.name %}
|
||||
<div class="alert alert-info">
|
||||
{{ _("You've successfully submitted the assignment. Once the moderator grades your submission, you'll find the details here. Feel free to make edits to your submission if needed.") }}
|
||||
</div>
|
||||
{{ submission.member_name }}
|
||||
</div>
|
||||
{% if is_moderator %}
|
||||
<div class="field-group">
|
||||
<div class="field-label">
|
||||
{{ _("Student Name") }}
|
||||
</div>
|
||||
{{ submission.member_name }}
|
||||
</div>
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
|
||||
<div class="field-group">
|
||||
@@ -79,14 +84,15 @@
|
||||
<div class="btn btn-default btn-sm btn-upload mt-2 {% if submission.assignment_attachment %} hide {% endif %}" data-type="{{ assignment.type }}">
|
||||
{{ _("Browse").format(assignment.type) }}
|
||||
</div>
|
||||
<div class="field-input flex justify-between align-center {% if not submission.assignment_attachment %} hide {% endif %}" id="assignment-preview">
|
||||
<div class="field-input flex justify-between align-center overflow-auto
|
||||
{% if not submission.assignment_attachment %} hide {% endif %}" id="assignment-preview">
|
||||
<a class="clickable" {% if submission.assignment_attachment %} href="{{ submission.assignment_attachment }}" {% endif %}>
|
||||
{% if submission.assignment_attachment %} {{ submission.assignment_attachment }} {% endif %}
|
||||
</a>
|
||||
<span class="btn btn-default btn-sm btn-close {% if not submission %} hide {% endif %}">
|
||||
{{ _("Clear") }}
|
||||
</span>
|
||||
</div>
|
||||
<span class="btn btn-default btn-sm btn-close {% if not submission %} hide {% endif %} mt-2">
|
||||
{{ _("Clear") }}
|
||||
</span>
|
||||
</div>
|
||||
|
||||
{% if is_moderator %}
|
||||
|
||||
@@ -61,10 +61,10 @@
|
||||
<div class="breadcrumb">
|
||||
{% if class_info %}
|
||||
<a class="dark-links" href="/courses">
|
||||
{{ _("All Classes") }}
|
||||
{{ _("All Batches") }}
|
||||
</a>
|
||||
<img class="ml-1 mr-1" src="/assets/lms/icons/chevron-right.svg">
|
||||
<a class="dark-links" href="/classes/{{ class_info.name }}">
|
||||
<a class="dark-links" href="/batches/{{ class_info.name }}">
|
||||
{{ class_info.title }}
|
||||
</a>
|
||||
<img class="ml-1 mr-1" src="/assets/lms/icons/chevron-right.svg">
|
||||
|
||||
@@ -22,6 +22,8 @@
|
||||
<div class="breadcrumb">
|
||||
<a class="dark-links" href="/batches">{{ _("All Batches") }}</a>
|
||||
<img class="ml-1 mr-1" src="/assets/lms/icons/chevron-right.svg">
|
||||
<a class="dark-links" href="/batches/details/{{ batch_info.name }}">{{ _("Batch Details") }}</a>
|
||||
<img class="ml-1 mr-1" src="/assets/lms/icons/chevron-right.svg">
|
||||
<span class="breadcrumb-destination">{{ batch_info.title }}</span>
|
||||
</div>
|
||||
{% endmacro %}
|
||||
@@ -239,11 +241,6 @@
|
||||
<div class="bold-heading">
|
||||
{{ _("Courses") }}
|
||||
</div>
|
||||
{% if is_moderator %}
|
||||
<button class="btn btn-default btn-sm btn-add-course">
|
||||
{{ _("Add Courses") }}
|
||||
</button>
|
||||
{% endif %}
|
||||
</div>
|
||||
</header>
|
||||
|
||||
@@ -252,11 +249,6 @@
|
||||
{% for course in batch_courses %}
|
||||
<div class="h-100">
|
||||
{{ widgets.CourseCard(course=course, read_only=False) }}
|
||||
<button class="btn icon-btn btn-default btn-block btn-remove-course" data-course="{{ course.name }}">
|
||||
<svg class="icon icon-sm">
|
||||
<use href="#icon-delete"></use>
|
||||
</svg>
|
||||
</button>
|
||||
</div>
|
||||
|
||||
{% endfor %}
|
||||
@@ -320,7 +312,7 @@
|
||||
{% set allow_progress = is_moderator or is_evaluator %}
|
||||
<div class="grid-row">
|
||||
<div class="data-row row">
|
||||
<a class="col grid-static-col button-links {% if allow_progress %} clickable {% endif %}" {% if allow_progress %} href="/classes/{{ batch_info.name }}/students/{{ student.username }}" {% endif %}>
|
||||
<a class="col grid-static-col button-links {% if allow_progress %} clickable {% endif %}" {% if allow_progress %} href="/batches/{{ batch_info.name }}/students/{{ student.username }}" {% endif %}>
|
||||
{{ student.student_name }}
|
||||
</a>
|
||||
<div class="col grid-static-col col-xs-2 text-right">
|
||||
|
||||
@@ -25,13 +25,6 @@ frappe.ready(() => {
|
||||
create_live_class(e);
|
||||
});
|
||||
|
||||
$(".btn-add-course").click((e) => {
|
||||
show_course_modal(e);
|
||||
});
|
||||
$(".btn-remove-course").click((e) => {
|
||||
remove_course(e);
|
||||
});
|
||||
|
||||
$(".btn-remove-assessment").click((e) => {
|
||||
remove_assessment(e);
|
||||
});
|
||||
@@ -55,11 +48,11 @@ frappe.ready(() => {
|
||||
});
|
||||
|
||||
const create_live_class = (e) => {
|
||||
let class_name = $(".class-details").data("batch");
|
||||
let batch_name = $(".class-details").data("batch");
|
||||
frappe.call({
|
||||
method: "lms.lms.doctype.lms_class.lms_class.create_live_class",
|
||||
method: "lms.lms.doctype.lms_batch.lms_batch.create_live_class",
|
||||
args: {
|
||||
class_name: class_name,
|
||||
batch_name: batch_name,
|
||||
title: $("input[data-fieldname='meeting_title']").val(),
|
||||
duration: $("input[data-fieldname='meeting_duration']").val(),
|
||||
date: $("input[data-fieldname='meeting_date']").val(),
|
||||
@@ -300,85 +293,6 @@ const get_timezones = () => {
|
||||
];
|
||||
};
|
||||
|
||||
const show_course_modal = () => {
|
||||
let course_modal = new frappe.ui.Dialog({
|
||||
title: "Add Course",
|
||||
fields: [
|
||||
{
|
||||
fieldtype: "Link",
|
||||
options: "LMS Course",
|
||||
label: __("Course"),
|
||||
fieldname: "course",
|
||||
reqd: 1,
|
||||
only_select: 1,
|
||||
},
|
||||
{
|
||||
fieldtype: "Link",
|
||||
options: "Course Evaluator",
|
||||
label: __("Course Evaluator"),
|
||||
fieldname: "evaluator",
|
||||
only_select: 1,
|
||||
},
|
||||
],
|
||||
primary_action_label: __("Add"),
|
||||
primary_action(values) {
|
||||
add_course(values);
|
||||
course_modal.hide();
|
||||
},
|
||||
});
|
||||
course_modal.show();
|
||||
setTimeout(() => {
|
||||
$(".modal-body").css("min-height", "200px");
|
||||
}, 1000);
|
||||
};
|
||||
|
||||
const add_course = (values) => {
|
||||
frappe.call({
|
||||
method: "frappe.client.insert",
|
||||
args: {
|
||||
doc: {
|
||||
doctype: "Batch Course",
|
||||
course: values.course,
|
||||
parenttype: "LMS Batch",
|
||||
parentfield: "courses",
|
||||
parent: $(".class-details").data("batch"),
|
||||
},
|
||||
},
|
||||
callback(r) {
|
||||
frappe.show_alert(
|
||||
{
|
||||
message: __("Course Added"),
|
||||
indicator: "green",
|
||||
},
|
||||
2000
|
||||
);
|
||||
window.location.reload();
|
||||
},
|
||||
});
|
||||
};
|
||||
|
||||
const remove_course = (e) => {
|
||||
frappe.confirm("Are you sure you want to remove this course?", () => {
|
||||
frappe.call({
|
||||
method: "lms.lms.doctype.lms_class.lms_class.remove_course",
|
||||
args: {
|
||||
course: $(e.currentTarget).data("course"),
|
||||
parent: $(".class-details").data("batch"),
|
||||
},
|
||||
callback(r) {
|
||||
frappe.show_alert(
|
||||
{
|
||||
message: __("Course Removed"),
|
||||
indicator: "green",
|
||||
},
|
||||
2000
|
||||
);
|
||||
window.location.reload();
|
||||
},
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
const show_student_modal = () => {
|
||||
let student_modal = new frappe.ui.Dialog({
|
||||
title: "Add Student",
|
||||
@@ -435,13 +349,13 @@ const add_student = (values) => {
|
||||
|
||||
const remove_student = (e) => {
|
||||
frappe.confirm(
|
||||
"Are you sure you want to remove this student from the class?",
|
||||
"Are you sure you want to remove this student from the batch?",
|
||||
() => {
|
||||
frappe.call({
|
||||
method: "lms.lms.doctype.lms_class.lms_class.remove_student",
|
||||
method: "lms.lms.doctype.lms_batch.lms_batch.remove_student",
|
||||
args: {
|
||||
student: $(e.currentTarget).data("student"),
|
||||
class_name: $(".class-details").data("batch"),
|
||||
batch_name: $(".class-details").data("batch"),
|
||||
},
|
||||
callback: (data) => {
|
||||
frappe.show_alert(
|
||||
@@ -547,7 +461,7 @@ const add_addessment = (values) => {
|
||||
const remove_assessment = (e) => {
|
||||
frappe.confirm("Are you sure you want to remove this assessment?", () => {
|
||||
frappe.call({
|
||||
method: "lms.lms.doctype.lms_class.lms_class.remove_assessment",
|
||||
method: "lms.lms.doctype.lms_batch.lms_batch.remove_assessment",
|
||||
args: {
|
||||
assessment: $(e.currentTarget).data("assessment"),
|
||||
parent: $(".class-details").data("batch"),
|
||||
@@ -580,6 +494,7 @@ const open_evaluation_form = (e) => {
|
||||
name: ["in", courses],
|
||||
},
|
||||
filter_description: " ",
|
||||
only_select: 1,
|
||||
},
|
||||
{
|
||||
fieldtype: "Date",
|
||||
@@ -615,7 +530,7 @@ const get_slots = () => {
|
||||
args: {
|
||||
course: this.eval_form.get_value("course"),
|
||||
date: this.eval_form.get_value("date"),
|
||||
class_name: $(".class-details").data("batch"),
|
||||
batch_name: $(".class-details").data("batch"),
|
||||
},
|
||||
callback: (r) => {
|
||||
if (r.message) {
|
||||
@@ -677,7 +592,7 @@ const submit_evaluation_form = (values) => {
|
||||
start_time: this.current_slot.data("start"),
|
||||
end_time: this.current_slot.data("end"),
|
||||
day: this.current_slot.data("day"),
|
||||
class_name: $(".class-details").data("batch"),
|
||||
batch_name: $(".class-details").data("batch"),
|
||||
},
|
||||
callback: (r) => {
|
||||
this.eval_form.hide();
|
||||
|
||||
@@ -36,7 +36,7 @@ def get_context(context):
|
||||
"start_time",
|
||||
"end_time",
|
||||
"category",
|
||||
"paid_class",
|
||||
"paid_batch",
|
||||
"amount",
|
||||
"currency",
|
||||
"batch_details",
|
||||
|
||||
@@ -173,7 +173,12 @@
|
||||
|
||||
|
||||
{% macro CourseList(courses) %}
|
||||
<div>
|
||||
<div class="batch-course-list">
|
||||
{% if is_moderator %}
|
||||
<button class="btn btn-default btn-sm btn-add-course pull-right">
|
||||
{{ _("Add Courses") }}
|
||||
</button>
|
||||
{% endif %}
|
||||
<div class="page-title">
|
||||
{{ _("Courses") }}
|
||||
</div>
|
||||
@@ -182,13 +187,23 @@
|
||||
{% for course in courses %}
|
||||
<div class="h-100">
|
||||
{{ widgets.CourseCard(course=course, read_only=False) }}
|
||||
<button class="btn icon-btn btn-default btn-block btn-remove-course" data-course="{{ course.name }}">
|
||||
<svg class="icon icon-sm">
|
||||
<use href="#icon-delete"></use>
|
||||
</svg>
|
||||
</button>
|
||||
{% if is_moderator %}
|
||||
<div class="flex my-2 pull-right">
|
||||
<button class="btn icon-btn btn-default btn-edit-course"
|
||||
data-name="{{ course.batch_course }}" data-course="{{ course.name }}"
|
||||
{% if course.evaluator %} data-evaluator="{{ course.evaluator }}" {% endif %}>
|
||||
<svg class="icon icon-sm">
|
||||
<use href="#icon-edit"></use>
|
||||
</svg>
|
||||
</button>
|
||||
<button class="btn icon-btn btn-default btn-remove-course ml-2" data-course="{{ course.name }}">
|
||||
<svg class="icon icon-sm">
|
||||
<use href="#icon-delete"></use>
|
||||
</svg>
|
||||
</button>
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
|
||||
{% endfor %}
|
||||
</div>
|
||||
{% else %}
|
||||
|
||||
@@ -1,3 +1,97 @@
|
||||
frappe.ready(() => {
|
||||
frappe.require("controls.bundle.js");
|
||||
|
||||
$(".btn-add-course").click((e) => {
|
||||
show_course_modal(e);
|
||||
});
|
||||
|
||||
$(".btn-edit-course").click((e) => {
|
||||
show_course_modal(e);
|
||||
});
|
||||
|
||||
$(".btn-remove-course").click((e) => {
|
||||
remove_course(e);
|
||||
});
|
||||
});
|
||||
|
||||
const show_course_modal = (e) => {
|
||||
const target = $(e.currentTarget);
|
||||
const course = target.data("course");
|
||||
const evaluator = target.data("evaluator");
|
||||
const course_name = target.data("name");
|
||||
|
||||
let course_modal = new frappe.ui.Dialog({
|
||||
title: "Add Course",
|
||||
fields: [
|
||||
{
|
||||
fieldtype: "Link",
|
||||
options: "LMS Course",
|
||||
label: __("Course"),
|
||||
fieldname: "course",
|
||||
reqd: 1,
|
||||
only_select: 1,
|
||||
default: course || "",
|
||||
},
|
||||
{
|
||||
fieldtype: "Link",
|
||||
options: "Course Evaluator",
|
||||
label: __("Course Evaluator"),
|
||||
fieldname: "evaluator",
|
||||
only_select: 1,
|
||||
default: evaluator || "",
|
||||
},
|
||||
],
|
||||
primary_action_label: __("Add"),
|
||||
primary_action(values) {
|
||||
add_course(values, course_name);
|
||||
course_modal.hide();
|
||||
},
|
||||
});
|
||||
course_modal.show();
|
||||
};
|
||||
|
||||
const add_course = (values, course_name) => {
|
||||
frappe.call({
|
||||
method: "lms.lms.doctype.lms_batch.lms_batch.add_course",
|
||||
args: {
|
||||
course: values.course,
|
||||
evaluator: values.evaluator,
|
||||
parent: $(".class-details").data("batch"),
|
||||
name: course_name || "",
|
||||
},
|
||||
callback(r) {
|
||||
frappe.show_alert(
|
||||
{
|
||||
message: course_name
|
||||
? __("Course Updated")
|
||||
: __("Course Added"),
|
||||
indicator: "green",
|
||||
},
|
||||
2000
|
||||
);
|
||||
window.location.reload();
|
||||
},
|
||||
});
|
||||
};
|
||||
|
||||
const remove_course = (e) => {
|
||||
frappe.confirm("Are you sure you want to remove this course?", () => {
|
||||
frappe.call({
|
||||
method: "lms.lms.doctype.lms_batch.lms_batch.remove_course",
|
||||
args: {
|
||||
course: $(e.currentTarget).data("course"),
|
||||
parent: $(".class-details").data("batch"),
|
||||
},
|
||||
callback(r) {
|
||||
frappe.show_alert(
|
||||
{
|
||||
message: __("Course Removed"),
|
||||
indicator: "green",
|
||||
},
|
||||
2000
|
||||
);
|
||||
window.location.reload();
|
||||
},
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
@@ -30,7 +30,7 @@ def get_context(context):
|
||||
context.courses = frappe.get_all(
|
||||
"Batch Course",
|
||||
{"parent": batch_name},
|
||||
["name", "course", "title"],
|
||||
["name as batch_course", "course", "title", "evaluator"],
|
||||
order_by="creation desc",
|
||||
)
|
||||
|
||||
|
||||
@@ -68,18 +68,18 @@
|
||||
|
||||
<div class="tab-content">
|
||||
<div class="tab-pane active" id="upcoming" role="tabpanel" aria-labelledby="upcoming">
|
||||
{{ BatchCard(upcoming_batches, show_price=True) }}
|
||||
{{ BatchCard(upcoming_batches, show_price=True, label="Upcoming") }}
|
||||
</div>
|
||||
|
||||
{% if is_moderator %}
|
||||
<div class="tab-pane" id="past" role="tabpanel" aria-labelledby="past">
|
||||
{{ BatchCard(past_batches, show_price=False) }}
|
||||
{{ BatchCard(past_batches, show_price=False, label="Archived") }}
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
{% if frappe.session.user != "Guest" %}
|
||||
<div class="tab-pane" id="my-batch" role="tabpanel" aria-labelledby="my-batches">
|
||||
{{ BatchCard(my_batches, show_price=False) }}
|
||||
{{ BatchCard(my_batches, show_price=False, label="Enrolled") }}
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
@@ -87,7 +87,8 @@
|
||||
</article>
|
||||
{% endmacro %}
|
||||
|
||||
{% macro BatchCard(batches, show_price=False) %}
|
||||
{% macro BatchCard(batches, show_price=False, label="") %}
|
||||
{% if batches | length %}
|
||||
<div class="lms-card-parent">
|
||||
{% for batch in batches %}
|
||||
|
||||
@@ -148,6 +149,11 @@
|
||||
</div>
|
||||
{% endfor %}
|
||||
</div>
|
||||
{% else %}
|
||||
<p class="text-muted mt-3">
|
||||
{{ _("No {0} batches").format(label|lower) }}
|
||||
</p>
|
||||
{% endif %}
|
||||
{% endmacro %}
|
||||
|
||||
{% macro EmptyState() %}
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
<div class="common-page-style">
|
||||
{{ Header() }}
|
||||
<div class="container">
|
||||
{{ Progress(class_info, student) }}
|
||||
{{ Progress(batch, student) }}
|
||||
</div>
|
||||
</div>
|
||||
{% endblock %}
|
||||
@@ -22,12 +22,12 @@
|
||||
{{ _("{0}").format(student.full_name) }}
|
||||
</div>
|
||||
<div class="vertically-center">
|
||||
<a class="dark-links" href="/classes">
|
||||
{{ _("All Classes") }}
|
||||
<a class="dark-links" href="/batches">
|
||||
{{ _("All Batches") }}
|
||||
</a>
|
||||
<img class="icon icon-sm mr-0" src="/assets/lms/icons/chevron-right.svg">
|
||||
<a class="dark-links" href="/classes/{{ class_info.name }}">
|
||||
{{ class_info.name }}
|
||||
<a class="dark-links" href="/batches/{{ batch.name }}">
|
||||
{{ batch.name }}
|
||||
</a>
|
||||
<img class="icon icon-sm mr-0" src="/assets/lms/icons/chevron-right.svg">
|
||||
<span class="breadcrumb-destination">
|
||||
@@ -46,7 +46,7 @@
|
||||
</button>
|
||||
{% endif %}
|
||||
{% if is_moderator %}
|
||||
<a class="btn btn-primary btn-sm btn-evaluate ml-2" href="/evaluation/new?member={{student.name}}&date={{frappe.utils.getdate()}}&class_name={{class_info.name}}">
|
||||
<a class="btn btn-primary btn-sm btn-evaluate ml-2" href="/evaluation/new?member={{student.name}}&date={{frappe.utils.getdate()}}&class_name={{batch.name}}">
|
||||
{{ _("Evaluate") }}
|
||||
</a>
|
||||
{% endif %}
|
||||
@@ -57,9 +57,9 @@
|
||||
{% endmacro %}
|
||||
|
||||
|
||||
{% macro Progress(class_info, student) %}
|
||||
{% macro Progress(batch, student) %}
|
||||
{{ UpcomingEvals(upcoming_evals) }}
|
||||
{{ Assessments(class_info, student) }}
|
||||
{{ Assessments(batch, student) }}
|
||||
{% endmacro %}
|
||||
|
||||
{% macro UpcomingEvals(upcoming_evals) %}
|
||||
@@ -68,7 +68,7 @@
|
||||
</div>
|
||||
{% endmacro %}
|
||||
|
||||
{% macro Assessments(class_info, student) %}
|
||||
{% macro Assessments(batch, student) %}
|
||||
<div class="mb-8">
|
||||
{% include "lms/templates/assessments.html" %}
|
||||
</div>
|
||||
@@ -84,7 +84,7 @@
|
||||
"can_read": ["LMS Course"]
|
||||
};
|
||||
let courses = {{ courses | json }};
|
||||
let class_name = "{{ class_info.name }}";
|
||||
let batch_name = "{{ batch.name }}";
|
||||
</script>
|
||||
{{ include_script('controls.bundle.js') }}
|
||||
{% endblock %}
|
||||
@@ -12,7 +12,7 @@ def get_context(context):
|
||||
context.no_cache = 1
|
||||
|
||||
student = frappe.form_dict["username"]
|
||||
class_name = frappe.form_dict["classname"]
|
||||
batch_name = frappe.form_dict["batchname"]
|
||||
context.is_moderator = has_course_moderator_role()
|
||||
context.is_evaluator = has_course_evaluator_role()
|
||||
|
||||
@@ -29,13 +29,11 @@ def get_context(context):
|
||||
):
|
||||
raise frappe.PermissionError(_("You don't have permission to access this page."))
|
||||
|
||||
context.class_info = frappe.db.get_value(
|
||||
"LMS Batch", class_name, ["name"], as_dict=True
|
||||
)
|
||||
context.batch = frappe.db.get_value("LMS Batch", batch_name, ["name"], as_dict=True)
|
||||
|
||||
context.courses = frappe.get_all(
|
||||
"Batch Course", {"parent": class_name}, pluck="course"
|
||||
"Batch Course", {"parent": batch_name}, pluck="course"
|
||||
)
|
||||
|
||||
context.assessments = get_assessments(class_name, context.student.name)
|
||||
context.assessments = get_assessments(batch_name, context.student.name)
|
||||
context.upcoming_evals = get_upcoming_evals(context.student.name, context.courses)
|
||||
|
||||
@@ -30,7 +30,7 @@
|
||||
<div class="">
|
||||
<div class="flex mb-2">
|
||||
<div class="field-label">
|
||||
{% set label = "Course Name" if module == "course" else "Class Name" %}
|
||||
{% set label = "Course Name" if module == "course" else "Batch Name" %}
|
||||
{{ _(label) }} : {{ title }}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -9,7 +9,7 @@ def get_context(context):
|
||||
if frappe.session.user == "Guest":
|
||||
raise frappe.PermissionError(_("You are not allowed to access this page."))
|
||||
|
||||
if module not in ["course", "class"]:
|
||||
if module not in ["course", "batch"]:
|
||||
raise ValueError(_("Module is incorrect."))
|
||||
|
||||
doctype = "LMS Course" if module == "course" else "LMS Batch"
|
||||
@@ -32,7 +32,7 @@ def get_context(context):
|
||||
"Batch Student", {"student": frappe.session.user, "parent": docname}
|
||||
)
|
||||
if membership:
|
||||
raise frappe.PermissionError(_("You are already enrolled for this class"))
|
||||
raise frappe.PermissionError(_("You are already enrolled for this batch."))
|
||||
|
||||
if doctype == "LMS Course":
|
||||
course = frappe.db.get_value(
|
||||
@@ -50,18 +50,18 @@ def get_context(context):
|
||||
context.currency = course.currency
|
||||
|
||||
else:
|
||||
class_info = frappe.db.get_value(
|
||||
batch = frappe.db.get_value(
|
||||
"LMS Batch",
|
||||
docname,
|
||||
["title", "name", "paid_class", "amount", "currency"],
|
||||
["title", "name", "paid_batch", "amount", "currency"],
|
||||
as_dict=True,
|
||||
)
|
||||
|
||||
if not class_info.paid_class:
|
||||
if not batch.paid_batch:
|
||||
raise frappe.PermissionError(
|
||||
_("To join this class, please contact the Administrator.")
|
||||
_("To join this batch, please contact the Administrator.")
|
||||
)
|
||||
|
||||
context.title = class_info.title
|
||||
context.amount = class_info.amount
|
||||
context.currency = class_info.currency
|
||||
context.title = batch.title
|
||||
context.amount = batch.amount
|
||||
context.currency = batch.currency
|
||||
|
||||
35
lms/www/certified_participants/certified_participants.html
Normal file
35
lms/www/certified_participants/certified_participants.html
Normal file
@@ -0,0 +1,35 @@
|
||||
{% extends "lms/templates/lms_base.html" %}
|
||||
{% block title %}
|
||||
{{ _("Certified Participants") }}
|
||||
{% endblock %}
|
||||
|
||||
{% block page_content %}
|
||||
<main class="common-page-style">
|
||||
<div class="container">
|
||||
<header>
|
||||
<div class="page-title">
|
||||
{{ _("Certified Participants") }}
|
||||
</div>
|
||||
</header>
|
||||
{{ ParticipantsList() }}
|
||||
</div>
|
||||
</main>
|
||||
{% endblock %}
|
||||
|
||||
{% macro ParticipantsList() %}
|
||||
<article class="member-parent">
|
||||
{% for participant in participants %}
|
||||
<div class="common-card-style column-card align-center">
|
||||
{{ widgets.Avatar(member=participant, avatar_class="avatar-large") }}
|
||||
<div class="bold-heading">
|
||||
{{ participant.full_name }}
|
||||
</div>
|
||||
{% for course in participant.courses %}
|
||||
<div>
|
||||
{{ course }}
|
||||
</div>
|
||||
{% endfor %}
|
||||
</div>
|
||||
{% endfor %}
|
||||
</article>
|
||||
{% endmacro %}
|
||||
22
lms/www/certified_participants/certified_participants.py
Normal file
22
lms/www/certified_participants/certified_participants.py
Normal file
@@ -0,0 +1,22 @@
|
||||
import frappe
|
||||
|
||||
|
||||
def get_context(context):
|
||||
context.no_cache = 1
|
||||
context.members = frappe.get_all(
|
||||
"LMS Certificate", pluck="member", order_by="creation desc", distinct=1
|
||||
)
|
||||
|
||||
participants = []
|
||||
for member in context.members:
|
||||
details = frappe.db.get_value(
|
||||
"User", member, ["name", "full_name", "user_image", "username", "enabled"], as_dict=1
|
||||
)
|
||||
courses = frappe.get_all("LMS Certificate", {"member": member}, pluck="course")
|
||||
details.courses = []
|
||||
for course in courses:
|
||||
details.courses.append(frappe.db.get_value("LMS Course", course, "title"))
|
||||
if details.enabled:
|
||||
participants.append(details)
|
||||
|
||||
context.participants = participants
|
||||
@@ -48,15 +48,15 @@
|
||||
</a>
|
||||
{% endif %}
|
||||
|
||||
{% if show_creators_section %}
|
||||
<a class="btn btn-default btn-sm" href="/courses/new-course/edit">
|
||||
{{ _("Create a Course") }}
|
||||
</a>
|
||||
{% endif %}
|
||||
|
||||
<a class="btn btn-default btn-sm" id="open-search">
|
||||
{{ _("Search") }} (Ctrl + k)
|
||||
</a>
|
||||
|
||||
{% if show_creators_section %}
|
||||
<a class="btn btn-primary btn-sm" href="/courses/new-course/edit">
|
||||
{{ _("Create a Course") }}
|
||||
</a>
|
||||
{% endif %}
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
@@ -65,8 +65,8 @@
|
||||
<div class="tab-pane active" id="profile" role="tabpanel" aria-labelledby="profile">
|
||||
<div class="">
|
||||
{{ About(member) }}
|
||||
{{ EducationDetails(member) }}
|
||||
{{ WorkDetails(member) }}
|
||||
{{ EducationDetails(member) }}
|
||||
{{ ExternalCertification(member) }}
|
||||
{{ Contact(member) }}
|
||||
{{ Skills(member) }}
|
||||
@@ -171,7 +171,7 @@
|
||||
{% macro CoursesMentored(member, read_only) %}
|
||||
{% if member.get_mentored_courses() | length %}
|
||||
<div class="profile-courses">
|
||||
<div class="course-home-headings"> {{ _("Courses Mentored") }} </div>
|
||||
<div class="page-title"> {{ _("Courses Mentored") }} </div>
|
||||
<div class="cards-parent">
|
||||
{% for course in member.get_mentored_courses() %}
|
||||
{{ widgets.CourseCard(course=course, read_only=read_only) }}
|
||||
@@ -202,7 +202,7 @@
|
||||
{% if has_course_moderator_role() %}
|
||||
<div class="">
|
||||
<div class="">
|
||||
<div class="course-home-headings"> {{ _("Role Settings") }} </div>
|
||||
<div class="page-title mb-2"> {{ _("Role Settings") }} </div>
|
||||
<div class="d-flex">
|
||||
<label class="role">
|
||||
<input type="checkbox" id="course-creator" data-role="Course Creator"
|
||||
@@ -223,7 +223,6 @@
|
||||
|
||||
<!-- About Section -->
|
||||
{% macro About(member) %}
|
||||
<div class="course-home-headings"> {{ _("About") }} </div>
|
||||
<div class="description">
|
||||
{% if member.bio %}
|
||||
{{ member.bio }}
|
||||
@@ -236,7 +235,7 @@
|
||||
|
||||
<!-- Work Preference -->
|
||||
{% macro WorkPreference(member) %}
|
||||
<div class="course-home-headings mt-10"> {{ _("Work Preference") }} </div>
|
||||
<div class="page-title mt-10"> {{ _("Work Preference") }} </div>
|
||||
<div> {{ member.attire }} </div>
|
||||
<div> {{ member.collaboration }} </div>
|
||||
<div> {{ member.role }} </div>
|
||||
@@ -249,7 +248,7 @@
|
||||
<!-- Career Preference -->
|
||||
{% macro CareerPreference(member) %}
|
||||
{% if member.preferred_functions or member.preferred_industries or member.preferred_location or member.dream_companies %}
|
||||
<div class="course-home-headings mt-10">
|
||||
<div class="page-title mt-10">
|
||||
{{ _("Career Preference") }}
|
||||
</div>
|
||||
<div class="profile-column-grid">
|
||||
@@ -294,7 +293,7 @@
|
||||
<!-- Contact Section -->
|
||||
{% macro Contact(member) %}
|
||||
{% if member.linkedin or member.medium or member.github %}
|
||||
<div class="course-home-headings mt-10"> {{ _("Contact") }} </div>
|
||||
<div class="page-title mt-10"> {{ _("Contact") }} </div>
|
||||
<div class="profile-column-grid">
|
||||
{% if member.linkedin %}
|
||||
{% set linkedin = member.linkedin[:-1] if member.linkedin[-1] == "/" else member.linkedin %}
|
||||
@@ -323,7 +322,7 @@
|
||||
<!-- Skills -->
|
||||
{% macro Skills(member) %}
|
||||
{% if member.skill | length %}
|
||||
<div class="course-home-headings mt-10"> {{ _("Skills")}} </div>
|
||||
<div class="page-title mt-10"> {{ _("Skills")}} </div>
|
||||
<div class="profile-column-grid">
|
||||
{% for skill in member.skill %}
|
||||
<div class="description"> {{ skill.skill_name }} </div>
|
||||
@@ -336,11 +335,11 @@
|
||||
<!-- Education Details -->
|
||||
{% macro EducationDetails(member) %}
|
||||
{% if member.education %}
|
||||
<div class="course-home-headings mt-10"> {{ _("Education") }} </div>
|
||||
<div class="page-title mt-10 mb-2"> {{ _("Education") }} </div>
|
||||
<div class="profile-grid-card">
|
||||
{% for edu in member.education %}
|
||||
<div class="column-card-row">
|
||||
<div class="bold-title"> {{ edu.institution_name }} </div>
|
||||
<div class="bold-heading"> {{ edu.institution_name }} </div>
|
||||
<div class="profile-item"> {{ edu.degree_type }} <span></span> {{ edu.major }}
|
||||
{% if not member.hide_private %}
|
||||
<!-- {% if edu.grade_type %} {{ edu.grade_type }} {% endif %} -->
|
||||
@@ -362,17 +361,16 @@
|
||||
{% endmacro %}
|
||||
|
||||
|
||||
<!-- Work Details -->
|
||||
{% macro WorkDetails(member) %}
|
||||
{% set work_details = member.work_experience + member.internship %}
|
||||
|
||||
{% if work_details | length %}
|
||||
<div class="course-home-headings mt-10"> {{ _("Work Experience") }} </div>
|
||||
<div class="page-title mt-10 mb-2"> {{ _("Work Experience") }} </div>
|
||||
<div class="profile-grid-card">
|
||||
|
||||
{% for work in work_details %}
|
||||
<div class="">
|
||||
<div class="bold-title"> {{ work.title }} </div>
|
||||
<div class="bold-heading"> {{ work.title }} </div>
|
||||
<div class="profile-item"> {{ work.company }} </div>
|
||||
<div class="description">
|
||||
{{ frappe.utils.format_date(work.from_date, "MMM YYYY") }} -
|
||||
@@ -398,7 +396,7 @@
|
||||
<!-- Certifications -->
|
||||
{% macro ExternalCertification(member) %}
|
||||
{% if member.certification %}
|
||||
<div class="course-home-headings mt-10"> {{ _("External Certification") }} </div>
|
||||
<div class="page-title mt-10"> {{ _("External Certification") }} </div>
|
||||
<div class="profile-grid-card">
|
||||
{% for cert in member.certification %}
|
||||
<div class="">
|
||||
|
||||
@@ -23,8 +23,8 @@
|
||||
</div>
|
||||
</div>
|
||||
<div class="vertically-center small">
|
||||
<a class="dark-links" href="/classes">
|
||||
{{ _("All Classes") }}
|
||||
<a class="dark-links" href="/batches">
|
||||
{{ _("All Batches") }}
|
||||
</a>
|
||||
<img class="icon icon-sm mr-0" src="/assets/lms/icons/chevron-right.svg">
|
||||
<span class="breadcrumb-destination">{{ _("Quiz Submission") }}</span>
|
||||
|
||||
@@ -61,13 +61,13 @@ def get_current_lesson_details(lesson_number, context, is_edit=False):
|
||||
return lesson_info
|
||||
|
||||
|
||||
def get_assessments(class_name, member=None):
|
||||
def get_assessments(batch, member=None):
|
||||
if not member:
|
||||
member = frappe.session.user
|
||||
|
||||
assessments = frappe.get_all(
|
||||
"LMS Assessment",
|
||||
{"parent": class_name},
|
||||
{"parent": batch},
|
||||
["name", "assessment_type", "assessment_name"],
|
||||
)
|
||||
|
||||
@@ -132,7 +132,7 @@ def get_quiz_details(assessment, member):
|
||||
assessment.url = f"/quiz-submission/{assessment.assessment_name}/{submission_name}"
|
||||
|
||||
|
||||
def is_student(class_name, member=None):
|
||||
def is_student(batch, member=None):
|
||||
if not member:
|
||||
member = frappe.session.user
|
||||
|
||||
@@ -140,6 +140,6 @@ def is_student(class_name, member=None):
|
||||
"Batch Student",
|
||||
{
|
||||
"student": member,
|
||||
"parent": class_name,
|
||||
"parent": batch,
|
||||
},
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user