def encode_entrance_exam_and_student_input(usage_key, student=None):
 assert isinstance(usage_key, UsageKey)
 if (student is not None):
  task_input = {'entrance_exam_url': unicode(usage_key), 'student': student.username}
  task_key_stub = '{student}_{entranceexam}'.format(student=student.id, entranceexam=unicode(usage_key))
 else:
  task_input = {'entrance_exam_url': unicode(usage_key)}
  task_key_stub = '_{entranceexam}'.format(entranceexam=unicode(usage_key))
 task_key = hashlib.md5(task_key_stub).hexdigest()
 return (task_input, task_key)

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