Fix + Enhancement in Program Enrollment Tool (#12291)

* Fix + Enhancement in Program Enrollment Tool

* updated the docs
This commit is contained in:
Manas Solanki 2018-01-05 12:42:39 +05:30 committed by Nabin Hait
parent bc2c83ee3c
commit 171157f1b3
6 changed files with 307 additions and 37 deletions

View File

@ -1,16 +1,21 @@
# Program Enrollment Tool # Program Enrollment Tool
The Program Enrollment tool allows the bulk enrollment of the **Student Applicants** in a Program. The Program Enrollment tool allows the bulk enrollment of the new and old students in a Program. If you are enrolling a new student, you can fetch the students from the **Student Applicant** or if you are promoting the older students you can fetch them from the **Program Enrollment** itself
> Note: Academic Term is optional in the Program Enrollment Tool
You can create the the Program Enrollment for : You can create the Program Enrollment for :
1. **Student Applicants** >> List of Student Applicants will be fetched for the selected **Program** and **Academic year**. 1. **Student Applicants**: List of Student Applicants will be fetched for the selected **Program**, **Academic year** and **Academic Term** (if provided).
<img class="screenshot" alt="Student Applicant Enrollment" src="/docs/assets/img/education/admission/program-enrollment-tool.gif"> <img class="screenshot" alt="Student Applicant Enrollment" src="/docs/assets/img/education/admission/program-enrollment-tool.gif">
2. **Program Enrollment** >> You can bulk update the **Program** for the students from one academic year to another in the same **Program** or a new **Program**. 2. **Program Enrollment**: List of students already enrolled in selected **Program** for the given **Academic Year**, **Academic Term** (if provided) and **Student Batch** will be fetched and can be used to enroll students from one academic year/term to another in the same **Program** or a new **Program**.
<img class="screenshot" alt="Student Applicant Enrollment" src="/docs/assets/img/education/admission/program-enrollment-tool01.gif"> <img class="screenshot" alt="Student Applicant Enrollment" src="/docs/assets/img/education/admission/program-enrollment-tool01.gif">
**New Student Batch**: This can be selected for the entire students fetched in the table. Priority will be given to the Batch selected in the table (for individual students).
For promoting the students, the new academic year, academic term and program can also be selected for the enrollment of the fetched students list.
{next} {next}

View File

@ -1,11 +1,19 @@
// Copyright (c) 2016, Frappe and contributors // Copyright (c) 2016, Frappe and contributors
// For license information, please see license.txt // For license information, please see license.txt
cur_frm.add_fetch("student", "title", "student_name");
cur_frm.add_fetch("student_applicant", "title", "student_name");
frappe.ui.form.on("Program Enrollment Tool", { frappe.ui.form.on("Program Enrollment Tool", {
setup: function(frm) {
frm.add_fetch("student", "title", "student_name");
frm.add_fetch("student_applicant", "title", "student_name");
},
"refresh": function(frm) { "refresh": function(frm) {
frm.disable_save(); frm.disable_save();
frm.fields_dict.enroll_students.$input.addClass(' btn btn-primary');
frappe.realtime.on("program_enrollment_tool", function(data) {
frappe.hide_msgprint(true);
frappe.show_progress(__("Enrolling students"), data.progress[0], data.progress[1]);
});
}, },
"get_students": function(frm) { "get_students": function(frm) {
@ -18,7 +26,7 @@ frappe.ui.form.on("Program Enrollment Tool", {
frm.set_value("students", r.message); frm.set_value("students", r.message);
} }
} }
}) });
}, },
"enroll_students": function(frm) { "enroll_students": function(frm) {
@ -27,7 +35,8 @@ frappe.ui.form.on("Program Enrollment Tool", {
doc:frm.doc, doc:frm.doc,
callback: function(r) { callback: function(r) {
frm.set_value("students", []); frm.set_value("students", []);
frappe.hide_msgprint(true);
} }
}) });
} }
}); });

View File

