@frappe.whitelist()
def get_grade(grading_scale, percentage):
 grading_scale_intervals = {}
 for d in frappe.get_all(u'Grading Scale Interval', fields=[u'grade_code', u'threshold'], filters={u'parent': grading_scale}):
  grading_scale_intervals.update({d.threshold: d.grade_code})
 intervals = sorted(grading_scale_intervals.keys(), key=float, reverse=True)
 for interval in intervals:
  if (flt(percentage) >= interval):
   grade = grading_scale_intervals.get(interval)
   break
  else:
   grade = u''
 return grade

@ frappe . whitelist ( ) def get_grade ( grading_scale , percentage ) : grading_scale_intervals = { } for d in frappe . get_all ( u'Grading Scale Interval' , fields = [ u'grade_code' , u'threshold' ] , filters = { u'parent' : grading_scale } ) : grading_scale_intervals . update ( { d . threshold : d . grade_code } ) intervals = sorted ( grading_scale_intervals . keys ( ) , key = float , reverse = True ) for interval in intervals : if ( flt ( percentage ) >= interval ) : grade = grading_scale_intervals . get ( interval ) break else : grade = u'' return grade
returns grade based on the grading scale and score .