added Create exam group button in Auto Exam Group
And it works!
This commit is contained in:
parent
885b71d927
commit
b04ac777d8
|
@ -1,8 +1,23 @@
|
|||
// Copyright (c) 2023, CSE 2020 Batch and contributors
|
||||
// For license information, please see license.txt
|
||||
|
||||
// frappe.ui.form.on("Auto Exam Group", {
|
||||
// refresh(frm) {
|
||||
|
||||
// },
|
||||
// });
|
||||
frappe.ui.form.on("Auto Exam Group", {
|
||||
refresh(frm) {
|
||||
frm.disable_save();
|
||||
frm.add_custom_button("Create exam group", () => {
|
||||
frm.trigger("create_exam_group");
|
||||
});
|
||||
frm.change_custom_button_type("Create exam group", null, "primary");
|
||||
},
|
||||
create_exam_group(frm) {
|
||||
frappe.db
|
||||
.insert({
|
||||
doctype: "Exam Group",
|
||||
date: frm.doc.date,
|
||||
session: frm.doc.session,
|
||||
})
|
||||
.then((doc) => {
|
||||
frappe.set_route("Form", "Exam Group", doc.name);
|
||||
});
|
||||
},
|
||||
});
|
||||
|
|
|
@ -9,8 +9,7 @@
|
|||
"engine": "InnoDB",
|
||||
"field_order": [
|
||||
"date",
|
||||
"session",
|
||||
"generate_exam_group"
|
||||
"session"
|
||||
],
|
||||
"fields": [
|
||||
{
|
||||
|
@ -27,17 +26,12 @@
|
|||
"label": "Session",
|
||||
"options": "Forenoon\nAfternoon",
|
||||
"reqd": 1
|
||||
},
|
||||
{
|
||||
"fieldname": "generate_exam_group",
|
||||
"fieldtype": "Button",
|
||||
"label": "Generate exam group"
|
||||
}
|
||||
],
|
||||
"index_web_pages_for_search": 1,
|
||||
"is_virtual": 1,
|
||||
"links": [],
|
||||
"modified": "2023-04-04 19:10:48.073906",
|
||||
"modified": "2023-04-05 19:41:39.427602",
|
||||
"modified_by": "Administrator",
|
||||
"module": "Exam Helper",
|
||||
"name": "Auto Exam Group",
|
||||
|
|
|
@ -26,11 +26,16 @@ class AutoExamGroup(Document):
|
|||
for exam in exams:
|
||||
exam = frappe.get_doc("Exam", exam["name"])
|
||||
print(exam.date, exam.session)
|
||||
name = str(exam.date) + " " + exam.session
|
||||
if frappe.db.exists(
|
||||
"Exam Group", {"date": exam.date, "session": exam.session}
|
||||
):
|
||||
continue
|
||||
list_of_dates_and_session.append(
|
||||
{
|
||||
"date": exam.date,
|
||||
"session": exam.session,
|
||||
"name": str(exam.date) + " " + exam.session,
|
||||
"name": name,
|
||||
}
|
||||
)
|
||||
list_of_dates_and_session = [
|
||||
|
|
Loading…
Reference in New Issue