def _update_subsection_grades(course_key, scored_block_usage_key, only_if_higher, user_id):
 student = User.objects.get(id=user_id)
 store = modulestore()
 with store.bulk_operations(course_key):
  course_structure = get_course_blocks(student, store.make_course_usage_key(course_key))
  subsections_to_update = course_structure.get_transformer_block_field(scored_block_usage_key, GradesTransformer, 'subsections', set())
  course = store.get_course(course_key, depth=0)
  subsection_grade_factory = SubsectionGradeFactory(student, course, course_structure)
  for subsection_usage_key in subsections_to_update:
   if (subsection_usage_key in course_structure):
    subsection_grade = subsection_grade_factory.update(course_structure[subsection_usage_key], only_if_higher)
    SUBSECTION_SCORE_CHANGED.send(sender=None, course=course, course_structure=course_structure, user=student, subsection_grade=subsection_grade)

def _update_subsection_grades ( course_key , scored_block_usage_key , only_if_higher , user_id ) : student = User . objects . get ( id = user_id ) store = modulestore ( ) with store . bulk_operations ( course_key ) : course_structure = get_course_blocks ( student , store . make_course_usage_key ( course_key ) ) subsections_to_update = course_structure . get_transformer_block_field ( scored_block_usage_key , GradesTransformer , 'subsections' , set ( ) ) course = store . get_course ( course_key , depth = 0 ) subsection_grade_factory = SubsectionGradeFactory ( student , course , course_structure ) for subsection_usage_key in subsections_to_update : if ( subsection_usage_key in course_structure ) : subsection_grade = subsection_grade_factory . update ( course_structure [ subsection_usage_key ] , only_if_higher ) SUBSECTION_SCORE_CHANGED . send ( sender = None , course = course , course_structure = course_structure , user = student , subsection_grade = subsection_grade )
a helper function to update subsection grades in the database for each subsection containing the given block .