Commit 5e05459f by Vik Paruchuri

Fix classes in template, add number of problem areas in shortform feedback.

parent 9a39aeb3
...@@ -23,34 +23,49 @@ import sklearn.ensemble ...@@ -23,34 +23,49 @@ import sklearn.ensemble
log = logging.getLogger(__name__) log = logging.getLogger(__name__)
feedback_template = u""" feedback_template = u"""
<div class="feedback">
<header>Feedback</header> <header>Feedback</header>
<section> <section>
<div class="topicality"> <div class="shortform">
{topicality} <div class="result-output">
</div> There are {problem_areas} potential problem areas in your submission.
<div class="spelling"> </div>
{spelling}
</div>
<div class="grammar">
{grammar}
</div> </div>
<div class="markup_text"> <div class="longform">
{markup_text} <div class="result-output">
<div class="topicality">
Topicality: {topicality}
</div>
<div class="spelling">
Spelling: {spelling}
</div>
<div class="grammar">
Grammar: {grammar}
</div>
<div class="markup-text">
{markup_text}
</div>
</div>
</div> </div>
</section> </section>
</div>
""" """
error_template = u""" error_template = u"""
<div class="feedback">
<header>Feedback</header> <section>
<section> <div class="shortform">
<div class="error"> <div class="result-errors">
{errors} There was an error with your submission. Please contact course staff.
</div>
</div>
<div class="longform">
<div class="result-errors">
{errors}
</div>
</div> </div>
</section> </section>
</div>
""" """
...@@ -86,6 +101,11 @@ def grade(grader_path,submission,sandbox=None): ...@@ -86,6 +101,11 @@ def grade(grader_path,submission,sandbox=None):
results['errors'].append("Could not extract features and score essay.") results['errors'].append("Could not extract features and score essay.")
has_error=True has_error=True
#Generate short form output--number of problem areas identified in feedback
problem_areas=0
for tag in feedback:
problem_areas+=len(feedback[tag])>5
#Determine maximum score and correctness of response #Determine maximum score and correctness of response
max_score=numpy.max(grader_data['model'].classes_) max_score=numpy.max(grader_data['model'].classes_)
if results['score']/float(max_score) >= .66: if results['score']/float(max_score) >= .66:
...@@ -96,7 +116,8 @@ def grade(grader_path,submission,sandbox=None): ...@@ -96,7 +116,8 @@ def grade(grader_path,submission,sandbox=None):
#Add feedback template to results #Add feedback template to results
if not has_error: if not has_error:
results['feedback']=feedback_template.format(topicality=feedback['topicality'], results['feedback']=feedback_template.format(topicality=feedback['topicality'],
spelling=feedback['spelling'],grammar=feedback['grammar'],markup_text=feedback['markup_text']) spelling=feedback['spelling'],grammar=feedback['grammar'],
markup_text=feedback['markup_text'],problem_areas=problem_areas)
else: else:
results['feedback']=error_template.format(errors=' '.join(results['errors'])) results['feedback']=error_template.format(errors=' '.join(results['errors']))
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment