lots of changes

- edited onboarding
- merged hall allocation, seat arrangement and duty list into exam group
- more js
This commit is contained in:
Pranav Jerry 2023-05-21 22:45:11 +05:30
parent b02d579c82
commit dd768f6c79
Signed by: pranav
GPG Key ID: F1DCDC4FED0A0C5B
15 changed files with 509 additions and 80 deletions

View File

@ -3,35 +3,36 @@
frappe.ui.form.on("Exam Group", {
refresh(frm) {
frm.add_custom_button("Allocate exam halls", () => {
frm.trigger("allocate_exam_halls");
});
frm.change_custom_button_type("Allocate exam halls", null, "primary");
frm.add_custom_button("Generate duty list", () => {
frm.trigger("generate_duty_list");
});
frm.change_custom_button_type("Generate duty list", null, "primary");
console.log("hi");
console.log(frm);
if (frm.doc.rooms_allocated == 0) {
frm.add_custom_button("Allocate exam halls", () => {
frm.trigger("allocate_exam_halls");
});
frm.change_custom_button_type("Allocate exam halls", null, "primary");
} else if (frm.doc.seat_arrangement_created == 0) {
frm.add_custom_button("Arrange seats", () => {
frm.trigger("generate_seat_arrangement");
});
frm.change_custom_button_type("Arrange seats", null, "primary");
} else if (frm.doc.duty_list_created == 0) {
frm.add_custom_button("Generate duty list", () => {
frm.trigger("generate_duty_list");
});
frm.change_custom_button_type("Generate duty list", null, "primary");
}
},
allocate_exam_halls(frm) {
frappe.db
.insert({
doctype: "Hall Allocation",
date: frm.doc.date,
session: frm.doc.session,
exam_group: frm.doc.name,
})
.then((doc) => {
frappe.set_route("Form", "Hall Allocation", doc.name);
});
frm.set_value("allocate_rooms", true);
frm.save();
},
generate_duty_list(frm) {
frappe.db
.insert({
doctype: "Duty List",
exam_group: frm.doc.name,
})
.then((doc) => {
frappe.set_route("Form", "Duty List", doc.name);
});
frm.set_value("create_duty_list", true);
frm.save();
frappe.show_alert("Submit to update duty count of invigilators");
},
generate_seat_arrangement(frm) {
frm.set_value("create_seat_arrangement", true);
frm.save();
},
});

View File

@ -12,7 +12,20 @@
"date",
"session",
"exams",
"number_of_students"
"number_of_students",
"rooms_tab",
"allocate_rooms",
"allocated_rooms",
"seats_tab",
"create_seat_arrangement",
"seat_arrangement",
"duty_list_tab",
"create_duty_list",
"duties",
"rooms_allocated",
"duty_list_created",
"seat_arrangement_created",
"amended_from"
],
"fields": [
{
@ -41,11 +54,97 @@
"fieldtype": "Int",
"label": "Number of students",
"read_only": 1
},
{
"description": "Exam Halls allocated for the exam. Generated automatically. Can be manually edited if needed",
"fieldname": "allocated_rooms",
"fieldtype": "Table MultiSelect",
"label": "Allocated rooms",
"options": "Exam Hall Child"
},
{
"default": "0",
"fieldname": "allocate_rooms",
"fieldtype": "Check",
"hidden": 1,
"label": "Allocate rooms"
},
{
"fieldname": "duties",
"fieldtype": "Table",
"label": "Duties",
"options": "Invigilator And Duty"
},
{
"default": "0",
"fieldname": "create_duty_list",
"fieldtype": "Check",
"hidden": 1,
"label": "Create duty list"
},
{
"fieldname": "rooms_tab",
"fieldtype": "Tab Break",
"label": "Rooms"
},
{
"fieldname": "duty_list_tab",
"fieldtype": "Tab Break",
"label": "Duty list"
},
{
"default": "0",
"fieldname": "rooms_allocated",
"fieldtype": "Check",
"hidden": 1,
"label": "Rooms allocated"
},
{
"default": "0",
"fieldname": "duty_list_created",
"fieldtype": "Check",
"hidden": 1,
"label": "Duty list created"
},
{
"fieldname": "seat_arrangement",
"fieldtype": "Table",
"label": "Seat arrangement",
"options": "Seats And Exams"
},
{
"fieldname": "seats_tab",
"fieldtype": "Tab Break",
"label": "Seats"
},
{
"default": "0",
"fieldname": "create_seat_arrangement",
"fieldtype": "Check",
"hidden": 1,
"label": "Create seat arrangement"
},
{
"default": "0",
"fieldname": "seat_arrangement_created",
"fieldtype": "Check",
"hidden": 1,
"label": "Seat arrangement created"
},
{
"fieldname": "amended_from",
"fieldtype": "Link",
"label": "Amended From",
"no_copy": 1,
"options": "Exam Group",
"print_hide": 1,
"read_only": 1
}
],
"index_web_pages_for_search": 1,
"is_submittable": 1,
"links": [],
"modified": "2023-04-07 13:32:33.002382",
"modified": "2023-05-21 22:13:44.855255",
"modified_by": "Administrator",
"module": "Exam Helper",
"name": "Exam Group",
@ -61,7 +160,9 @@
"read": 1,
"report": 1,
"role": "System Manager",
"select": 1,
"share": 1,
"submit": 1,
"write": 1
},
{
@ -73,7 +174,9 @@
"read": 1,
"report": 1,
"role": "Exam Cell Staff",
"select": 1,
"share": 1,
"submit": 1,
"write": 1
}
],

