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
0173eaf9
Commit
0173eaf9
authored
May 15, 2014
by
Dave St.Germain
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Updated payload for new matlab endpoint.
parent
964e73f0
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
33 additions
and
24 deletions
+33
-24
cms/djangoapps/contentstore/features/problem-editor.py
+3
-1
common/lib/capa/capa/inputtypes.py
+5
-15
common/lib/capa/capa/responsetypes.py
+8
-5
common/lib/capa/capa/tests/test_inputtypes.py
+2
-1
common/lib/xmodule/xmodule/capa_base.py
+9
-1
common/lib/xmodule/xmodule/modulestore/inheritance.py
+6
-1
No files found.
cms/djangoapps/contentstore/features/problem-editor.py
View file @
0173eaf9
...
...
@@ -14,6 +14,7 @@ PROBLEM_WEIGHT = "Problem Weight"
RANDOMIZATION
=
'Randomization'
SHOW_ANSWER
=
"Show Answer"
TIMER_BETWEEN_ATTEMPTS
=
"Timer Between Attempts"
MATLAB_API_KEY
=
"Matlab API key"
@step
(
'I have created a Blank Common Problem$'
)
def
i_created_blank_common_problem
(
step
):
...
...
@@ -40,11 +41,12 @@ def i_see_advanced_settings_with_values(step):
world
.
verify_all_setting_entries
(
[
[
DISPLAY_NAME
,
"Blank Common Problem"
,
True
],
[
MATLAB_API_KEY
,
""
,
False
],
[
MAXIMUM_ATTEMPTS
,
""
,
False
],
[
PROBLEM_WEIGHT
,
""
,
False
],
[
RANDOMIZATION
,
"Never"
,
False
],
[
SHOW_ANSWER
,
"Finished"
,
False
],
[
TIMER_BETWEEN_ATTEMPTS
,
"0"
,
False
]
[
TIMER_BETWEEN_ATTEMPTS
,
"0"
,
False
]
,
])
...
...
common/lib/capa/capa/inputtypes.py
View file @
0173eaf9
...
...
@@ -804,20 +804,7 @@ class MatlabInput(CodeInput):
xml
=
self
.
xml
# the new way to define the api key is to set it in the course advanced settings
api_key
=
getattr
(
self
.
capa_system
,
'matlab_api_key'
,
None
)
if
api_key
:
plot_payload
=
'
%
api_key={}'
.
format
(
api_key
)
else
:
plot_payload
=
''
# the old way to define api_key is to add it to the plot_payload xml.
# are there other things that go in the payload?
xml_payload
=
xml
.
findtext
(
'./plot_payload'
)
if
xml_payload
:
plot_payload
+=
'
\n
{}'
.
format
(
xml_payload
)
self
.
plot_payload
=
plot_payload
self
.
plot_payload
=
xml
.
findtext
(
'./plot_payload'
)
# Check if problem has been queued
self
.
queuename
=
'matlab'
self
.
queue_msg
=
''
...
...
@@ -966,7 +953,10 @@ class MatlabInput(CodeInput):
contents
=
{
'grader_payload'
:
self
.
plot_payload
,
'student_info'
:
json
.
dumps
(
student_info
),
'student_response'
:
response
'student_response'
:
response
,
'token'
:
getattr
(
self
.
capa_system
,
'matlab_api_key'
,
None
),
'endpoint_version'
:
"2"
,
'requestor_id'
:
anonymous_student_id
,
}
(
error
,
msg
)
=
qinterface
.
send_to_queue
(
header
=
xheader
,
...
...
common/lib/capa/capa/responsetypes.py
View file @
0173eaf9
...
...
@@ -1878,13 +1878,16 @@ class CodeResponse(LoncapaResponse):
"""
grader_payload
=
codeparam
.
find
(
'grader_payload'
)
grader_payload
=
grader_payload
.
text
if
grader_payload
is
not
None
else
''
self
.
payload
=
{
'grader_payload'
:
grader_payload
,
}
# matlab api key can be defined in course settings. if so, add it to the grader payload
# only if the problem didn't have an api key already defined.
api_key
=
getattr
(
self
.
capa_system
,
'matlab_api_key'
,
None
)
if
self
.
xml
.
find
(
'matlabinput'
)
and
api_key
and
'api_key'
not
in
grader_payload
:
grader_payload
+=
'
\n
%
api_key={}'
.
format
(
api_key
)
self
.
payload
=
{
'grader_payload'
:
grader_payload
}
if
self
.
xml
.
find
(
'matlabinput'
)
and
api_key
:
self
.
payload
[
'token'
]
=
api_key
self
.
payload
[
'endpoint_version'
]
=
"2"
self
.
payload
[
'requestor_id'
]
=
self
.
capa_system
.
anonymous_student_id
self
.
initial_display
=
find_with_default
(
codeparam
,
'initial_display'
,
''
)
...
...
common/lib/capa/capa/tests/test_inputtypes.py
View file @
0173eaf9
...
...
@@ -642,7 +642,8 @@ class MatlabTest(unittest.TestCase):
body
=
system
.
xqueue
[
'interface'
]
.
send_to_queue
.
call_args
[
1
][
'body'
]
payload
=
json
.
loads
(
body
)
self
.
assertIn
(
'
%
api_key=test_api_key'
,
payload
[
'grader_payload'
])
self
.
assertEqual
(
'test_api_key'
,
payload
[
'token'
])
self
.
assertEqual
(
'2'
,
payload
[
'endpoint_version'
])
def
test_get_html
(
self
):
# usual output
...
...
common/lib/xmodule/xmodule/capa_base.py
View file @
0173eaf9
...
...
@@ -189,7 +189,15 @@ class CapaFields(object):
default
=
False
,
scope
=
Scope
.
settings
)
matlab_api_key
=
String
(
help
=
"API key for Matlab problems"
,
scope
=
Scope
.
settings
)
matlab_api_key
=
String
(
display_name
=
"Matlab API key"
,
help
=
"Enter the API key provided by MathWorks for accessing the MATLAB Hosted Service. "
"This key is granted for exclusive use by this course for the specified duration. "
"Please do not share the API key with other courses and notify MathWorks immediately "
"if you believe the key is exposed or compromised. To obtain a key for your course, "
"or to report and issue, please contact moocsupport@mathworks.com"
,
scope
=
Scope
.
settings
)
class
CapaMixin
(
CapaFields
):
...
...
common/lib/xmodule/xmodule/modulestore/inheritance.py
View file @
0173eaf9
...
...
@@ -87,7 +87,12 @@ class InheritanceMixin(XBlockMixin):
values
=
{
"min"
:
0
},
scope
=
Scope
.
settings
)
matlab_api_key
=
String
(
help
=
"API key for Matlab problems"
,
display_name
=
"Matlab API key"
,
help
=
"Enter the API key provided by MathWorks for accessing the MATLAB Hosted Service. "
"This key is granted for exclusive use by this course for the specified duration. "
"Please do not share the API key with other courses and notify MathWorks immediately "
"if you believe the key is exposed or compromised. To obtain a key for your course, "
"or to report and issue, please contact moocsupport@mathworks.com"
,
scope
=
Scope
.
settings
)
...
...
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