validate the duplicate assessment criteria

This commit is contained in:
Manas Solanki 2017-06-29 12:56:03 +05:30
parent ec252c806f
commit 800c69eec3

View File

@ -11,6 +11,7 @@ class AssessmentPlan(Document):
def validate(self):
self.validate_overlap()
self.validate_max_score()
self.validate_assessment_criteria()
def validate_overlap(self):
"""Validates overlap for Student Group, Instructor, Room"""
@ -37,3 +38,13 @@ class AssessmentPlan(Document):
max_score += d.maximum_score
if self.maximum_assessment_score != max_score:
frappe.throw(_("Sum of Scores of Assessment Criteria needs to be {0}.".format(self.maximum_assessment_score)))
def validate_assessment_criteria(self):
assessment_criteria_list = frappe.db.sql_list(''' select apc.assessment_criteria
from `tabAssessment Plan` ap , `tabAssessment Plan Criteria` apc
where ap.name = apc.parent and ap.course=%s and ap.student_group=%s and ap.assessment_group=%s
and ap.name != %s''', (self.course, self.student_group, self.assessment_group, self.name))
for d in self.assessment_criteria:
if d.assessment_criteria in assessment_criteria_list:
frappe.throw(_("You have already assessed for the assessment criteria {}.")
.format(frappe.bold(d.assessment_criteria)))