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
73bd46d7
Commit
73bd46d7
authored
Aug 02, 2012
by
kimth
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
LMS must login before submitting to xqueue
parent
faf3d2c3
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
33 additions
and
11 deletions
+33
-11
common/lib/capa/capa/responsetypes.py
+5
-5
lms/djangoapps/courseware/xqueue_interface.py
+28
-6
No files found.
common/lib/capa/capa/responsetypes.py
View file @
73bd46d7
...
@@ -881,15 +881,15 @@ class CodeResponse(LoncapaResponse):
...
@@ -881,15 +881,15 @@ class CodeResponse(LoncapaResponse):
'edX_student_response'
:
submission
}
'edX_student_response'
:
submission
}
# Submit request
# Submit request
success
=
xqueue_interface
.
send_to_queue
(
header
=
xheader
,
error
=
xqueue_interface
.
send_to_queue
(
header
=
xheader
,
body
=
json
.
dumps
(
contents
))
body
=
json
.
dumps
(
contents
))
cmap
=
CorrectMap
()
cmap
=
CorrectMap
()
if
success
:
if
error
:
cmap
.
set
(
self
.
answer_id
,
msg
=
'Unable to deliver your submission to grader! Please try again later'
)
else
:
# Non-null CorrectMap['queuekey'] indicates that the problem has been queued
# Non-null CorrectMap['queuekey'] indicates that the problem has been queued
cmap
.
set
(
self
.
answer_id
,
queuekey
=
queuekey
,
msg
=
'Submitted to grader'
)
cmap
.
set
(
self
.
answer_id
,
queuekey
=
queuekey
,
msg
=
'Submitted to grader'
)
else
:
cmap
.
set
(
self
.
answer_id
,
msg
=
'Unable to deliver submission to grader! Please try again later'
)
return
cmap
return
cmap
...
...
lms/djangoapps/courseware/xqueue_interface.py
View file @
73bd46d7
...
@@ -5,7 +5,8 @@ import json
...
@@ -5,7 +5,8 @@ import json
import
requests
import
requests
# TODO: Collection of parameters to be hooked into rest of edX system
# TODO: Collection of parameters to be hooked into rest of edX system
XQUEUE_SUBMIT_URL
=
'http://xqueue.edx.org/xqueue/submit/'
XQUEUE_LMS_AUTH
=
(
'LMS'
,
'PaloAltoCA'
)
# (username, password)
XQUEUE_SUBMIT_URL
=
'http://xqueue.edx.org'
def
upload_files_to_s3
():
def
upload_files_to_s3
():
print
' THK: xqueue_interface.upload_files_to_s3'
print
' THK: xqueue_interface.upload_files_to_s3'
...
@@ -35,21 +36,42 @@ def send_to_queue(header, body, xqueue_url=None):
...
@@ -35,21 +36,42 @@ def send_to_queue(header, body, xqueue_url=None):
body: Serialized data for the receipient behind the queueing service. The operation of
body: Serialized data for the receipient behind the queueing service. The operation of
xqueue is agnostic to the contents of 'body'
xqueue is agnostic to the contents of 'body'
Returns a
'success' flag indicating successful submiss
ion
Returns a
n 'error' flag indicating error in xqueue transact
ion
'''
'''
if
xqueue_url
is
None
:
if
xqueue_url
is
None
:
xqueue_url
=
XQUEUE_SUBMIT_URL
xqueue_url
=
XQUEUE_SUBMIT_URL
# Contact queue server
# First, we login with our credentials
#------------------------------------------------------------
s
=
requests
.
session
()
try
:
r
=
s
.
post
(
xqueue_url
+
'/xqueue/login/'
,
data
=
{
'username'
:
XQUEUE_LMS_AUTH
[
0
],
'password'
:
XQUEUE_LMS_AUTH
[
1
]
})
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
)
# Xqueue responses are JSON-serialized dicts
xreply
=
json
.
loads
(
r
.
text
)
return_code
=
xreply
[
'return_code'
]
if
return_code
:
# Nonzero return code from xqueue indicates error
print
' Error in queue_interface.send_to_queue:
%
s'
%
xreply
[
'content'
]
return
1
# Error
# Next, we can make a queueing request
#------------------------------------------------------------
payload
=
{
'xqueue_header'
:
header
,
payload
=
{
'xqueue_header'
:
header
,
'xqueue_body'
:
body
}
'xqueue_body'
:
body
}
try
:
try
:
r
=
requests
.
post
(
xqueue_url
,
data
=
payload
)
# Send request
r
=
s
.
post
(
xqueue_url
+
'/xqueue/submit/'
,
data
=
payload
)
except
Exception
as
err
:
except
Exception
as
err
:
msg
=
'Error in xqueue_interface.send_to_queue
%
s: Cannot connect to server url=
%
s'
%
(
err
,
xqueue_url
)
msg
=
'Error in xqueue_interface.send_to_queue
%
s: Cannot connect to server url=
%
s'
%
(
err
,
xqueue_url
)
raise
Exception
(
msg
)
raise
Exception
(
msg
)
# Xqueue responses are JSON-serialized dicts
xreply
=
json
.
loads
(
r
.
text
)
xreply
=
json
.
loads
(
r
.
text
)
return_code
=
xreply
[
'return_code'
]
if
return_code
:
print
' Error in queue_interface.send_to_queue:
%
s'
%
xreply
[
'content'
]
return
xreply
[
'return_code'
]
==
0
# return_code == 0 from xqueue indicates successful submission
return
return_code
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