Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
X
xblock-lti-consumer
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
xblock-lti-consumer
Commits
e99ce815
Commit
e99ce815
authored
Jan 06, 2017
by
Robert Raposa
Committed by
GitHub
Jan 06, 2017
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #22 from ubc/fix-old-lti-module-compat
Add a compatibility function for get_course_lti_endpoints
parents
2c53cb67
43ee768e
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
72 additions
and
0 deletions
+72
-0
lti_consumer/lti_consumer.py
+28
-0
lti_consumer/tests/unit/test_lti_consumer.py
+44
-0
No files found.
lti_consumer/lti_consumer.py
View file @
e99ce815
...
...
@@ -563,6 +563,20 @@ class LtiConsumerXBlock(StudioEditableXBlockMixin, XBlock):
return
self
.
runtime
.
handler_url
(
self
,
"outcome_service_handler"
,
thirdparty
=
True
)
.
rstrip
(
'/?'
)
@property
def
result_service_url
(
self
):
"""
Return URL for results.
To test LTI on sandbox we must use http scheme.
While testing locally and on Jenkins, mock_lti_server use http.referer
to obtain scheme, so it is ok to have http(s) anyway.
The scheme logic is handled in lms/lib/xblock/runtime.py
"""
return
self
.
runtime
.
handler_url
(
self
,
"result_service_handler"
,
thirdparty
=
True
)
.
rstrip
(
'/?'
)
@property
def
prefixed_custom_parameters
(
self
):
"""
Apply prefix to configured custom LTI parameters
...
...
@@ -860,3 +874,17 @@ class LtiConsumerXBlock(StudioEditableXBlockMixin, XBlock):
float: The css position offset to apply to the modal window
"""
return
(
100
-
viewport_percentage
)
/
2
def
get_outcome_service_url
(
self
,
service_name
=
"grade_handler"
):
"""
This function is called by get_course_lti_endpoints when using LTI result service to
discover the LTI result endpoints.
"""
# using string as mapped value instead of attributes to avoid unnecessary calls as both urls
# are @property.
mapping
=
{
'grade_handler'
:
'outcome_service_url'
,
'lti_2_0_result_rest_handler'
:
'result_service_url'
}
return
getattr
(
self
,
mapping
[
service_name
])
lti_consumer/tests/unit/test_lti_consumer.py
View file @
e99ce815
...
...
@@ -185,6 +185,17 @@ class TestProperties(TestLtiConsumerXBlock):
self
.
xblock
.
runtime
.
handler_url
.
assert_called_with
(
self
.
xblock
,
'outcome_service_handler'
,
thirdparty
=
True
)
self
.
assertEqual
(
url
,
handler_url
)
def
test_result_service_url
(
self
):
"""
Test `result_service_url` calls `runtime.handler_url` with thirdparty kwarg
"""
handler_url
=
'http://localhost:8005/result_service_handler'
self
.
xblock
.
runtime
.
handler_url
=
Mock
(
return_value
=
"{}/?"
.
format
(
handler_url
))
url
=
self
.
xblock
.
result_service_url
self
.
xblock
.
runtime
.
handler_url
.
assert_called_with
(
self
.
xblock
,
'result_service_handler'
,
thirdparty
=
True
)
self
.
assertEqual
(
url
,
handler_url
)
def
test_prefixed_custom_parameters
(
self
):
"""
Test `prefixed_custom_parameters` appropriately prefixes the configured custom params
...
...
@@ -528,6 +539,39 @@ class TestResultServiceHandler(TestLtiConsumerXBlock):
assert
mock_delete_result
.
called
self
.
assertEqual
(
response
.
status_code
,
200
)
def
test_get_outcome_service_url_with_default_parameter
(
self
):
"""
Test `get_outcome_service_url` with default parameter
"""
handler_url
=
'http://localhost:8005/outcome_service_handler'
self
.
xblock
.
runtime
.
handler_url
=
Mock
(
return_value
=
"{}/?"
.
format
(
handler_url
))
url
=
self
.
xblock
.
get_outcome_service_url
()
self
.
xblock
.
runtime
.
handler_url
.
assert_called_with
(
self
.
xblock
,
'outcome_service_handler'
,
thirdparty
=
True
)
self
.
assertEqual
(
url
,
handler_url
)
def
test_get_outcome_service_url_with_service_name_grade_handler
(
self
):
"""
Test `get_outcome_service_url` calls service name grade_handler
"""
handler_url
=
'http://localhost:8005/outcome_service_handler'
self
.
xblock
.
runtime
.
handler_url
=
Mock
(
return_value
=
"{}/?"
.
format
(
handler_url
))
url
=
self
.
xblock
.
get_outcome_service_url
(
'grade_handler'
)
self
.
xblock
.
runtime
.
handler_url
.
assert_called_with
(
self
.
xblock
,
'outcome_service_handler'
,
thirdparty
=
True
)
self
.
assertEqual
(
url
,
handler_url
)
def
test_get_outcome_service_url_with_service_name_lti_2_0_result_rest_handler
(
self
):
"""
Test `get_outcome_service_url` calls with service name lti_2_0_result_rest_handler
"""
handler_url
=
'http://localhost:8005/result_service_handler'
self
.
xblock
.
runtime
.
handler_url
=
Mock
(
return_value
=
"{}/?"
.
format
(
handler_url
))
url
=
self
.
xblock
.
get_outcome_service_url
(
'lti_2_0_result_rest_handler'
)
self
.
xblock
.
runtime
.
handler_url
.
assert_called_with
(
self
.
xblock
,
'result_service_handler'
,
thirdparty
=
True
)
self
.
assertEqual
(
url
,
handler_url
)
class
TestMaxScore
(
TestLtiConsumerXBlock
):
"""
...
...
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