Merge pull request #9466 from manassolanki/validation

changes in student settings for validating the students in the student groups
This commit is contained in:
Makarand Bauskar 2017-06-29 10:48:59 +05:30 committed by GitHub
commit 1eb31db71f
4 changed files with 44 additions and 13 deletions

View File

@ -139,8 +139,8 @@
"bold": 0,
"collapsible": 0,
"columns": 0,
"default": "1",
"fieldname": "validation_from_pe",
"description": "For Batch based Student Group, the Student Batch will be validated for every Student from the Program Enrollment.",
"fieldname": "validate_batch",
"fieldtype": "Check",
"hidden": 0,
"ignore_user_permissions": 0,
@ -149,7 +149,38 @@
"in_global_search": 0,
"in_list_view": 0,
"in_standard_filter": 0,
"label": "Validate the Student Group from Program Enrollment",
"label": "Validate Batch for Students in Student Group",
"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,
"description": "For Course based Student Group, the Course will be validated for every Student from the enrolled Courses in Program Enrollment.",
"fieldname": "validate_course",
"fieldtype": "Check",
"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": "Validate Enrolled Course for Students in Student Group",
"length": 0,
"no_copy": 0,
"permlevel": 0,
@ -175,7 +206,7 @@
"issingle": 1,
"istable": 0,
"max_attachments": 0,
"modified": "2017-04-27 15:37:00.159072",
"modified": "2017-06-26 14:07:36.542314",
"modified_by": "Administrator",
"module": "Schools",
"name": "School Settings",

View File

@ -11,7 +11,8 @@ school_keydict = {
# "key in defaults": "key in Global Defaults"
"academic_year": "current_academic_year",
"academic_term": "current_academic_term",
"student_validation_setting": "validation_from_pe",
"validate_batch": "validate_batch",
"validate_course": "validate_course"
}
class SchoolSettings(Document):

View File

@ -35,9 +35,7 @@ class StudentAttendance(Document):
student_group = frappe.db.get_value("Course Schedule", self.course_schedule, "student_group")
else:
student_group = self.student_group
student_group_students = []
for d in get_student_group_students(student_group):
student_group_students.append(d.student)
student_group_students = [d.student for d in get_student_group_students(student_group)]
if student_group and self.student not in student_group_students:
frappe.throw(_('''Student {0}: {1} does not belong to Student Group {2}'''.format(self.student, self.student_name, student_group)))

View File

@ -12,8 +12,7 @@ class StudentGroup(Document):
def validate(self):
self.validate_mandatory_fields()
self.validate_strength()
if frappe.defaults.get_defaults().student_validation_setting:
self.validate_students()
self.validate_students()
self.validate_and_set_child_table_fields()
validate_duplicate_student(self.students)
@ -31,12 +30,14 @@ class StudentGroup(Document):
def validate_students(self):
program_enrollment = get_program_enrollment(self.academic_year, self.academic_term, self.program, self.batch, self.course)
students = [d.student for d in program_enrollment] if program_enrollment else None
students = [d.student for d in program_enrollment] if program_enrollment else []
for d in self.students:
if self.group_based_on != "Activity" and students and d.student not in students and d.active == 1:
frappe.throw(_("{0} - {1} is not enrolled in the given {2}".format(d.group_roll_number, d.student_name, self.group_based_on)))
if not frappe.db.get_value("Student", d.student, "enabled") and d.active:
frappe.throw(_("{0} - {1} is inactive student".format(d.group_roll_number, d.student_name)))
if self.group_based_on == "Batch" and d.student not in students and frappe.defaults.get_defaults().validate_batch:
frappe.throw(_("{0} - {1} is not enrolled in the Batch {2}".format(d.group_roll_number, d.student_name, self.batch)))
if self.group_based_on == "Course" and d.student not in students and frappe.defaults.get_defaults().validate_course:
frappe.throw(_("{0} - {1} is not enrolled in the Course {2}".format(d.group_roll_number, d.student_name, self.course)))
def validate_and_set_child_table_fields(self):
roll_numbers = [d.group_roll_number for d in self.students if d.group_roll_number]