Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
edx-platform
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
edx-platform
Commits
51e148a7
Commit
51e148a7
authored
Nov 30, 2012
by
Vik Paruchuri
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add in support for rendering feedback within lms
parent
835f1879
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
74 additions
and
2 deletions
+74
-2
common/lib/capa/capa/responsetypes.py
+44
-2
lms/templates/open_ended_error.html
+13
-0
lms/templates/open_ended_feedback.html
+17
-0
No files found.
common/lib/capa/capa/responsetypes.py
View file @
51e148a7
...
...
@@ -24,6 +24,7 @@ import os
import
subprocess
import
xml.sax.saxutils
as
saxutils
from
shapely.geometry
import
Point
,
MultiPoint
from
django.template.loader
import
render_to_string
# specific library imports
from
calc
import
evaluator
,
UndefinedVariable
...
...
@@ -1965,6 +1966,8 @@ class OpenEndedResponse(LoncapaResponse):
'max_score'
:
self
.
max_score
})
log
.
debug
(
xheader
)
log
.
debug
(
contents
)
# Submit request. When successful, 'msg' is the prior length of the queue
(
error
,
msg
)
=
qinterface
.
send_to_queue
(
header
=
xheader
,
body
=
json
.
dumps
(
contents
))
...
...
@@ -2027,6 +2030,40 @@ class OpenEndedResponse(LoncapaResponse):
def
get_initial_display
(
self
):
return
{
self
.
answer_id
:
self
.
initial_display
}
def
_format_feedback
(
self
,
response_items
):
"""
Input:
Dictionary called feedback. Must contain keys seen below.
Output:
Return success/fail, error message or feedback template
"""
tags
=
[
'feedback_items'
,
'score'
,
'grader_type'
]
for
tag
in
tags
:
if
tag
not
in
response_items
:
return
False
,
"Grader response missing required feedback key!"
if
'errors'
in
response_items
[
'feedback_items'
]:
return
True
,
render_to_string
(
"open_ended_error.html"
,
{
'errors'
:
response_items
[
'feedback_items'
][
'errors'
]})
feedback_item_start
=
'<div class="{feedback_key}">'
feedback_item_end
=
'</div>'
feedback_long
=
""
for
k
,
v
in
response_items
:
feedback_long
+=
feedback_item_start
.
format
(
feedback_key
=
k
)
feedback_long
+=
v
feedback_long
+=
feedback_item_end
feedback_template
=
render_to_string
(
"open_ended_feedback.html"
,{
'grader_type'
:
response_items
[
'grader_type'
],
'score'
:
response_items
[
'score'
],
'feedback_long'
:
feedback_long
,
})
return
True
,
feedback_template
def
_parse_score_msg
(
self
,
score_msg
):
"""
Grader reply is a JSON-dump of the following dict
...
...
@@ -2052,7 +2089,7 @@ class OpenEndedResponse(LoncapaResponse):
log
.
error
(
"External grader message should be a JSON-serialized dict."
" Received score_result =
%
s"
%
score_result
)
return
fail
for
tag
in
[
'score'
,
'feedback'
]:
for
tag
in
[
'score'
,
'feedback'
,
'grader_type'
]:
if
tag
not
in
score_result
:
log
.
error
(
"External grader message is missing one or more required"
" tags: 'score', 'feedback"
)
...
...
@@ -2062,7 +2099,12 @@ class OpenEndedResponse(LoncapaResponse):
# is safe for the LMS.
# 1) Make sure that the message is valid XML (proper opening/closing tags)
# 2) TODO: Is the message actually HTML?
feedback
=
score_result
[
'feedback'
]
feedback
=
self
.
_format_feedback
({
'score'
:
score_result
[
'score'
],
'feedback_items'
:
score_result
[
'feedback'
],
'grader_type'
:
score_result
[
'grader_type'
],
})
score_ratio
=
int
(
score_result
[
'score'
])
/
self
.
max_score
...
...
lms/templates/open_ended_error.html
0 → 100644
View file @
51e148a7
<section>
<div
class=
"shortform"
>
<div
class=
"result-errors"
>
There was an error with your submission. Please contact course staff.
</div>
</div>
<div
class=
"longform"
>
<div
class=
"result-errors"
>
{errors}
</div>
</div>
</section>
\ No newline at end of file
lms/templates/open_ended_feedback.html
0 → 100644
View file @
51e148a7
<section>
<header>
Feedback
</header>
<div
class=
"shortform"
>
<div
class=
"result-output"
>
<p>
Score: ${score}
</p>
% if grader_type=="ML"
<p>
Number of potential problem areas identified: ${problem_areas}
</p>
% endif
</div>
</div>
<div
class=
"longform"
>
<div
class=
"result-output"
>
${feedback_long}
</div>
</div>
</section>
\ No newline at end of file
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