View File

@ -7,6 +7,9 @@ from frappe.model.document import Document
class ExamGroup(Document):
def before_insert(self):
self.rooms_allocated = 0
self.duty_list_created = 0
self.seat_arrangement_created = 0
self.number_of_students = 0
exams = frappe.db.get_list(
"Exam", filters={"date": self.date, "session": self.session}, pluck="name"
@ -27,6 +30,29 @@ class ExamGroup(Document):
exam = frappe.get_doc("Exam", exam_id)
self.number_of_students += len(exam.students)
def before_save(self):
if self.allocate_rooms:
self.generate_hall_allocation()
self.allocate_rooms = False
self.rooms_allocated = True
if self.create_duty_list:
self.generate_duty_list()
self.create_duty_list = False
self.duty_list_created = True
if self.create_seat_arrangement:
self.generate_seat_arrangement()
self.create_seat_arrangement = False
self.seat_arrangement_created = True
def before_submit(self):
# update duty count
for inv in self.duties:
print(inv)
staff = frappe.get_doc("Staff", inv.invigilator)
staff.duty_count += 1
print("updating duty count for", staff.full_name)
staff.save()
def get_students(self):
students_by_exams = []
for exam in self.exams:
@ -63,3 +89,85 @@ class ExamGroup(Document):
if not halls:
return None
return frappe.get_doc("Hall Allocation", halls[0])
def generate_hall_allocation(self):
exam_halls = frappe.get_list("Exam Hall", pluck="name")
remaining_students = self.number_of_students
print(vars(self))
for exam_hall in exam_halls:
# students allocated to the exam hall
number_of_students = 0
if remaining_students <= 0:
break
print(exam_hall)
exam_hall = frappe.get_doc("Exam Hall", exam_hall)
if remaining_students >= exam_hall.seating_capacity:
number_of_students = exam_hall.seating_capacity
else:
number_of_students = remaining_students
remaining_students -= number_of_students
e = frappe.new_doc("Exam Hall Child")
e.update(
{
"id": exam_hall.name,
"parent": self.name,
"parentfield": "allocated_rooms",
"parenttype": self.doctype,
"number_of_students": number_of_students,
}
)
# e.save()
print(vars(self))
self.allocated_rooms.append(e)
def generate_duty_list(self):
total_invigilators_required = 0
print(self.allocated_rooms)
all_staff = []
for room in self.allocated_rooms:
invigilators_required = room.number_of_students // 30
if invigilators_required == 0:
invigilators_required += 1
total_invigilators_required += invigilators_required
print(total_invigilators_required)
for i in range(total_invigilators_required):
if not all_staff:
all_staff = frappe.db.get_list(
"Staff", pluck="name", order_by="duty_count asc"
)
staff = all_staff.pop(0)
staff = frappe.get_doc("Staff", staff)
print(staff)
invigilator_child = frappe.new_doc("Invigilator And Duty")
invigilator_child.update(
{
"invigilator": staff.name,
"invigilator_name": staff.full_name,
"invigilator_department": staff.department,
"parent": self.name,
"parentfield": "duties",
"parenttype": self.doctype,
}
)
print(invigilator_child)
self.duties.append(invigilator_child)
def generate_seat_arrangement(self):
print("randomizing students")
students = self.randomize_students_by_exam()
for exam_hall in self.allocated_rooms:
print("exam hall", exam_hall.id)
for i in range(self.number_of_students):
if not students:
print("no more students")
break
seat = frappe.new_doc("Seats And Exams")
seat.exam_hall = exam_hall.id
seat.seat_number = i + 1
seat.candidate = students.pop(0)
seat.parent = self.name
seat.parentfield = "seat_arrangement"
seat.parenttype = self.doctype
print("adding", seat.candidate, "to seat", seat.seat_number)
self.seat_arrangement.append(seat)

View File

@ -1,6 +1,7 @@
{
"actions": [],
"allow_rename": 1,
"autoname": "format:{invigilator_department}-{#####}",
"creation": "2023-05-15 19:28:50.532292",
"default_view": "List",
"doctype": "DocType",
@ -18,7 +19,7 @@
"in_list_view": 1,
"label": "Invigilator",
"options": "Staff",
"reqd": 1
"print_hide": 1
},
{
"fieldname": "invigilator_name",
@ -30,18 +31,19 @@
{
"fieldname": "invigilator_department",
"fieldtype": "Data",
"hidden": 1,
"in_list_view": 1,
"label": "Invigilator Department",
"reqd": 1
"label": "Invigilator Department"
}
],
"index_web_pages_for_search": 1,
"istable": 1,
"links": [],
"modified": "2023-05-19 17:34:53.289859",
"modified": "2023-05-21 20:58:40.082608",
"modified_by": "Administrator",
"module": "Exam Helper",
"name": "Invigilator And Duty",
"naming_rule": "Expression",
"owner": "Administrator",
"permissions": [],
"sort_field": "modified",

View File

@ -9,10 +9,7 @@
"field_order": [
"exam_hall",
"seat_number",
"candidate",
"hall_allocation",
"date",
"session"
"candidate"
],
"fields": [
{
@ -31,52 +28,25 @@
"reqd": 1
},
{
"allow_in_quick_entry": 1,
"fieldname": "exam_hall",
"fieldtype": "Link",
"in_list_view": 1,
"label": "Exam Hall",
"options": "Exam Hall",
"reqd": 1
},
{
"fieldname": "hall_allocation",
"fieldtype": "Link",
"label": "Hall Allocation",
"options": "Hall Allocation"
},
{
"fieldname": "date",
"fieldtype": "Date",
"label": "Date"
},
{
"fieldname": "session",
"fieldtype": "Select",
"label": "Session",
"options": "Forenoon\nAfternoon"
}
],
"index_web_pages_for_search": 1,
"istable": 1,
"links": [],
"modified": "2023-05-19 16:40:18.933744",
"modified": "2023-05-21 21:24:32.113192",
"modified_by": "Administrator",
"module": "Exam Helper",
"name": "Seats And Exams",
"naming_rule": "Expression",
"owner": "Administrator",
"permissions": [
{
"create": 1,
"delete": 1,
"email": 1,
"export": 1,
"print": 1,
"read": 1,
"report": 1,
"role": "System Manager",
"share": 1,
"write": 1
}
],
"permissions": [],
"sort_field": "modified",
"sort_order": "DESC",
"states": []

View File

@ -0,0 +1,81 @@
{
"creation": "2023-05-21 22:06:17.585431",
"docstatus": 0,
"doctype": "Form Tour",
"first_document": 0,
"idx": 0,
"include_name_field": 0,
"is_standard": 1,
"modified": "2023-05-21 22:17:32.970952",
"modified_by": "Administrator",
"module": "Exam Helper",
"name": "New Exam Group",
"owner": "Administrator",
"reference_doctype": "Exam Group",
"save_on_complete": 1,
"steps": [
{
"description": "Shows the date of the exams",
"fieldname": "date",
"fieldtype": "Date",
"has_next_condition": 0,
"is_table_field": 0,
"label": "Date",
"position": "Bottom",
"title": "Date of exam"
},
{
"description": "Shows the session of the exams (forenoon or afternoon)",
"fieldname": "session",
"fieldtype": "Select",
"has_next_condition": 0,
"is_table_field": 0,
"label": "Session",
"position": "Bottom",
"title": "Session"
},
{
"description": "Lists all the exams on the date and session",
"fieldname": "exams",
"fieldtype": "Table MultiSelect",
"has_next_condition": 0,
"is_table_field": 0,
"label": "Exams",
"position": "Bottom",
"title": "Exams on the group"
},
{
"description": "Lists the rooms allocated for the exams. Press [Allocate exam halls] to allocate rooms",
"fieldname": "rooms_tab",
"fieldtype": "Tab Break",
"has_next_condition": 1,
"is_table_field": 0,
"label": "Rooms",
"next_step_condition": "eval: doc.rooms_allocated != 0",
"position": "Bottom",
"title": "Room allocation"
},
{
"description": "Press the [Arrange seats] button to generate the seating arrangement",
"fieldname": "seats_tab",
"fieldtype": "Tab Break",
"has_next_condition": 1,
"is_table_field": 0,
"label": "Seats",
"next_step_condition": "eval: doc.seat_arrangement_created != 0",
"position": "Bottom",
"title": "Seating arrangement"
},
{
"description": "Press [Generate duty list] to generate the duty list",
"fieldname": "duty_list_tab",
"fieldtype": "Tab Break",
"has_next_condition": 0,
"is_table_field": 0,
"label": "Duty list",
"position": "Bottom",
"title": "Invigilation duty list"
}
],
"title": "New Exam Group"
}

View File

@ -0,0 +1,39 @@
{
"creation": "2023-05-21 22:02:44.424017",
"docstatus": 0,
"doctype": "Form Tour",
"first_document": 0,
"idx": 0,
"include_name_field": 0,
"is_standard": 1,
"modified": "2023-05-21 22:02:44.424017",
"modified_by": "Administrator",
"module": "Exam Helper",
"name": "New Exam Hall",
"owner": "Administrator",
"reference_doctype": "Exam Hall",
"save_on_complete": 1,
"steps": [
{
"description": "Give a unique id which candidates can easily recognise",
"fieldname": "room_number",
"fieldtype": "Data",
"has_next_condition": 0,
"is_table_field": 0,
"label": "Room number",
"position": "Bottom",
"title": "Unique identification number"
},
{
"description": "Give the number of candidates this room can house",
"fieldname": "seating_capacity",
"fieldtype": "Int",
"has_next_condition": 0,
"is_table_field": 0,
"label": "Seating capacity",
"position": "Bottom",
"title": "Total number of candidates"
}
],
"title": "New Exam Hall"
}

View File

@ -0,0 +1,49 @@
{
"creation": "2023-05-21 21:46:45.373602",
"docstatus": 0,
"doctype": "Form Tour",
"first_document": 0,
"idx": 0,
"include_name_field": 0,
"is_standard": 1,
"modified": "2023-05-21 21:46:45.373602",
"modified_by": "Administrator",
"module": "Exam Helper",
"name": "New Staff",
"owner": "Administrator",
"reference_doctype": "Staff",
"save_on_complete": 1,
"steps": [
{
"description": "This will be used to identify the staff.",
"fieldname": "full_name",
"fieldtype": "Data",
"has_next_condition": 0,
"is_table_field": 0,
"label": "Full name",
"position": "Bottom",
"title": "Type a name"
},
{
"description": "Joining date will be used to relieve senior staff of invigilation duties when junior staff is available.",
"fieldname": "joining_date",
"fieldtype": "Date",
"has_next_condition": 0,
"is_table_field": 0,
"label": "Joining date",
"position": "Bottom",
"title": "Add the date when the person joined the organization"
},
{
"description": "Used for arranging duty list by department.",
"fieldname": "department",
"fieldtype": "Link",
"has_next_condition": 0,
"is_table_field": 0,
"label": "Department",
"position": "Bottom",
"title": "Department"
}
],
"title": "New Staff"
}

View File

@ -0,0 +1,49 @@
{
"creation": "2023-05-21 21:52:36.596814",
"docstatus": 0,
"doctype": "Form Tour",
"first_document": 0,
"idx": 0,
"include_name_field": 0,
"is_standard": 1,
"modified": "2023-05-21 21:52:36.596814",
"modified_by": "Administrator",
"module": "Exam Helper",
"name": "New Student",
"owner": "Administrator",
"reference_doctype": "Student",
"save_on_complete": 0,
"steps": [
{
"description": "Give the ID used to identify the student by the university",
"fieldname": "id",
"fieldtype": "Data",
"has_next_condition": 0,
"is_table_field": 0,
"label": "ID",
"position": "Bottom",
"title": "University ID"
},
{
"description": "This is optional, and will be used in later versions of the software.",
"fieldname": "full_name",
"fieldtype": "Data",
"has_next_condition": 0,
"is_table_field": 0,
"label": "Full name",
"position": "Bottom",
"title": "Name of the student"
},
{
"description": "Useful for adding multiple students as candidates to an exam, as opposed to adding each student manually",
"fieldname": "classroom",
"fieldtype": "Link",
"has_next_condition": 0,
"is_table_field": 0,
"label": "Class",
"position": "Bottom",
"title": "Group students by class"
}
],
"title": "New Student"
}

View File

@ -10,7 +10,7 @@
"documentation_url": "https://example.org",
"idx": 0,
"is_complete": 0,
"modified": "2023-05-19 18:06:01.586387",
"modified": "2023-05-21 22:25:11.524321",
"modified_by": "Administrator",
"module": "Exam Helper",
"name": "First steps",
@ -28,6 +28,9 @@
{
"step": "Create exams"
},
{
"step": "Group exams manually"
},
{
"step": "Group exams"
}

View File

@ -3,17 +3,18 @@
"creation": "2023-05-19 18:02:31.591991",
"docstatus": 0,
"doctype": "Onboarding Step",
"form_tour": "New Student",
"idx": 0,
"is_complete": 0,
"is_single": 0,
"is_skipped": 0,
"modified": "2023-05-19 18:02:31.591991",
"modified": "2023-05-21 21:53:02.968686",
"modified_by": "Administrator",
"name": "Create students",
"owner": "Administrator",
"reference_document": "Student",
"show_form_tour": 0,
"show_full_form": 0,
"show_form_tour": 1,
"show_full_form": 1,
"title": "Add students",
"validate_action": 1
}

