Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
ease
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
edx
ease
Commits
d6ddd2d7
Commit
d6ddd2d7
authored
Nov 07, 2012
by
Vik Paruchuri
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Alter feedback handling to return feedback as an html string based on a template.
parent
f5df42e6
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
28 additions
and
2 deletions
+28
-2
grade.py
+28
-2
No files found.
grade.py
View file @
d6ddd2d7
...
...
@@ -22,9 +22,30 @@ import sklearn.ensemble
log
=
logging
.
getLogger
(
__name__
)
feedback_template
=
u"""
<div class="feedback">
<header>Feedback</header>
<section>
<div class="topicality">
{topicality}
</div>
<div class="spelling">
{spelling}
</div>
<div class="grammar">
{grammar}
</div>
<div class="markup_text">
{markup_text}
</div>
</section>
</div>
"""
def
grade
(
grader_path
,
submission
,
sandbox
=
None
):
log
.
debug
(
"Grader path: {0}
\n
Submission: {1}"
.
format
(
grader_path
,
submission
))
results
=
{
'errors'
:
[],
'tests'
:
[],
'correct'
:
False
,
'score'
:
0
,
'feedback'
:
[]
}
results
=
{
'errors'
:
[],
'tests'
:
[],
'correct'
:
False
,
'score'
:
0
,
'feedback'
:
""
}
#Try to find and load the model file
...
...
@@ -44,7 +65,7 @@ def grade(grader_path,submission,sandbox=None):
#Try to extract features from submission and assign score via the model
try
:
grader_feats
=
grader_data
[
'extractor'
]
.
gen_feats
(
grader_set
)
results
[
'feedback'
]
=
grader_data
[
'extractor'
]
.
gen_feedback
(
grader_set
)
feedback
=
grader_data
[
'extractor'
]
.
gen_feedback
(
grader_set
)
results
[
'score'
]
=
int
(
grader_data
[
'model'
]
.
predict
(
grader_feats
)[
0
])
except
:
results
[
'errors'
]
.
append
(
"Could not extract features and score essay."
)
...
...
@@ -55,6 +76,11 @@ def grade(grader_path,submission,sandbox=None):
results
[
'correct'
]
=
True
else
:
results
[
'correct'
]
=
False
#Add feedback template to results
results
[
"feedback"
]
=
feedback_template
.
format
(
topicality
=
feedback
[
'topicality'
],
spelling
=
feedback
[
'spelling'
],
grammar
=
feedback
[
'grammar'
],
markup_text
=
feedback
[
'markup_text'
])
return
results
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment