feat: live class checkbox
This commit is contained in:
@@ -12,12 +12,7 @@ frappe.ui.form.on("LMS Batch", {
|
|||||||
});
|
});
|
||||||
|
|
||||||
frm.set_query("reference_doctype", "timetable", function () {
|
frm.set_query("reference_doctype", "timetable", function () {
|
||||||
let doctypes = [
|
let doctypes = ["Course Lesson", "LMS Quiz", "LMS Assignment"];
|
||||||
"Course Lesson",
|
|
||||||
"LMS Quiz",
|
|
||||||
"LMS Assignment",
|
|
||||||
"LMS Live Class",
|
|
||||||
];
|
|
||||||
return {
|
return {
|
||||||
filters: {
|
filters: {
|
||||||
name: ["in", doctypes],
|
name: ["in", doctypes],
|
||||||
|
|||||||
@@ -36,6 +36,9 @@
|
|||||||
"assessment",
|
"assessment",
|
||||||
"schedule_tab",
|
"schedule_tab",
|
||||||
"timetable_template",
|
"timetable_template",
|
||||||
|
"column_break_anya",
|
||||||
|
"show_live_class",
|
||||||
|
"section_break_ontp",
|
||||||
"timetable"
|
"timetable"
|
||||||
],
|
],
|
||||||
"fields": [
|
"fields": [
|
||||||
@@ -200,11 +203,25 @@
|
|||||||
"fieldtype": "Link",
|
"fieldtype": "Link",
|
||||||
"label": "Timetable Template",
|
"label": "Timetable Template",
|
||||||
"options": "LMS Timetable Template"
|
"options": "LMS Timetable Template"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "column_break_anya",
|
||||||
|
"fieldtype": "Column Break"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"default": "0",
|
||||||
|
"fieldname": "show_live_class",
|
||||||
|
"fieldtype": "Check",
|
||||||
|
"label": "Show Live Class"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "section_break_ontp",
|
||||||
|
"fieldtype": "Section Break"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"index_web_pages_for_search": 1,
|
"index_web_pages_for_search": 1,
|
||||||
"links": [],
|
"links": [],
|
||||||
"modified": "2023-09-18 17:36:03.621651",
|
"modified": "2023-09-20 11:25:10.683688",
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"module": "LMS",
|
"module": "LMS",
|
||||||
"name": "LMS Batch",
|
"name": "LMS Batch",
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import requests
|
|||||||
import base64
|
import base64
|
||||||
import json
|
import json
|
||||||
from frappe import _
|
from frappe import _
|
||||||
|
from datetime import timedelta
|
||||||
from frappe.model.document import Document
|
from frappe.model.document import Document
|
||||||
from frappe.utils import cint, format_date, format_datetime
|
from frappe.utils import cint, format_date, format_datetime
|
||||||
from lms.lms.utils import get_lessons, get_lesson_index, get_lesson_url
|
from lms.lms.utils import get_lessons, get_lesson_index, get_lesson_url
|
||||||
@@ -274,6 +275,32 @@ def get_batch_timetable(batch):
|
|||||||
order_by="date",
|
order_by="date",
|
||||||
)
|
)
|
||||||
|
|
||||||
|
show_live_class = frappe.db.get_value("LMS Batch", batch, "show_live_class")
|
||||||
|
if show_live_class:
|
||||||
|
live_classes = get_live_classes(batch)
|
||||||
|
timetable.extend(live_classes)
|
||||||
|
|
||||||
|
timetable = get_timetable_details(timetable)
|
||||||
|
return timetable
|
||||||
|
|
||||||
|
|
||||||
|
def get_live_classes(batch):
|
||||||
|
live_classes = frappe.get_all(
|
||||||
|
"LMS Live Class",
|
||||||
|
{"batch_name": batch},
|
||||||
|
["name", "title", "date", "time as start_time", "duration", "join_url as url"],
|
||||||
|
order_by="date",
|
||||||
|
)
|
||||||
|
for class_ in live_classes:
|
||||||
|
class_.end_time = class_.start_time + timedelta(minutes=class_.duration)
|
||||||
|
class_.reference_doctype = "LMS Live Class"
|
||||||
|
class_.reference_docname = class_.name
|
||||||
|
class_.icon = "icon-call"
|
||||||
|
|
||||||
|
return live_classes
|
||||||
|
|
||||||
|
|
||||||
|
def get_timetable_details(timetable):
|
||||||
for entry in timetable:
|
for entry in timetable:
|
||||||
entry.title = frappe.db.get_value(
|
entry.title = frappe.db.get_value(
|
||||||
entry.reference_doctype, entry.reference_docname, "title"
|
entry.reference_doctype, entry.reference_docname, "title"
|
||||||
@@ -298,10 +325,5 @@ def get_batch_timetable(batch):
|
|||||||
details = get_assignment_details(assessment, frappe.session.user)
|
details = get_assignment_details(assessment, frappe.session.user)
|
||||||
entry.update(details)
|
entry.update(details)
|
||||||
|
|
||||||
elif entry.reference_doctype == "LMS Live Class":
|
timetable = sorted(timetable, key=lambda k: k["date"])
|
||||||
entry.icon = "icon-call"
|
|
||||||
entry.url = frappe.db.get_value(
|
|
||||||
entry.reference_doctype, entry.reference_docname, "join_url"
|
|
||||||
)
|
|
||||||
|
|
||||||
return timetable
|
return timetable
|
||||||
|
|||||||
@@ -10,16 +10,16 @@
|
|||||||
"title",
|
"title",
|
||||||
"host",
|
"host",
|
||||||
"batch_name",
|
"batch_name",
|
||||||
"password",
|
|
||||||
"auto_recording",
|
|
||||||
"column_break_astv",
|
"column_break_astv",
|
||||||
"description",
|
|
||||||
"section_break_glxh",
|
|
||||||
"date",
|
"date",
|
||||||
"timezone",
|
|
||||||
"column_break_spvt",
|
|
||||||
"time",
|
"time",
|
||||||
"duration",
|
"duration",
|
||||||
|
"section_break_glxh",
|
||||||
|
"description",
|
||||||
|
"column_break_spvt",
|
||||||
|
"timezone",
|
||||||
|
"password",
|
||||||
|
"auto_recording",
|
||||||
"section_break_yrpq",
|
"section_break_yrpq",
|
||||||
"start_url",
|
"start_url",
|
||||||
"column_break_yokr",
|
"column_break_yokr",
|
||||||
@@ -126,7 +126,7 @@
|
|||||||
],
|
],
|
||||||
"index_web_pages_for_search": 1,
|
"index_web_pages_for_search": 1,
|
||||||
"links": [],
|
"links": [],
|
||||||
"modified": "2023-09-14 15:02:44.081474",
|
"modified": "2023-09-20 11:29:20.899897",
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"module": "LMS",
|
"module": "LMS",
|
||||||
"name": "LMS Live Class",
|
"name": "LMS Live Class",
|
||||||
|
|||||||
Reference in New Issue
Block a user