feat: live class checkbox

This commit is contained in:
Jannat Patel
2023-09-20 12:09:02 +05:30
parent 8098532215
commit 0d99269109
4 changed files with 54 additions and 20 deletions

View File

@@ -12,12 +12,7 @@ frappe.ui.form.on("LMS Batch", {
});
frm.set_query("reference_doctype", "timetable", function () {
let doctypes = [
"Course Lesson",
"LMS Quiz",
"LMS Assignment",
"LMS Live Class",
];
let doctypes = ["Course Lesson", "LMS Quiz", "LMS Assignment"];
return {
filters: {
name: ["in", doctypes],

View File

@@ -36,6 +36,9 @@
"assessment",
"schedule_tab",
"timetable_template",
"column_break_anya",
"show_live_class",
"section_break_ontp",
"timetable"
],
"fields": [
@@ -200,11 +203,25 @@
"fieldtype": "Link",
"label": "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,
"links": [],
"modified": "2023-09-18 17:36:03.621651",
"modified": "2023-09-20 11:25:10.683688",
"modified_by": "Administrator",
"module": "LMS",
"name": "LMS Batch",

View File

@@ -6,6 +6,7 @@ import requests
import base64
import json
from frappe import _
from datetime import timedelta
from frappe.model.document import Document
from frappe.utils import cint, format_date, format_datetime
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",
)
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:
entry.title = frappe.db.get_value(
entry.reference_doctype, entry.reference_docname, "title"
@@ -298,10 +325,5 @@ def get_batch_timetable(batch):
details = get_assignment_details(assessment, frappe.session.user)
entry.update(details)
elif entry.reference_doctype == "LMS Live Class":
entry.icon = "icon-call"
entry.url = frappe.db.get_value(
entry.reference_doctype, entry.reference_docname, "join_url"
)
timetable = sorted(timetable, key=lambda k: k["date"])
return timetable

View File

@@ -10,16 +10,16 @@
"title",
"host",
"batch_name",
"password",
"auto_recording",
"column_break_astv",
"description",
"section_break_glxh",
"date",
"timezone",
"column_break_spvt",
"time",
"duration",
"section_break_glxh",
"description",
"column_break_spvt",
"timezone",
"password",
"auto_recording",
"section_break_yrpq",
"start_url",
"column_break_yokr",
@@ -126,7 +126,7 @@
],
"index_web_pages_for_search": 1,
"links": [],
"modified": "2023-09-14 15:02:44.081474",
"modified": "2023-09-20 11:29:20.899897",
"modified_by": "Administrator",
"module": "LMS",
"name": "LMS Live Class",