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
8eff9f7c
Commit
8eff9f7c
authored
Aug 03, 2012
by
kimth
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Upload to xqueue
parent
9d52c432
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
20 additions
and
8 deletions
+20
-8
common/lib/capa/capa/responsetypes.py
+11
-5
common/lib/capa/capa/xqueue_interface.py
+9
-3
No files found.
common/lib/capa/capa/responsetypes.py
View file @
8eff9f7c
...
...
@@ -848,12 +848,13 @@ class CodeResponse(LoncapaResponse):
def
get_score
(
self
,
student_answers
):
try
:
submission
=
student_answers
[
self
.
answer_id
]
submission
=
student_answers
[
self
.
answer_id
]
# Note that submission can be a file
except
Exception
as
err
:
log
.
error
(
'Error in CodeResponse
%
s: cannot get student answer for
%
s; student_answers=
%
s'
%
(
err
,
self
.
answer_id
,
student_answers
))
log
.
error
(
'Error in CodeResponse
%
s: cannot get student answer for
%
s; student_answers=
%
s'
%
(
err
,
self
.
answer_id
,
convert_files_to_filenames
(
student_answers
)))
raise
Exception
(
err
)
self
.
context
.
update
({
'submission'
:
unicode
(
submission
)})
# Submission could be a file
self
.
context
.
update
({
'submission'
:
unicode
(
submission
)})
# Prepare xqueue request
#------------------------------------------------------------
...
...
@@ -873,8 +874,13 @@ class CodeResponse(LoncapaResponse):
'edX_student_response'
:
unicode
(
submission
)}
# Submit request
error
=
xqueue_interface
.
send_to_queue
(
header
=
xheader
,
body
=
json
.
dumps
(
contents
))
if
hasattr
(
submission
,
'read'
):
# Test for whether submission is a file
error
=
xqueue_interface
.
send_to_queue
(
header
=
xheader
,
body
=
json
.
dumps
(
contents
),
file_to_upload
=
submission
)
else
:
error
=
xqueue_interface
.
send_to_queue
(
header
=
xheader
,
body
=
json
.
dumps
(
contents
))
cmap
=
CorrectMap
()
if
error
:
...
...
common/lib/capa/capa/xqueue_interface.py
View file @
8eff9f7c
...
...
@@ -37,7 +37,7 @@ def make_xheader(lms_callback_url, lms_key, queue_name):
'queue_name'
:
queue_name
})
def
send_to_queue
(
header
,
body
,
xqueue_url
=
None
):
def
send_to_queue
(
header
,
body
,
file_to_upload
=
None
,
xqueue_url
=
None
):
'''
Submit a request to xqueue.
...
...
@@ -46,6 +46,8 @@ def send_to_queue(header, body, xqueue_url=None):
body: Serialized data for the receipient behind the queueing service. The operation of
xqueue is agnostic to the contents of 'body'
file_to_upload: File object to be uploaded to xqueue along with queue request
Returns an 'error' flag indicating error in xqueue transaction
'''
if
xqueue_url
is
None
:
...
...
@@ -72,9 +74,13 @@ def send_to_queue(header, body, xqueue_url=None):
#------------------------------------------------------------
payload
=
{
'xqueue_header'
:
header
,
'xqueue_body'
:
body
}
files
=
None
if
file_to_upload
is
not
None
:
files
=
{
file_to_upload
.
name
:
file_to_upload
}
try
:
# Send request
r
=
s
.
post
(
xqueue_url
+
'/xqueue/submit/'
,
data
=
payload
)
r
=
s
.
post
(
xqueue_url
+
'/xqueue/submit/'
,
data
=
payload
,
files
=
files
)
except
Exception
as
err
:
msg
=
'Error in xqueue_interface.send_to_queue
%
s: Cannot connect to server url=
%
s'
%
(
err
,
xqueue_url
)
raise
Exception
(
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