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
35d6c773
Commit
35d6c773
authored
Aug 07, 2012
by
Arjun Singh
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Clean up code for generating env for running node
parent
f004f5fe
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
7 deletions
+8
-7
common/lib/capa/capa/responsetypes.py
+8
-7
No files found.
common/lib/capa/capa/responsetypes.py
View file @
35d6c773
...
...
@@ -367,12 +367,17 @@ class JavascriptResponse(LoncapaResponse):
self
.
display_class
=
self
.
display_xml
.
get
(
"class"
)
def
ge
nerate_problem_state
(
self
):
def
ge
t_node_env
(
self
):
js_dir
=
os
.
path
.
join
(
self
.
system
.
filestore
.
root_path
,
'js'
)
tmp_env
=
os
.
environ
.
copy
()
node_path
=
tmp_env
[
"NODE_PATH"
]
+
":"
+
os
.
path
.
normpath
(
js_dir
)
tmp_env
[
"NODE_PATH"
]
=
node_path
return
tmp_env
def
generate_problem_state
(
self
):
generator_file
=
os
.
path
.
dirname
(
os
.
path
.
normpath
(
__file__
))
+
'/javascript_problem_generator.js'
output
=
subprocess
.
check_output
([
"node"
,
generator_file
,
...
...
@@ -381,7 +386,7 @@ class JavascriptResponse(LoncapaResponse):
json
.
dumps
(
str
(
self
.
system
.
seed
)),
json
.
dumps
(
self
.
params
)
],
env
=
tmp_env
)
.
strip
()
env
=
self
.
get_node_env
()
)
.
strip
()
return
json
.
loads
(
output
)
...
...
@@ -426,10 +431,6 @@ class JavascriptResponse(LoncapaResponse):
if
submission
is
None
or
submission
==
''
:
submission
=
json
.
dumps
(
None
)
js_dir
=
os
.
path
.
join
(
self
.
system
.
filestore
.
root_path
,
'js'
)
tmp_env
=
os
.
environ
.
copy
()
node_path
=
tmp_env
[
"NODE_PATH"
]
+
":"
+
os
.
path
.
normpath
(
js_dir
)
tmp_env
[
"NODE_PATH"
]
=
node_path
grader_file
=
os
.
path
.
dirname
(
os
.
path
.
normpath
(
__file__
))
+
'/javascript_problem_grader.js'
outputs
=
subprocess
.
check_output
([
"node"
,
grader_file
,
...
...
@@ -439,7 +440,7 @@ class JavascriptResponse(LoncapaResponse):
json
.
dumps
(
self
.
problem_state
),
json
.
dumps
(
self
.
params
)
],
env
=
tmp_env
)
.
split
(
'
\n
'
)
env
=
self
.
get_node_env
()
)
.
split
(
'
\n
'
)
all_correct
=
json
.
loads
(
outputs
[
0
]
.
strip
())
evaluation
=
outputs
[
1
]
.
strip
()
...
...
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