+
+ {% if live_classes | length %}
{% for class in live_classes %}
@@ -295,6 +309,9 @@
{% endfor %}
+ {% else %}
+
{{ _("No Live Classes") }}
+ {% endif %}
{% endmacro %}
@@ -318,10 +335,4 @@
{% endif %}
{{ include_script('controls.bundle.js') }}
-{% endblock %}
-
-{% set classes = frappe.get_all("LMS Class", filters = {
- "start_date": [">", frappe.utils.getdate()],
- "title": ["like", "%ERPNext%"]
- }, fields=["name", "title", "start_date", "end_date"])
-%}
\ No newline at end of file
+{% endblock %}
\ No newline at end of file
diff --git a/lms/www/classes/class.js b/lms/www/classes/class.js
index 54c8f487..686f99c7 100644
--- a/lms/www/classes/class.js
+++ b/lms/www/classes/class.js
@@ -3,7 +3,7 @@ frappe.ready(() => {
show_student_modal(e);
});
- $(".remove-student").click((e) => {
+ $(".btn-remove-student").click((e) => {
remove_student(e);
});
@@ -323,26 +323,6 @@ const get_timezones = () => {
];
};
-const make_add_students_section = () => {
- this.field_group = new frappe.ui.FieldGroup({
- fields: [
- {
- fieldname: "student_input",
- fieldtype: "Link",
- options: "User",
- label: "Add Student",
- filters: {
- ignore_user_type: 1,
- },
- },
- ],
- body: $(".add-students").get(0),
- });
- this.field_group.make();
- $(".add-students .form-section:last").removeClass("empty-section");
- $(".add-students .frappe-control").removeClass("hide-control");
-};
-
const show_course_modal = () => {
let course_modal = new frappe.ui.Dialog({
title: "Add Course",
@@ -354,6 +334,12 @@ const show_course_modal = () => {
fieldname: "course",
reqd: 1,
},
+ {
+ fieldtype: "HTML",
+ fieldname: "instructions",
+ label: __("Instructions"),
+ options: __("Select a course to add to this class."),
+ },
],
primary_action_label: __("Add"),
primary_action(values) {
@@ -383,25 +369,31 @@ const show_course_modal = () => {
},
});
course_modal.show();
+ setTimeout(() => {
+ $(".modal-body").css("min-height", "200px");
+ $(".modal-body input").focus();
+ }, 1000);
};
const remove_course = (e) => {
- frappe.call({
- method: "lms.lms.doctype.lms_class.lms_class.remove_course",
- args: {
- course: $(e.target).data("course"),
- parent: $(".class-details").data("class"),
- },
- callback(r) {
- frappe.show_alert(
- {
- message: __("Course Removed"),
- indicator: "green",
- },
- 3
- );
- window.location.reload();
- },
+ 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("class"),
+ },
+ callback(r) {
+ frappe.show_alert(
+ {
+ message: __("Course Removed"),
+ indicator: "green",
+ },
+ 3
+ );
+ window.location.reload();
+ },
+ });
});
};
@@ -419,6 +411,14 @@ const show_student_modal = () => {
ignore_user_type: 1,
},
},
+ {
+ fieldtype: "HTML",
+ fieldname: "instructions",
+ label: __("Instructions"),
+ options: __(
+ "Please ensure a user account exists for the student before adding them to the class. Only users can be enrolled as students."
+ ),
+ },
],
primary_action_label: __("Add"),
primary_action(values) {
@@ -448,4 +448,8 @@ const show_student_modal = () => {
},
});
student_modal.show();
+ setTimeout(() => {
+ $(".modal-body").css("min-height", "200px");
+ $(".modal-body input").focus();
+ }, 1000);
};
diff --git a/lms/www/classes/class.py b/lms/www/classes/class.py
index 03b6e969..edc7b6eb 100644
--- a/lms/www/classes/class.py
+++ b/lms/www/classes/class.py
@@ -32,11 +32,17 @@ def get_context(context):
)
context.class_courses = frappe.get_all(
- "Class Course", {"parent": class_name}, ["name", "course", "title"]
+ "Class Course",
+ {"parent": class_name},
+ ["name", "course", "title"],
+ order_by="creation desc",
)
class_students = frappe.get_all(
- "Class Student", {"parent": class_name}, ["student", "student_name", "username"]
+ "Class Student",
+ {"parent": class_name},
+ ["student", "student_name", "username"],
+ order_by="creation desc",
)
for student in class_students:
diff --git a/lms/www/classes/index.html b/lms/www/classes/index.html
index c8438ac6..c1059373 100644
--- a/lms/www/classes/index.html
+++ b/lms/www/classes/index.html
@@ -6,40 +6,46 @@
{% block page_content %}
- {% if is_moderator %}
-
- {% endif %}
-
{{ _("All Classes") }}
+ {{ Header() }}
{% if past_classes | length or upcoming_classes | length %}
{{ ClassTabs(past_classes, upcoming_classes) }}
{% else %}
-
-

-
-
{{ _("No Classes") }}
-
{{ _("Nothing to see here.") }}
-
-
+ {{ EmptyState() }}
{% endif %}
{% endblock %}
+{% macro Header() %}
+
+{% endmacro %}
+
{% macro ClassTabs(past_classes, upcoming_classes) %}
-
- {{ _("Upcoming") }} ({{ upcoming_classes | length }})
+ {{ _("Upcoming") }}
+
+ {{ upcoming_classes | length }}
+
-
- {{ _("Past Classes") }} ({{ past_classes | length }})
+ {{ _("Past Classes") }}
+
+ {{ past_classes | length }}
+
@@ -64,14 +70,18 @@
{% for class in classes %}
{% set course_count = frappe.db.count("Class Course", {"parent": class.name}) %}
- {% set student_count = frappe.db.count("Class Student", {"parent": class.name}) %}
+ {% set student_count = frappe.db.count("Class Student", {"parent": class.name}) %}
-
+
+ {{ class.title }}
+
+
+
- {% if class.paid_class and class.start_date > frappe.utils.getdate() %}
-
- {{ _("Register") }}
-
- {% endif %}
-
{% endfor %}
{% endmacro %}
+{% macro EmptyState() %}
+
+

+
+
{{ _("No Classes") }}
+
{{ _("Nothing to see here.") }}
+
+
+{% endmacro %}
+
+{% block style %}
+ {{ super() }}
+ {{ include_style('controls.bundle.css') }}
+{% endblock %}
+
{%- block script %}
{{ super() }}
{{ include_script('controls.bundle.js') }}
diff --git a/lms/www/classes/index.py b/lms/www/classes/index.py
index 58e7510d..379c481a 100644
--- a/lms/www/classes/index.py
+++ b/lms/www/classes/index.py
@@ -13,12 +13,6 @@ def get_context(context):
past_classes, upcoming_classes = [], []
for class_ in classes:
- if class_.seat_count:
- filled_seats = frappe.db.count(
- "Class Student",
- filters={"parent": class_.name},
- )
- class_.seats_left = class_.seat_count - filled_seats
if getdate(class_.start_date) < getdate():
past_classes.append(class_)
diff --git a/lms/www/courses/create.html b/lms/www/courses/create.html
index fcc21299..3fff7c13 100644
--- a/lms/www/courses/create.html
+++ b/lms/www/courses/create.html
@@ -64,7 +64,7 @@
{{ _("Short Introduction") }}
- {{ _("A one line breif description") }}
+ {{ _("A one line brief description") }}