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
838a8624
Commit
838a8624
authored
Jul 16, 2012
by
kimth
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add docstring to 'score_update' path
parent
e7c25c99
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
24 additions
and
4 deletions
+24
-4
common/lib/capa/capa/capa_problem.py
+7
-1
common/lib/capa/capa/responsetypes.py
+8
-3
common/lib/xmodule/xmodule/capa_module.py
+9
-0
No files found.
common/lib/capa/capa/capa_problem.py
View file @
838a8624
...
...
@@ -180,9 +180,15 @@ class LoncapaProblem(object):
'total'
:
self
.
get_max_score
()}
def
update_score
(
self
,
score_msg
):
'''
Deliver grading response (e.g. from async code checking) to
the specific ResponseType
Returns an updated CorrectMap
'''
newcmap
=
CorrectMap
()
for
responder
in
self
.
responders
.
values
():
if
hasattr
(
responder
,
'update_score'
):
#
Is this the best way to implement 'update_score' for
CodeResponse?
if
hasattr
(
responder
,
'update_score'
):
#
TODO: Is this the best way to target 'update_score' of
CodeResponse?
results
=
responder
.
update_score
(
score_msg
)
newcmap
.
update
(
results
)
self
.
correct_map
=
newcmap
...
...
common/lib/capa/capa/responsetypes.py
View file @
838a8624
...
...
@@ -696,7 +696,9 @@ class SymbolicResponse(CustomResponse):
class
CodeResponse
(
LoncapaResponse
):
'''
Grade student code using an external server
Grade student code using an external server. Unlike ExternalResponse, CodeResponse:
1) Goes through a queueing system (xqueue)
2) Does not do external request for 'get_answers'
'''
response_tag
=
'coderesponse'
...
...
@@ -704,9 +706,10 @@ class CodeResponse(LoncapaResponse):
def
setup_response
(
self
):
xml
=
self
.
xml
self
.
url
=
xml
.
get
(
'url'
)
or
"http://ec2-50-16-59-149.compute-1.amazonaws.com/xqueue/submit/"
# FIXME -- hardcoded url
self
.
url
=
xml
.
get
(
'url'
,
"http://ec2-50-16-59-149.compute-1.amazonaws.com/xqueue/submit/"
)
# FIXME -- hardcoded url
answer
=
xml
.
find
(
'answer'
)
if
answer
is
not
None
:
answer_src
=
answer
.
get
(
'src'
)
if
answer_src
is
not
None
:
...
...
@@ -791,7 +794,9 @@ class CodeResponse(LoncapaResponse):
# Prepare payload
xmlstr
=
etree
.
tostring
(
self
.
xml
,
pretty_print
=
True
)
header
=
{
'return_url'
:
self
.
system
.
xqueue_callback_url
}
header
.
update
({
'timestamp'
:
time
.
time
()})
# header.update({'timestamp': time.time()})
random
.
seed
()
header
.
update
({
'key'
:
random
.
randint
(
0
,
2
**
32
-
1
)})
payload
=
{
'xqueue_header'
:
json
.
dumps
(
header
),
# 'xqueue_header' should eventually be derived from xqueue.queue_common.HEADER_TAG or something similar
'xml'
:
xmlstr
,
'edX_cmd'
:
'get_score'
,
...
...
common/lib/xmodule/xmodule/capa_module.py
View file @
838a8624
...
...
@@ -323,6 +323,15 @@ class CapaModule(XModule):
raise
self
.
system
.
exception404
def
update_score
(
self
,
get
):
"""
Delivers grading response (e.g. from asynchronous code checking) to
the capa problem, so its score can be updated
'get' must have a field 'response' which is a string that contains the
grader's response
No ajax return is needed. Return empty dict.
"""
score_msg
=
get
[
'response'
]
self
.
lcp
.
update_score
(
score_msg
)
...
...
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