def encode_problem_and_student_input(usage_key, student=None):
 assert isinstance(usage_key, UsageKey)
 if (student is not None):
  task_input = {'problem_url': usage_key.to_deprecated_string(), 'student': student.username}
  task_key_stub = '{student}_{problem}'.format(student=student.id, problem=usage_key.to_deprecated_string())
 else:
  task_input = {'problem_url': usage_key.to_deprecated_string()}
  task_key_stub = '_{problem}'.format(problem=usage_key.to_deprecated_string())
 task_key = hashlib.md5(task_key_stub).hexdigest()
 return (task_input, task_key)

def encode_problem_and_student_input ( usage_key , student = None ) : assert isinstance ( usage_key , UsageKey ) if ( student is not None ) : task_input = { 'problem_url' : usage_key . to_deprecated_string ( ) , 'student' : student . username } task_key_stub = '{student}_{problem}' . format ( student = student . id , problem = usage_key . to_deprecated_string ( ) ) else : task_input = { 'problem_url' : usage_key . to_deprecated_string ( ) } task_key_stub = '_{problem}' . format ( problem = usage_key . to_deprecated_string ( ) ) task_key = hashlib . md5 ( task_key_stub ) . hexdigest ( ) return ( task_input , task_key )
encode optional usage_key and optional student into task_key and task_input values .