@ -29,7 +29,7 @@
"label": "Get Students From", "label": "Get Students From",
"length": 0, "length": 0,
"no_copy": 0, "no_copy": 0,
"options": "\nStudent Applicants\nProgram Enrollments", "options": "\nStudent Applicant\nProgram Enrollment",
"permlevel": 0, "permlevel": 0,
"precision": "", "precision": "",
"print_hide": 0, "print_hide": 0,
@ -73,6 +73,67 @@
"set_only_once": 0, "set_only_once": 0,
"unique": 0 "unique": 0
}, },
{
"allow_bulk_edit": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"depends_on": "eval:doc.get_students_from==\"Program Enrollment\"",
"fieldname": "student_batch",
"fieldtype": "Link",
"hidden": 0,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_global_search": 0,
"in_list_view": 0,
"in_standard_filter": 0,
"label": "Student Batch",
"length": 0,
"no_copy": 0,
"options": "Student Batch Name",
"permlevel": 0,
"precision": "",
"print_hide": 0,
"print_hide_if_no_value": 0,
"read_only": 0,
"remember_last_selected_value": 0,
"report_hide": 0,
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"fieldname": "column_break_3",
"fieldtype": "Column Break",
"hidden": 0,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_global_search": 0,
"in_list_view": 0,
"in_standard_filter": 0,
"length": 0,
"no_copy": 0,
"permlevel": 0,
"precision": "",
"print_hide": 0,
"print_hide_if_no_value": 0,
"read_only": 0,
"remember_last_selected_value": 0,
"report_hide": 0,
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"unique": 0
},
{ {
"allow_bulk_edit": 0, "allow_bulk_edit": 0,
"allow_on_submit": 0, "allow_on_submit": 0,
@ -110,8 +171,8 @@
"bold": 0, "bold": 0,
"collapsible": 0, "collapsible": 0,
"columns": 0, "columns": 0,
"fieldname": "get_students", "fieldname": "academic_term",
"fieldtype": "Button", "fieldtype": "Link",
"hidden": 0, "hidden": 0,
"ignore_user_permissions": 0, "ignore_user_permissions": 0,
"ignore_xss_filter": 0, "ignore_xss_filter": 0,
@ -119,9 +180,10 @@
"in_global_search": 0, "in_global_search": 0,
"in_list_view": 0, "in_list_view": 0,
"in_standard_filter": 0, "in_standard_filter": 0,
"label": "Get Students", "label": "Academic Term",
"length": 0, "length": 0,
"no_copy": 0, "no_copy": 0,
"options": "Academic Term",
"permlevel": 0, "permlevel": 0,
"precision": "", "precision": "",
"print_hide": 0, "print_hide": 0,
@ -163,6 +225,36 @@
"set_only_once": 0, "set_only_once": 0,
"unique": 0 "unique": 0
}, },
{
"allow_bulk_edit": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"fieldname": "get_students",
"fieldtype": "Button",
"hidden": 0,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_global_search": 0,
"in_list_view": 0,
"in_standard_filter": 0,
"label": "Get Students",
"length": 0,
"no_copy": 0,
"permlevel": 0,
"precision": "",
"print_hide": 0,
"print_hide_if_no_value": 0,
"read_only": 0,
"remember_last_selected_value": 0,
"report_hide": 0,
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"unique": 0
},
{ {
"allow_bulk_edit": 0, "allow_bulk_edit": 0,
"allow_on_submit": 0, "allow_on_submit": 0,
@ -209,6 +301,7 @@
"in_global_search": 0, "in_global_search": 0,
"in_list_view": 0, "in_list_view": 0,
"in_standard_filter": 0, "in_standard_filter": 0,
"label": "Enrollment Details",
"length": 0, "length": 0,
"no_copy": 0, "no_copy": 0,
"permlevel": 0, "permlevel": 0,
@ -229,7 +322,7 @@
"bold": 0, "bold": 0,
"collapsible": 0, "collapsible": 0,
"columns": 0, "columns": 0,
"depends_on": "eval:doc.get_students_from==\"Program Enrollments\"", "depends_on": "eval:doc.get_students_from==\"Program Enrollment\"",
"fieldname": "new_program", "fieldname": "new_program",
"fieldtype": "Link", "fieldtype": "Link",
"hidden": 0, "hidden": 0,
@ -261,8 +354,7 @@
"bold": 0, "bold": 0,
"collapsible": 0, "collapsible": 0,
"columns": 0, "columns": 0,
"depends_on": "eval:doc.get_students_from==\"Program Enrollments\"", "fieldname": "new_student_batch",
"fieldname": "new_academic_year",
"fieldtype": "Link", "fieldtype": "Link",
"hidden": 0, "hidden": 0,
"ignore_user_permissions": 0, "ignore_user_permissions": 0,
@ -271,10 +363,10 @@
"in_global_search": 0, "in_global_search": 0,
"in_list_view": 0, "in_list_view": 0,
"in_standard_filter": 0, "in_standard_filter": 0,
"label": "New Academic Year", "label": "New Student Batch",
"length": 0, "length": 0,
"no_copy": 0, "no_copy": 0,
"options": "Academic Year", "options": "Student Batch Name",
"permlevel": 0, "permlevel": 0,
"precision": "", "precision": "",
"print_hide": 0, "print_hide": 0,
@ -316,6 +408,99 @@
"search_index": 0, "search_index": 0,
"set_only_once": 0, "set_only_once": 0,
"unique": 0 "unique": 0
},
{
"allow_bulk_edit": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"fieldname": "column_break_12",
"fieldtype": "Column Break",
"hidden": 0,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_global_search": 0,
"in_list_view": 0,
"in_standard_filter": 0,
"length": 0,
"no_copy": 0,
"permlevel": 0,
"precision": "",
"print_hide": 0,
"print_hide_if_no_value": 0,
"read_only": 0,
"remember_last_selected_value": 0,
"report_hide": 0,
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"depends_on": "eval:doc.get_students_from==\"Program Enrollment\"",
"fieldname": "new_academic_year",
"fieldtype": "Link",
"hidden": 0,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_global_search": 0,
"in_list_view": 0,
"in_standard_filter": 0,
"label": "New Academic Year",
"length": 0,
"no_copy": 0,
"options": "Academic Year",
"permlevel": 0,
"precision": "",
"print_hide": 0,
"print_hide_if_no_value": 0,
"read_only": 0,
"remember_last_selected_value": 0,
"report_hide": 0,
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"depends_on": "eval:doc.get_students_from==\"Program Enrollment\"",
"fieldname": "new_academic_term",
"fieldtype": "Link",
"hidden": 0,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_global_search": 0,
"in_list_view": 0,
"in_standard_filter": 0,
"label": "New Academic Term",
"length": 0,
"no_copy": 0,
"options": "Academic Term",
"permlevel": 0,
"precision": "",
"print_hide": 0,
"print_hide_if_no_value": 0,
"read_only": 0,
"remember_last_selected_value": 0,
"report_hide": 0,
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"unique": 0
} }
], ],
"has_web_view": 0, "has_web_view": 0,
@ -328,7 +513,7 @@
"issingle": 1, "issingle": 1,
"istable": 0, "istable": 0,
"max_attachments": 0, "max_attachments": 0,
"modified": "2017-12-27 09:35:45.002469", "modified": "2018-01-02 11:59:40.230689",
"modified_by": "Administrator", "modified_by": "Administrator",
"module": "Education", "module": "Education",
"name": "Program Enrollment Tool", "name": "Program Enrollment Tool",

