Added validation to ensure that the Sum of Scores of evaluation Criteras is equal to the max assessment score.

This commit is contained in:
Neil Trini Lasrado 2017-01-30 13:28:54 +05:30
parent fbaa6197f9
commit 80ca65c166

View File

@ -13,7 +13,7 @@ class AssessmentPlan(Document):
frappe.throw(_("Please select Student Group or Student Batch"))
self.validate_student_batch()
self.validate_overlap()
self.validate_max_score()
def validate_overlap(self):
"""Validates overlap for Student Group/Student Batch, Instructor, Room"""
@ -42,4 +42,11 @@ class AssessmentPlan(Document):
def validate_student_batch(self):
if self.student_group:
self.student_batch = frappe.db.get_value("Student Group", self.student_group, "student_batch")
self.student_batch = frappe.db.get_value("Student Group", self.student_group, "student_batch")
def validate_max_score(self):
max_score = 0
for d in self.evaluation_criterias:
max_score += d.maximum_score
if self.maximum_assessment_score != max_score:
frappe.throw(_("Sum of Scores of Evaluation Criterias needs to be {0}.".format(self.maximum_assessment_score)))