diff --git a/lms/public/css/style.css b/lms/public/css/style.css
index 0297ffcc..ebe2bfa0 100644
--- a/lms/public/css/style.css
+++ b/lms/public/css/style.css
@@ -2003,9 +2003,16 @@ select {
.live-class-panel {
margin-top: auto;
- display: none;
}
-.lms-card:hover + .live-class-panel {
- display: block;
+.lms-card .live-class-panel .btn {
+ visibility: hidden;
}
+
+.lms-card:hover .live-class-panel .btn {
+ visibility: visible;
+}
+
+.add-students .text-primary.link-option {
+ visibility: hidden;
+}
\ No newline at end of file
diff --git a/lms/www/classes/class.html b/lms/www/classes/class.html
index f7e4bf2c..0557a449 100644
--- a/lms/www/classes/class.html
+++ b/lms/www/classes/class.html
@@ -75,7 +75,7 @@
- {% if is_moderator or is_student %}
+ {% if class_students | length and (is_moderator or is_student) %}
{{ _("Live Class") }}
@@ -96,7 +96,7 @@
{{ StudentsSection(class_info, class_students) }}
- {% if is_moderator or is_student %}
+ {% if class_students | length and (is_moderator or is_student) %}
{{ LiveClassSection(class_info, live_classes) }}
@@ -175,20 +175,10 @@
{% macro AddStudents() %}
-
- {{ _("Add Student") }}
-
-
+
+
{% endmacro %}
@@ -254,13 +244,19 @@
- {% if class.owner == frappe.session.user and class.date == frappe.utils.getdate() %}
+ {% if class.owner == frappe.session.user %}
{{ _("Start") }}
{% endif %}
- {% if class.owner == frappe.session.user %}
+ {% if is_student %}
+
+ {{ _("Join Class") }}
+
+ {% endif %}
+
+
- {% if is_student and class.date == frappe.utils.getdate() %}
-
- {{ _("Join Class") }}
-
- {% endif %}
-
{% endfor %}
@@ -284,5 +274,22 @@
{%- block script %}
{{ super() }}
+
+ {% if is_moderator %}
+
+ {% endif %}
+
{{ include_script('controls.bundle.js') }}
{% endblock %}
diff --git a/lms/www/classes/class.js b/lms/www/classes/class.js
index 7b038376..ef6f22fd 100644
--- a/lms/www/classes/class.js
+++ b/lms/www/classes/class.js
@@ -15,6 +15,10 @@ frappe.ready(() => {
make_live_class_form();
}
+ if ($(".add-students").length) {
+ make_add_students_section();
+ }
+
$("#open-class-modal").click((e) => {
e.preventDefault();
$("#live-class-modal").modal("show");
@@ -23,27 +27,34 @@ frappe.ready(() => {
$("#create-live-class").click((e) => {
create_live_class(e);
});
+
+ setTimeout(() => {
+ console.log(locals.Doctype)
+ }, 10000);
+
});
const submit_student = (e) => {
e.preventDefault();
- frappe.call({
- method: "lms.lms.doctype.lms_class.lms_class.add_student",
- args: {
- email: $("#student-email").val(),
- class_name: $(".class-details").data("class"),
- },
- callback: (data) => {
- frappe.show_alert(
- {
- message: __("Student added successfully"),
- indicator: "green",
- },
- 3
- );
- window.location.reload();
- },
- });
+ if ($('input[data-fieldname="student_input"]').val()) {
+ frappe.call({
+ method: "lms.lms.doctype.lms_class.lms_class.add_student",
+ args: {
+ email: $('input[data-fieldname="student_input"]').val(),
+ class_name: $(".class-details").data("class"),
+ },
+ callback: (data) => {
+ frappe.show_alert(
+ {
+ message: __("Student added successfully"),
+ indicator: "green",
+ },
+ 3
+ );
+ window.location.reload();
+ },
+ });
+ }
};
const remove_student = (e) => {
@@ -100,14 +111,14 @@ const create_live_class = (e) => {
$("#live-class-modal").modal("hide");
frappe.show_alert(
{
- message: __("Live Class created successfully"),
+ message: __("Live Class added successfully"),
indicator: "green",
},
3
);
setTimeout(function () {
- window.location.href = `/classes/${class_name}#live-class`;
- }, 2000);
+ window.location.reload()
+ }, 1000);
},
});
};
@@ -168,3 +179,24 @@ const make_live_class_form = (e) => {
$("#live-class-form .form-section:last").removeClass("empty-section");
$("#live-class-form .frappe-control").removeClass("hide-control");
};
+
+
+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");
+}
\ No newline at end of file