View File

@ -17,21 +17,26 @@ class ProgramEnrollmentTool(Document):
elif not self.academic_year: elif not self.academic_year:
frappe.throw(_("Mandatory field - Academic Year")) frappe.throw(_("Mandatory field - Academic Year"))
else: else:
if self.get_students_from == "Student Applicants": condition = 'and academic_term=%(academic_term)s' if self.academic_term else " "
students = frappe.db.sql("select name as student_applicant, title as student_name from \ if self.get_students_from == "Student Applicant":
`tabStudent Applicant` where program = %s and academic_year = %s",(self.program, self.academic_year), as_dict=1) students = frappe.db.sql('''select name as student_applicant, title as student_name from `tabStudent Applicant`
else: where application_status="Approved" and program=%(program)s and academic_year=%(academic_year)s {0}'''
students = frappe.db.sql("select student, student_name, student_batch_name from \ .format(condition), self.as_dict(), as_dict=1)
`tabProgram Enrollment` where program = %s and academic_year = %s",(self.program, self.academic_year), as_dict=1) elif self.get_students_from == "Program Enrollment":
condition2 = 'and student_batch_name=%(student_batch)s' if self.student_batch else " "
students = frappe.db.sql('''select student, student_name, student_batch_name from `tabProgram Enrollment`
where program=%(program)s and academic_year=%(academic_year)s {0} {1}'''
.format(condition, condition2), self.as_dict(), as_dict=1)
student_list = [d.student for d in students] student_list = [d.student for d in students]
if student_list:
inactive_students = frappe.db.sql('''
select name as student, title as student_name from `tabStudent` where name in (%s) and enabled = 0''' %
', '.join(['%s']*len(student_list)), tuple(student_list), as_dict=1)
inactive_students = frappe.db.sql(''' for student in students:
select name as student, title as student_name from `tabStudent` where name in (%s) and enabled = 0''' % if student.student in [d.student for d in inactive_students]:
', '.join(['%s']*len(student_list)), tuple(student_list), as_dict=1) students.remove(student)
for student in students:
if student.student in [d.student for d in inactive_students]:
students.remove(student)
if students: if students:
return students return students
@ -39,18 +44,22 @@ class ProgramEnrollmentTool(Document):
frappe.throw(_("No students Found")) frappe.throw(_("No students Found"))
def enroll_students(self): def enroll_students(self):
for stud in self.students: total = len(self.students)
for i, stud in enumerate(self.students):
frappe.publish_realtime("program_enrollment_tool", dict(progress=[i+1, total]), user=frappe.session.user)
if stud.student: if stud.student:
prog_enrollment = frappe.new_doc("Program Enrollment") prog_enrollment = frappe.new_doc("Program Enrollment")
prog_enrollment.student = stud.student prog_enrollment.student = stud.student
prog_enrollment.student_name = stud.student_name prog_enrollment.student_name = stud.student_name
prog_enrollment.student_batch_name = stud.student_batch_name
prog_enrollment.program = self.new_program prog_enrollment.program = self.new_program
prog_enrollment.academic_year = self.new_academic_year prog_enrollment.academic_year = self.new_academic_year
prog_enrollment.academic_term = self.new_academic_term
prog_enrollment.student_batch_name = stud.student_batch_name if stud.student_batch_name else self.new_student_batch
prog_enrollment.save() prog_enrollment.save()
elif stud.student_applicant: elif stud.student_applicant:
prog_enrollment = enroll_student(stud.student_applicant) prog_enrollment = enroll_student(stud.student_applicant)
prog_enrollment.academic_year = self.academic_year prog_enrollment.academic_year = self.academic_year
prog_enrollment.academic_term = self.academic_term
prog_enrollment.student_batch_name = stud.student_batch_name if stud.student_batch_name else self.new_student_batch
prog_enrollment.save() prog_enrollment.save()
frappe.msgprint("Students have been enrolled.") frappe.msgprint("{0} Students have been enrolled.".format(total))

View File

@ -133,6 +133,37 @@
"search_index": 0, "search_index": 0,
"set_only_once": 0, "set_only_once": 0,
"unique": 0 "unique": 0
},
{
"allow_bulk_edit": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"fieldname": "student_batch_name",
"fieldtype": "Link",
"hidden": 0,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_global_search": 0,
"in_list_view": 1,
"in_standard_filter": 0,
"label": "Student Batch Name",
"length": 0,
"no_copy": 0,
"options": "Student Batch Name",
"permlevel": 0,
"precision": "",
"print_hide": 0,
"print_hide_if_no_value": 0,
"read_only": 0,
"remember_last_selected_value": 0,
"report_hide": 0,
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"unique": 0
} }
], ],
"has_web_view": 0, "has_web_view": 0,
@ -145,7 +176,7 @@
"issingle": 0, "issingle": 0,
"istable": 1, "istable": 1,
"max_attachments": 0, "max_attachments": 0,
"modified": "2017-11-10 19:09:59.530615", "modified": "2018-01-02 12:03:53.890741",
"modified_by": "Administrator", "modified_by": "Administrator",
"module": "Education", "module": "Education",
"name": "Program Enrollment Tool Student", "name": "Program Enrollment Tool Student",

View File

@ -320,6 +320,37 @@
"set_only_once": 0, "set_only_once": 0,
"unique": 0 "unique": 0
}, },
{
"allow_bulk_edit": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"fieldname": "academic_term",
"fieldtype": "Link",
"hidden": 0,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_global_search": 0,
"in_list_view": 0,
"in_standard_filter": 0,
"label": "Academic Term",
"length": 0,
"no_copy": 0,
"options": "Academic Term",
"permlevel": 0,
"precision": "",
"print_hide": 0,
"print_hide_if_no_value": 0,
"read_only": 0,
"remember_last_selected_value": 0,
"report_hide": 0,
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"unique": 0
},
{ {
"allow_bulk_edit": 0, "allow_bulk_edit": 0,
"allow_on_submit": 0, "allow_on_submit": 0,
@ -1058,7 +1089,7 @@
"istable": 0, "istable": 0,
"max_attachments": 0, "max_attachments": 0,
"menu_index": 0, "menu_index": 0,
"modified": "2017-11-10 19:08:55.049625", "modified": "2018-01-02 11:47:14.944338",
"modified_by": "Administrator", "modified_by": "Administrator",
"module": "Education", "module": "Education",
"name": "Student Applicant", "name": "Student Applicant",