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
0d2d10d7
Commit
0d2d10d7
authored
Sep 02, 2013
by
Alexander Kryklia
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
custom parameters
parent
3e3d89e3
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
32 additions
and
8 deletions
+32
-8
common/lib/xmodule/xmodule/lti_module.py
+27
-7
lms/templates/lti.html
+5
-1
No files found.
common/lib/xmodule/xmodule/lti_module.py
View file @
0d2d10d7
...
...
@@ -11,7 +11,7 @@ import urllib
from
xmodule.editing_module
import
MetadataOnlyEditingDescriptor
from
xmodule.x_module
import
XModule
from
pkg_resources
import
resource_string
from
xblock.core
import
String
,
Scope
from
xblock.core
import
String
,
Scope
,
List
log
=
logging
.
getLogger
(
__name__
)
...
...
@@ -29,7 +29,8 @@ class LTIFields(object):
"""
client_key
=
String
(
help
=
"Client key"
,
default
=
''
,
scope
=
Scope
.
settings
)
client_secret
=
String
(
help
=
"Client secret"
,
default
=
''
,
scope
=
Scope
.
settings
)
lti_url
=
String
(
help
=
"URL of the tool"
,
default
=
''
,
scope
=
Scope
.
settings
)
launch_url
=
String
(
help
=
"URL of the tool"
,
default
=
''
,
scope
=
Scope
.
settings
)
custom_parameters
=
List
(
help
=
"Custom parameters"
,
scope
=
Scope
.
settings
)
class
LTIModule
(
LTIFields
,
XModule
):
...
...
@@ -44,14 +45,29 @@ class LTIModule(LTIFields, XModule):
# these params do not participate in oauth signing
params
=
{
'l
ti_url'
:
self
.
lti
_url
,
'l
aunch_url'
:
self
.
launch
_url
,
'element_id'
:
self
.
location
.
html_id
(),
'element_class'
:
self
.
location
.
category
,
}
params
.
update
(
self
.
oauth_params
())
parsed_custom_parameters
=
{}
for
custom_parameter
in
self
.
custom_parameters
:
try
:
param_name
,
param_value
=
custom_parameter
.
split
(
'='
)
except
ValueError
:
raise
Exception
(
'Could not parse custom parameter: {0}.
\
Should be "x=y" string.'
.
format
(
custom_parameter
))
# LTI specs: 'custom_' should be prepended before each custom parameter
parsed_custom_parameters
.
update
(
{
u'custom_'
+
unicode
(
param_name
):
unicode
(
param_value
)}
)
params
.
update
({
'custom_parameters'
:
parsed_custom_parameters
})
params
.
update
(
self
.
oauth_params
(
parsed_custom_parameters
))
return
self
.
system
.
render_template
(
'lti.html'
,
params
)
def
oauth_params
(
self
):
def
oauth_params
(
self
,
custom_parameters
):
"""Obtains LTI html from provider"""
client
=
requests
.
auth
.
Client
(
client_key
=
unicode
(
self
.
client_key
),
...
...
@@ -73,11 +89,15 @@ class LTIModule(LTIFields, XModule):
'lti_version'
:
'LTI-1p0'
,
'role'
:
'student'
}
# appending custom parameter for signing
body
.
update
(
custom_parameters
)
# This is needed for body encoding:
headers
=
{
'Content-Type'
:
'application/x-www-form-urlencoded'
}
_
,
headers
,
_
=
client
.
sign
(
unicode
(
self
.
l
ti
_url
),
unicode
(
self
.
l
aunch
_url
),
http_method
=
u'POST'
,
body
=
body
,
headers
=
headers
)
...
...
@@ -101,5 +121,5 @@ class LTIModule(LTIFields, XModule):
class
LTIModuleDescriptor
(
LTIFields
,
MetadataOnlyEditingDescriptor
):
"""LTI Descriptor. No export/import to
ht
ml."""
"""LTI Descriptor. No export/import to
x
ml."""
module_class
=
LTIModule
lms/templates/lti.html
View file @
0d2d10d7
...
...
@@ -4,7 +4,7 @@
## module JavaScript will trigget a "submit" on the form, and the
## result will be rendered to the below iFrame.
<form
action=
"${l
ti
_url}"
action=
"${l
aunch
_url}"
name=
"ltiLaunchForm"
class=
"ltiLaunchForm"
method=
"post"
...
...
@@ -26,6 +26,10 @@
<input
name=
"role"
value=
"student"
/>
<input
name=
"oauth_signature"
value=
"${oauth_signature}"
/>
% for param_name, param_value in custom_parameters.items():
<input
name=
"${param_name}"
value=
"${param_value}"
/>
%endfor
<input
type=
"submit"
value=
"Press to Launch"
/>
</form>
...
...
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