def grade(grader_data,submission):
<EOL>results = {'<STR_LIT>': [],'<STR_LIT>': [],'<STR_LIT>': <NUM_LIT:0>, '<STR_LIT>' : "<STR_LIT>", '<STR_LIT:success>' : False, '<STR_LIT>' : <NUM_LIT:0>}<EOL>has_error=False<EOL>grader_set=EssaySet(essaytype="<STR_LIT:test>")<EOL>feedback = {}<EOL>model, extractor = get_classifier_and_ext(grader_data)<EOL>if '<STR_LIT>' not in grader_data:<EOL><INDENT>grader_data['<STR_LIT>'] = util_functions.AlgorithmTypes.classification<EOL><DEDENT>try:<EOL><INDENT>grader_set.add_essay(str(submission),<NUM_LIT:0>)<EOL>grader_set.update_prompt(str(grader_data['<STR_LIT>']))<EOL><DEDENT>except Exception:<EOL><INDENT>error_message = "<STR_LIT>".format(submission)<EOL>log.exception(error_message)<EOL>results['<STR_LIT>'].append(error_message)<EOL>has_error=True<EOL><DEDENT>try:<EOL><INDENT>grader_feats=extractor.gen_feats(grader_set)<EOL>feedback=extractor.gen_feedback(grader_set,grader_feats)[<NUM_LIT:0>]<EOL>results['<STR_LIT>']=int(model.predict(grader_feats)[<NUM_LIT:0>])<EOL><DEDENT>except Exception:<EOL><INDENT>error_message = "<STR_LIT>"<EOL>log.exception(error_message)<EOL>results['<STR_LIT>'].append(error_message)<EOL>has_error=True<EOL><DEDENT>try:<EOL><INDENT>results['<STR_LIT>'] = get_confidence_value(grader_data['<STR_LIT>'], model, grader_feats, results['<STR_LIT>'], grader_data['<STR_LIT>'])<EOL><DEDENT>except Exception:<EOL><INDENT>log.exception("<STR_LIT>")<EOL><DEDENT>if not has_error:<EOL><INDENT>if( '<STR_LIT>' in feedback and feedback['<STR_LIT>']):<EOL><INDENT>results['<STR_LIT>']=<NUM_LIT:0><EOL>results['<STR_LIT>']=False<EOL><DEDENT>results['<STR_LIT:success>']=True<EOL>results['<STR_LIT>'] = {}<EOL>if '<STR_LIT>' in feedback and '<STR_LIT>' in feedback:<EOL><INDENT>results['<STR_LIT>'].update({<EOL>'<STR_LIT>' : feedback['<STR_LIT>'],<EOL>'<STR_LIT>' : feedback['<STR_LIT>'],<EOL>})<EOL><DEDENT>results['<STR_LIT>'].update(<EOL>{<EOL>'<STR_LIT>' : feedback['<STR_LIT>'],<EOL>'<STR_LIT>' : feedback['<STR_LIT>'],<EOL>'<STR_LIT>' : feedback['<STR_LIT>'],<EOL>}<EOL>)<EOL><DEDENT>else:<EOL><INDENT>results['<STR_LIT:success>']=False<EOL><DEDENT>return results<EOL>
Grades a specified submission using specified models
grader_data - A dictionary:
{
    'model' : trained model,
    'extractor' : trained feature extractor,
    'prompt' : prompt for the question,
    'algorithm' : algorithm for the question,
}
submission - The student submission (string)