@CELERY_APP.task(name='lti_provider.tasks.send_composite_outcome')
def send_composite_outcome(user_id, course_id, assignment_id, version):
 assignment = GradedAssignment.objects.get(id=assignment_id)
 if (version != assignment.version_number):
  log.info('Score passback for GradedAssignment %s skipped. More recent score available.', assignment.id)
  return
 course_key = CourseKey.from_string(course_id)
 mapped_usage_key = assignment.usage_key.map_into_course(course_key)
 user = User.objects.get(id=user_id)
 course = modulestore().get_course(course_key, depth=0)
 course_grade = CourseGradeFactory().create(user, course)
 (earned, possible) = course_grade.score_for_module(mapped_usage_key)
 if (possible == 0):
  weighted_score = 0
 else:
  weighted_score = (float(earned) / float(possible))
 assignment = GradedAssignment.objects.get(id=assignment_id)
 if (assignment.version_number == version):
  outcomes.send_score_update(assignment, weighted_score)

@ CELERY_APP . task ( name = 'lti_provider.tasks.send_composite_outcome' ) def send_composite_outcome ( user_id , course_id , assignment_id , version ) : assignment = GradedAssignment . objects . get ( id = assignment_id ) if ( version != assignment . version_number ) : log . info ( 'Score passback for GradedAssignment %s skipped. More recent score available.' , assignment . id ) return course_key = CourseKey . from_string ( course_id ) mapped_usage_key = assignment . usage_key . map_into_course ( course_key ) user = User . objects . get ( id = user_id ) course = modulestore ( ) . get_course ( course_key , depth = 0 ) course_grade = CourseGradeFactory ( ) . create ( user , course ) ( earned , possible ) = course_grade . score_for_module ( mapped_usage_key ) if ( possible == 0 ) : weighted_score = 0 else : weighted_score = ( float ( earned ) / float ( possible ) ) assignment = GradedAssignment . objects . get ( id = assignment_id ) if ( assignment . version_number == version ) : outcomes . send_score_update ( assignment , weighted_score )
calculate and transmit the score for a composite module .