View File

@ -3,17 +3,18 @@
"creation": "2023-05-19 18:00:48.182704",
"docstatus": 0,
"doctype": "Onboarding Step",
"form_tour": "New Exam Hall",
"idx": 0,
"is_complete": 0,
"is_single": 0,
"is_skipped": 0,
"modified": "2023-05-19 18:00:48.182704",
"modified": "2023-05-21 22:03:01.026619",
"modified_by": "Administrator",
"name": "Exam halls",
"owner": "Administrator",
"reference_document": "Exam Hall",
"show_form_tour": 0,
"show_full_form": 0,
"show_form_tour": 1,
"show_full_form": 1,
"title": "Add exam halls",
"validate_action": 1
}

View File

@ -1,19 +1,20 @@
{
"action": "Go to Page",
"creation": "2023-05-19 18:05:53.447607",
"description": "Group exams automatically using available data",
"docstatus": 0,
"doctype": "Onboarding Step",
"idx": 0,
"is_complete": 0,
"is_single": 0,
"is_skipped": 0,
"modified": "2023-05-19 18:05:53.447607",
"modified": "2023-05-21 22:22:41.602331",
"modified_by": "Administrator",
"name": "Group exams",
"owner": "Administrator",
"path": "/app/auto-exam-group/view/list",
"show_form_tour": 0,
"show_full_form": 0,
"title": "Group exams",
"title": "Automatically group exams",
"validate_action": 1
}

