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
748398fc
Commit
748398fc
authored
Jun 17, 2012
by
ichuang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
for externalresponse - fallback to script code if <answer> code not provided
parent
2d543f10
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
18 additions
and
8 deletions
+18
-8
common/lib/capa/capa_problem.py
+3
-1
common/lib/capa/responsetypes.py
+14
-6
lms/envs/dev_ike.py
+1
-1
No files found.
common/lib/capa/capa_problem.py
View file @
748398fc
...
...
@@ -286,6 +286,7 @@ class LoncapaProblem(object):
context
.
update
(
global_context
)
# initialize context to have stuff in global_context
context
[
'__builtins__'
]
=
globals
()[
'__builtins__'
]
# put globals there also
context
[
'the_lcp'
]
=
self
# pass instance of LoncapaProblem in
context
[
'script_code'
]
=
''
for
script
in
tree
.
findall
(
'.//script'
):
stype
=
script
.
get
(
'type'
)
...
...
@@ -298,8 +299,9 @@ class LoncapaProblem(object):
code
=
script
.
text
XMLESC
=
{
"'"
:
"'"
,
"""
:
'"'
}
code
=
unescape
(
code
,
XMLESC
)
context
[
'script_code'
]
+=
code
# store code source in context
try
:
exec
code
in
context
,
context
# use "context" for global context; thus defs in code are global within code
exec
code
in
context
,
context
# use "context" for global context; thus defs in code are global within code
except
Exception
:
log
.
exception
(
"Error while execing code: "
+
code
)
return
context
...
...
common/lib/capa/responsetypes.py
View file @
748398fc
...
...
@@ -746,12 +746,20 @@ main()
xml
=
self
.
xml
self
.
url
=
xml
.
get
(
'url'
)
or
"http://eecs1.mit.edu:8889/pyloncapa"
# FIXME - hardcoded URL
answer
=
xml
.
xpath
(
'//*[@id=$id]//answer'
,
id
=
xml
.
get
(
'id'
))[
0
]
# FIXME - catch errors
answer_src
=
answer
.
get
(
'src'
)
if
answer_src
is
not
None
:
self
.
code
=
self
.
system
.
filesystem
.
open
(
'src/'
+
answer_src
)
.
read
()
else
:
self
.
code
=
answer
.
text
# answer = xml.xpath('//*[@id=$id]//answer',id=xml.get('id'))[0] # FIXME - catch errors
answer
=
xml
.
find
(
'answer'
)
if
answer
is
not
None
:
answer_src
=
answer
.
get
(
'src'
)
if
answer_src
is
not
None
:
self
.
code
=
self
.
system
.
filesystem
.
open
(
'src/'
+
answer_src
)
.
read
()
else
:
self
.
code
=
answer
.
text
else
:
# no <answer> stanza; get code from <script>
self
.
code
=
self
.
context
[
'script_code'
]
if
not
self
.
code
:
msg
=
'
%
s: Missing answer script code for externalresponse'
%
unicode
(
self
)
msg
+=
"
\n
See XML source line
%
s"
%
getattr
(
self
.
xml
,
'sourceline'
,
'<unavailable>'
)
raise
LoncapaProblemError
(
msg
)
self
.
tests
=
xml
.
get
(
'tests'
)
...
...
lms/envs/dev_ike.py
View file @
748398fc
...
...
@@ -47,7 +47,7 @@ COURSE_SETTINGS = {'6.002_Spring_2012': {'number' : '6.002x',
},
'6.189_Spring_2013'
:
{
'number'
:
'6.189x'
,
'title'
:
'IAP Python Programming'
,
'xmlpath'
:
'/6
189-pytutor
/'
,
'xmlpath'
:
'/6
.189x
/'
,
'active'
:
True
,
},
'8.01_Summer_2012'
:
{
'number'
:
'8.01x'
,
...
...
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