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
5e7d328e
Commit
5e7d328e
authored
Apr 01, 2013
by
Ned Batchelder
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use the Django cache for sandboxed code execution.
parent
c8b908a2
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
14 additions
and
5 deletions
+14
-5
common/lib/capa/capa/capa_problem.py
+7
-1
common/lib/capa/capa/responsetypes.py
+3
-3
common/lib/capa/capa/tests/__init__.py
+2
-1
lms/djangoapps/courseware/module_render.py
+2
-0
No files found.
common/lib/capa/capa/capa_problem.py
View file @
5e7d328e
...
@@ -462,7 +462,13 @@ class LoncapaProblem(object):
...
@@ -462,7 +462,13 @@ class LoncapaProblem(object):
if
all_code
:
if
all_code
:
try
:
try
:
safe_exec
.
safe_exec
(
all_code
,
context
,
random_seed
=
self
.
seed
,
python_path
=
python_path
)
safe_exec
.
safe_exec
(
all_code
,
context
,
random_seed
=
self
.
seed
,
python_path
=
python_path
,
cache
=
self
.
system
.
cache
,
)
except
Exception
as
err
:
except
Exception
as
err
:
log
.
exception
(
"Error while execing script code: "
+
all_code
)
log
.
exception
(
"Error while execing script code: "
+
all_code
)
msg
=
"Error while executing script code:
%
s"
%
str
(
err
)
.
replace
(
'<'
,
'<'
)
msg
=
"Error while executing script code:
%
s"
%
str
(
err
)
.
replace
(
'<'
,
'<'
)
...
...
common/lib/capa/capa/responsetypes.py
View file @
5e7d328e
...
@@ -938,7 +938,7 @@ class CustomResponse(LoncapaResponse):
...
@@ -938,7 +938,7 @@ class CustomResponse(LoncapaResponse):
'ans'
:
ans
,
'ans'
:
ans
,
}
}
globals_dict
.
update
(
kwargs
)
globals_dict
.
update
(
kwargs
)
safe_exec
.
safe_exec
(
code
,
globals_dict
)
safe_exec
.
safe_exec
(
code
,
globals_dict
,
cache
=
self
.
system
.
cache
)
return
globals_dict
[
'cfn_return'
]
return
globals_dict
[
'cfn_return'
]
return
check_function
return
check_function
...
@@ -1055,7 +1055,7 @@ class CustomResponse(LoncapaResponse):
...
@@ -1055,7 +1055,7 @@ class CustomResponse(LoncapaResponse):
# exec the check function
# exec the check function
if
isinstance
(
self
.
code
,
basestring
):
if
isinstance
(
self
.
code
,
basestring
):
try
:
try
:
safe_exec
.
safe_exec
(
self
.
code
,
self
.
context
)
safe_exec
.
safe_exec
(
self
.
code
,
self
.
context
,
cache
=
self
.
system
.
cache
)
except
Exception
as
err
:
except
Exception
as
err
:
self
.
_handle_exec_exception
(
err
)
self
.
_handle_exec_exception
(
err
)
...
@@ -1783,7 +1783,7 @@ class SchematicResponse(LoncapaResponse):
...
@@ -1783,7 +1783,7 @@ class SchematicResponse(LoncapaResponse):
json
.
loads
(
student_answers
[
k
])
for
k
in
sorted
(
self
.
answer_ids
)
json
.
loads
(
student_answers
[
k
])
for
k
in
sorted
(
self
.
answer_ids
)
]
]
self
.
context
.
update
({
'submission'
:
submission
})
self
.
context
.
update
({
'submission'
:
submission
})
safe_exec
.
safe_exec
(
self
.
code
,
self
.
context
)
safe_exec
.
safe_exec
(
self
.
code
,
self
.
context
,
cache
=
self
.
system
.
cache
)
cmap
=
CorrectMap
()
cmap
=
CorrectMap
()
cmap
.
set_dict
(
dict
(
zip
(
sorted
(
self
.
answer_ids
),
self
.
context
[
'correct'
])))
cmap
.
set_dict
(
dict
(
zip
(
sorted
(
self
.
answer_ids
),
self
.
context
[
'correct'
])))
return
cmap
return
cmap
...
...
common/lib/capa/capa/tests/__init__.py
View file @
5e7d328e
...
@@ -33,5 +33,6 @@ test_system = Mock(
...
@@ -33,5 +33,6 @@ test_system = Mock(
debug
=
True
,
debug
=
True
,
xqueue
=
{
'interface'
:
xqueue_interface
,
'construct_callback'
:
calledback_url
,
'default_queuename'
:
'testqueue'
,
'waittime'
:
10
},
xqueue
=
{
'interface'
:
xqueue_interface
,
'construct_callback'
:
calledback_url
,
'default_queuename'
:
'testqueue'
,
'waittime'
:
10
},
node_path
=
os
.
environ
.
get
(
"NODE_PATH"
,
"/usr/local/lib/node_modules"
),
node_path
=
os
.
environ
.
get
(
"NODE_PATH"
,
"/usr/local/lib/node_modules"
),
anonymous_student_id
=
'student'
anonymous_student_id
=
'student'
,
cache
=
None
,
)
)
lms/djangoapps/courseware/module_render.py
View file @
5e7d328e
...
@@ -8,6 +8,7 @@ from functools import partial
...
@@ -8,6 +8,7 @@ from functools import partial
from
django.conf
import
settings
from
django.conf
import
settings
from
django.contrib.auth.models
import
User
from
django.contrib.auth.models
import
User
from
django.core.cache
import
cache
from
django.core.exceptions
import
PermissionDenied
from
django.core.exceptions
import
PermissionDenied
from
django.core.urlresolvers
import
reverse
from
django.core.urlresolvers
import
reverse
from
django.http
import
Http404
from
django.http
import
Http404
...
@@ -299,6 +300,7 @@ def get_module_for_descriptor(user, request, descriptor, model_data_cache, cours
...
@@ -299,6 +300,7 @@ def get_module_for_descriptor(user, request, descriptor, model_data_cache, cours
course_id
=
course_id
,
course_id
=
course_id
,
open_ended_grading_interface
=
open_ended_grading_interface
,
open_ended_grading_interface
=
open_ended_grading_interface
,
s3_interface
=
s3_interface
,
s3_interface
=
s3_interface
,
cache
=
cache
,
)
)
# pass position specified in URL to module through ModuleSystem
# pass position specified in URL to module through ModuleSystem
system
.
set
(
'position'
,
position
)
system
.
set
(
'position'
,
position
)
...
...
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