View File

@ -0,0 +1,20 @@
{
"action": "Create Entry",
"creation": "2023-05-21 22:23:48.809916",
"docstatus": 0,
"doctype": "Onboarding Step",
"form_tour": "New Exam Group",
"idx": 0,
"is_complete": 0,
"is_single": 0,
"is_skipped": 0,
"modified": "2023-05-21 22:23:48.809916",
"modified_by": "Administrator",
"name": "Group exams manually",
"owner": "Administrator",
"reference_document": "Exam Group",
"show_form_tour": 1,
"show_full_form": 1,
"title": "Group exams",
"validate_action": 1
}

View File

@ -3,17 +3,18 @@
"creation": "2023-05-19 17:58:37.670087",
"docstatus": 0,
"doctype": "Onboarding Step",
"form_tour": "New Staff",
"idx": 0,
"is_complete": 0,
"is_single": 0,
"is_skipped": 0,
"modified": "2023-05-19 17:58:55.344151",
"modified": "2023-05-21 21:48:28.915663",
"modified_by": "Administrator",
"name": "Invigilators",
"owner": "Administrator",
"reference_document": "Staff",
"show_form_tour": 0,
"show_full_form": 0,
"show_form_tour": 1,
"show_full_form": 1,
"title": "Add staff for invigilation",
"validate_action": 1
}