'Updates the SubsectionGrade object for the student and subsection.'

def update(self, subsection, only_if_higher=None):

    self._log_event(log.warning, u'update,    subsection:    {}'.format(subsection.location), subsection)
    calculated_grade = SubsectionGrade(subsection).init_from_structure(self.student, self.course_data.structure, self._submissions_scores, self._csm_scores)
    if should_persist_grades(self.course_data.course_key):
        if only_if_higher:
            try:
                grade_model = PersistentSubsectionGrade.read_grade(self.student.id, subsection.location)
            except PersistentSubsectionGrade.DoesNotExist:
                pass
            else:
                orig_subsection_grade = SubsectionGrade(subsection).init_from_model(self.student, grade_model, self.course_data.structure, self._submissions_scores, self._csm_scores)
                if (not is_score_higher_or_equal(orig_subsection_grade.graded_total.earned, orig_subsection_grade.graded_total.possible, calculated_grade.graded_total.earned, calculated_grade.graded_total.possible)):
                    return orig_subsection_grade
        grade_model = calculated_grade.update_or_create_model(self.student)
        self._update_saved_subsection_grade(subsection.location, grade_model)
    return calculated_grade
