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
b9773b5d
Commit
b9773b5d
authored
Jul 31, 2012
by
ichuang
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #323 from MITx/kimth/lms-coderesponse
Kimth/lms coderesponse
parents
f0999281
11495563
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
34 additions
and
14 deletions
+34
-14
common/lib/capa/capa/inputtypes.py
+9
-3
common/lib/capa/capa/responsetypes.py
+3
-3
common/lib/capa/capa/templates/textbox.html
+7
-2
common/lib/xmodule/xmodule/x_module.py
+2
-1
lms/djangoapps/courseware/module_render.py
+13
-5
No files found.
common/lib/capa/capa/inputtypes.py
View file @
b9773b5d
...
@@ -313,14 +313,20 @@ def textbox(element, value, status, render_template, msg=''):
...
@@ -313,14 +313,20 @@ def textbox(element, value, status, render_template, msg=''):
size
=
element
.
get
(
'size'
)
size
=
element
.
get
(
'size'
)
rows
=
element
.
get
(
'rows'
)
or
'30'
rows
=
element
.
get
(
'rows'
)
or
'30'
cols
=
element
.
get
(
'cols'
)
or
'80'
cols
=
element
.
get
(
'cols'
)
or
'80'
mode
=
element
.
get
(
'mode'
)
or
'python'
# mode for CodeMirror, eg "python" or "xml"
hidden
=
element
.
get
(
'hidden'
,
''
)
# if specified, then textline is hidden and id is stored in div of name given by hidden
hidden
=
element
.
get
(
'hidden'
,
''
)
# if specified, then textline is hidden and id is stored in div of name given by hidden
linenumbers
=
element
.
get
(
'linenumbers'
,
'true'
)
# for CodeMirror
if
not
value
:
value
=
element
.
text
# if no student input yet, then use the default input given by the problem
if
not
value
:
value
=
element
.
text
# if no student input yet, then use the default input given by the problem
# For CodeMirror
mode
=
element
.
get
(
'mode'
)
or
'python'
# mode, eg "python" or "xml"
linenumbers
=
element
.
get
(
'linenumbers'
,
'true'
)
# for CodeMirror
tabsize
=
element
.
get
(
'tabsize'
,
'4'
)
tabsize
=
int
(
tabsize
)
context
=
{
'id'
:
eid
,
'value'
:
value
,
'state'
:
status
,
'count'
:
count
,
'size'
:
size
,
'msg'
:
msg
,
context
=
{
'id'
:
eid
,
'value'
:
value
,
'state'
:
status
,
'count'
:
count
,
'size'
:
size
,
'msg'
:
msg
,
'mode'
:
mode
,
'linenumbers'
:
linenumbers
,
'mode'
:
mode
,
'linenumbers'
:
linenumbers
,
'rows'
:
rows
,
'cols'
:
cols
,
'rows'
:
rows
,
'cols'
:
cols
,
'hidden'
:
hidden
,
'hidden'
:
hidden
,
'tabsize'
:
tabsize
,
}
}
html
=
render_template
(
"textbox.html"
,
context
)
html
=
render_template
(
"textbox.html"
,
context
)
try
:
try
:
...
...
common/lib/capa/capa/responsetypes.py
View file @
b9773b5d
...
@@ -811,7 +811,7 @@ class CodeResponse(LoncapaResponse):
...
@@ -811,7 +811,7 @@ class CodeResponse(LoncapaResponse):
def
setup_response
(
self
):
def
setup_response
(
self
):
xml
=
self
.
xml
xml
=
self
.
xml
self
.
url
=
xml
.
get
(
'url'
,
"http://107.20.215.194/xqueue/submit/"
)
# FIXME -- hardcoded url
self
.
url
=
xml
.
get
(
'url'
,
"http://107.20.215.194/xqueue/submit/"
)
# FIXME -- hardcoded url
self
.
queue_name
=
xml
.
get
(
'queuename'
,
'python'
)
# TODO: Default queue_name should be course-specific
self
.
queue_name
=
xml
.
get
(
'queuename'
,
self
.
system
.
xqueue_default_queuename
)
answer
=
xml
.
find
(
'answer'
)
answer
=
xml
.
find
(
'answer'
)
if
answer
is
not
None
:
if
answer
is
not
None
:
...
@@ -905,7 +905,7 @@ class CodeResponse(LoncapaResponse):
...
@@ -905,7 +905,7 @@ class CodeResponse(LoncapaResponse):
def
_send_to_queue
(
self
,
extra_payload
):
def
_send_to_queue
(
self
,
extra_payload
):
# Prepare payload
# Prepare payload
xmlstr
=
etree
.
tostring
(
self
.
xml
,
pretty_print
=
True
)
xmlstr
=
etree
.
tostring
(
self
.
xml
,
pretty_print
=
True
)
header
=
{
'
return
_url'
:
self
.
system
.
xqueue_callback_url
,
header
=
{
'
lms_callback
_url'
:
self
.
system
.
xqueue_callback_url
,
'queue_name'
:
self
.
queue_name
,
'queue_name'
:
self
.
queue_name
,
}
}
...
@@ -914,7 +914,7 @@ class CodeResponse(LoncapaResponse):
...
@@ -914,7 +914,7 @@ class CodeResponse(LoncapaResponse):
h
.
update
(
str
(
self
.
system
.
seed
))
h
.
update
(
str
(
self
.
system
.
seed
))
h
.
update
(
str
(
time
.
time
()))
h
.
update
(
str
(
time
.
time
()))
queuekey
=
int
(
h
.
hexdigest
(),
16
)
queuekey
=
int
(
h
.
hexdigest
(),
16
)
header
.
update
({
'
queue
key'
:
queuekey
})
header
.
update
({
'
lms_
key'
:
queuekey
})
body
=
{
'xml'
:
xmlstr
,
body
=
{
'xml'
:
xmlstr
,
'edX_cmd'
:
'get_score'
,
'edX_cmd'
:
'get_score'
,
...
...
common/lib/capa/capa/templates/textbox.html
View file @
b9773b5d
...
@@ -35,15 +35,20 @@
...
@@ -35,15 +35,20 @@
lineNumbers
:
true
,
lineNumbers
:
true
,
%
endif
%
endif
mode
:
"${mode}"
,
mode
:
"${mode}"
,
tabsize
:
4
,
matchBrackets
:
true
,
lineWrapping
:
true
,
indentUnit
:
"${tabsize}"
,
tabSize
:
"${tabsize}"
,
smartIndent
:
false
});
});
});
});
</script>
</script>
<style
type=
"text/css"
>
<style
type=
"text/css"
>
.CodeMirror
{
.CodeMirror
{
border
:
2
px
solid
black
;
border
:
1
px
solid
black
;
font-size
:
14px
;
font-size
:
14px
;
line-height
:
18px
;
line-height
:
18px
;
resize
:
vertical
;
}
}
</style>
</style>
</section>
</section>
common/lib/xmodule/xmodule/x_module.py
View file @
b9773b5d
...
@@ -587,7 +587,7 @@ class ModuleSystem(object):
...
@@ -587,7 +587,7 @@ class ModuleSystem(object):
def
__init__
(
self
,
ajax_url
,
track_function
,
def
__init__
(
self
,
ajax_url
,
track_function
,
get_module
,
render_template
,
replace_urls
,
get_module
,
render_template
,
replace_urls
,
user
=
None
,
filestore
=
None
,
debug
=
False
,
user
=
None
,
filestore
=
None
,
debug
=
False
,
xqueue_callback_url
=
None
):
xqueue_callback_url
=
None
,
xqueue_default_queuename
=
"null"
):
'''
'''
Create a closure around the system environment.
Create a closure around the system environment.
...
@@ -616,6 +616,7 @@ class ModuleSystem(object):
...
@@ -616,6 +616,7 @@ class ModuleSystem(object):
'''
'''
self
.
ajax_url
=
ajax_url
self
.
ajax_url
=
ajax_url
self
.
xqueue_callback_url
=
xqueue_callback_url
self
.
xqueue_callback_url
=
xqueue_callback_url
self
.
xqueue_default_queuename
=
xqueue_default_queuename
self
.
track_function
=
track_function
self
.
track_function
=
track_function
self
.
filestore
=
filestore
self
.
filestore
=
filestore
self
.
get_module
=
get_module
self
.
get_module
=
get_module
...
...
lms/djangoapps/courseware/module_render.py
View file @
b9773b5d
...
@@ -140,8 +140,16 @@ def get_module(user, request, location, student_module_cache, position=None):
...
@@ -140,8 +140,16 @@ def get_module(user, request, location, student_module_cache, position=None):
# TODO (vshnayder): fix hardcoded urls (use reverse)
# TODO (vshnayder): fix hardcoded urls (use reverse)
# Setup system context for module instance
# Setup system context for module instance
ajax_url
=
settings
.
MITX_ROOT_URL
+
'/modx/'
+
descriptor
.
location
.
url
()
+
'/'
ajax_url
=
settings
.
MITX_ROOT_URL
+
'/modx/'
+
descriptor
.
location
.
url
()
+
'/'
xqueue_callback_url
=
(
settings
.
MITX_ROOT_URL
+
'/xqueue/'
+
str
(
user
.
id
)
+
'/'
+
descriptor
.
location
.
url
()
+
'/'
)
# Fully qualified callback URL for external queueing system
xqueue_callback_url
=
(
request
.
build_absolute_uri
(
'/'
)
+
settings
.
MITX_ROOT_URL
+
'xqueue/'
+
str
(
user
.
id
)
+
'/'
+
descriptor
.
location
.
url
()
+
'/'
+
'score_update'
)
# Default queuename is course-specific and is derived from the course that
# contains the current module.
# TODO: Queuename should be derived from 'course_settings.json' of each course
xqueue_default_queuename
=
descriptor
.
location
.
org
+
'-'
+
descriptor
.
location
.
course
def
_get_module
(
location
):
def
_get_module
(
location
):
(
module
,
_
,
_
,
_
)
=
get_module
(
user
,
request
,
location
,
(
module
,
_
,
_
,
_
)
=
get_module
(
user
,
request
,
location
,
...
@@ -155,6 +163,7 @@ def get_module(user, request, location, student_module_cache, position=None):
...
@@ -155,6 +163,7 @@ def get_module(user, request, location, student_module_cache, position=None):
render_template
=
render_to_string
,
render_template
=
render_to_string
,
ajax_url
=
ajax_url
,
ajax_url
=
ajax_url
,
xqueue_callback_url
=
xqueue_callback_url
,
xqueue_callback_url
=
xqueue_callback_url
,
xqueue_default_queuename
=
xqueue_default_queuename
.
replace
(
' '
,
'_'
),
# TODO (cpennington): Figure out how to share info between systems
# TODO (cpennington): Figure out how to share info between systems
filestore
=
descriptor
.
system
.
resources_fs
,
filestore
=
descriptor
.
system
.
resources_fs
,
get_module
=
_get_module
,
get_module
=
_get_module
,
...
@@ -203,13 +212,12 @@ def get_module(user, request, location, student_module_cache, position=None):
...
@@ -203,13 +212,12 @@ def get_module(user, request, location, student_module_cache, position=None):
return
(
module
,
instance_module
,
shared_module
,
descriptor
.
category
)
return
(
module
,
instance_module
,
shared_module
,
descriptor
.
category
)
# TODO: TEMPORARY BYPASS OF AUTH!
@csrf_exempt
@csrf_exempt
def
xqueue_callback
(
request
,
userid
,
id
,
dispatch
):
def
xqueue_callback
(
request
,
userid
,
id
,
dispatch
):
# Parse xqueue response
# Parse xqueue response
get
=
request
.
POST
.
copy
()
get
=
request
.
POST
.
copy
()
try
:
try
:
header
=
json
.
loads
(
get
.
pop
(
'xqueue_header'
)[
0
])
# 'dict'
header
=
json
.
loads
(
get
[
'xqueue_header'
])
except
Exception
as
err
:
except
Exception
as
err
:
msg
=
"Error in xqueue_callback
%
s: Invalid return format"
%
err
msg
=
"Error in xqueue_callback
%
s: Invalid return format"
%
err
raise
Exception
(
msg
)
raise
Exception
(
msg
)
...
@@ -230,7 +238,7 @@ def xqueue_callback(request, userid, id, dispatch):
...
@@ -230,7 +238,7 @@ def xqueue_callback(request, userid, id, dispatch):
# Transfer 'queuekey' from xqueue response header to 'get'. This is required to
# Transfer 'queuekey' from xqueue response header to 'get'. This is required to
# use the interface defined by 'handle_ajax'
# use the interface defined by 'handle_ajax'
get
.
update
({
'queuekey'
:
header
[
'
queue
key'
]})
get
.
update
({
'queuekey'
:
header
[
'
lms_
key'
]})
# We go through the "AJAX" path
# We go through the "AJAX" path
# So far, the only dispatch from xqueue will be 'score_update'
# So far, the only dispatch from xqueue will be 'score_update'
...
...
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