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
a6677aa0
Commit
a6677aa0
authored
Feb 14, 2013
by
Ned Batchelder
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Computed answers are run through safe_exec.
parent
37ca6bf7
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
20 additions
and
2 deletions
+20
-2
common/lib/capa/capa/responsetypes.py
+1
-2
common/test/data/embedded_python/course/2013_Spring.xml
+14
-0
lms/djangoapps/courseware/tests/tests.py
+5
-0
No files found.
common/lib/capa/capa/responsetypes.py
View file @
a6677aa0
...
...
@@ -1087,8 +1087,7 @@ def sympy_check2():
# exec the check function
if
isinstance
(
self
.
code
,
basestring
):
try
:
raise
Exception
(
"exec 1"
)
exec
self
.
code
in
self
.
context
[
'global_context'
],
self
.
context
safe_exec
.
safe_exec
(
self
.
code
,
self
.
context
)
correct
=
self
.
context
[
'correct'
]
messages
=
self
.
context
[
'messages'
]
overall_message
=
self
.
context
[
'overall_message'
]
...
...
common/test/data/embedded_python/course/2013_Spring.xml
View file @
a6677aa0
...
...
@@ -92,6 +92,20 @@ print(num)
</text>
</problem>
<problem
url_name=
"computed_answer"
>
<customresponse>
<textline
size=
"5"
correct_answer=
"Xyzzy"
/>
<answer
type=
"loncapa/python"
>
if submission[0] == "Xyzzy":
correct = ['correct']
else:
correct = ['incorrect']
</answer>
</customresponse>
</problem>
</vertical>
</chapter>
</course>
lms/djangoapps/courseware/tests/tests.py
View file @
a6677aa0
...
...
@@ -1023,3 +1023,8 @@ class TestSchematicResponse(TestSubmittingProblems):
resp
=
self
.
submit_question_answer
(
'cfn_problem'
,
{
'2_1'
:
"xyzzy!"
})
respdata
=
json
.
loads
(
resp
.
content
)
self
.
assertEqual
(
respdata
[
'success'
],
'incorrect'
)
def
test_computed_answer
(
self
):
resp
=
self
.
submit_question_answer
(
'computed_answer'
,
{
'2_1'
:
"Xyzzy"
})
respdata
=
json
.
loads
(
resp
.
content
)
self
.
assertEqual
(
respdata
[
'success'
],
'correct'
)
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