Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
S
schoolyourself-xblock
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
OpenEdx
schoolyourself-xblock
Commits
e79740de
Commit
e79740de
authored
Nov 17, 2014
by
John Lee
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Sign the requests going from the XBlock to the SY server
parent
5a0380b5
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
17 additions
and
7 deletions
+17
-7
schoolyourself/schoolyourself.py
+11
-4
schoolyourself/schoolyourself_lesson.py
+2
-1
schoolyourself/schoolyourself_review.py
+4
-2
No files found.
schoolyourself/schoolyourself.py
View file @
e79740de
"""The base class for School Yourself XBlocks (lessons and reviews)."""
import
hmac
import
os
import
pkg_resources
...
...
@@ -103,16 +104,22 @@ class SchoolYourselfXBlock(XBlock):
return
template
.
render_unicode
(
**
context
)
def
get_partner_url_params
(
self
):
def
get_partner_url_params
(
self
,
shared_key
=
None
):
"""A helper method that generates a dict of URL params that we can
append to the end of a URL, containing the partner ID and the
user's anonymouse user ID. These are typically transmitted as URL
params. in the iframes."""
url_params
=
{
"id"
:
self
.
module_id
,
"partner"
:
"edx"
}
params. in the iframes.
If a shared_key is provided and there is a username to encode,
we will sign it with the shared key.
"""
url_params
=
{
"partner"
:
"edx"
}
user_id
=
self
.
get_student_id
()
if
user_id
:
url_params
[
"partner_user_id"
]
=
user_id
if
shared_key
:
url_params
[
"partner_signature"
]
=
hmac
.
new
(
str
(
shared_key
),
user_id
)
.
hexdigest
()
return
url_params
...
...
schoolyourself/schoolyourself_lesson.py
View file @
e79740de
...
...
@@ -24,7 +24,8 @@ class SchoolYourselfLessonXBlock(SchoolYourselfXBlock):
"""
# Construct the URL we're going to stuff into the iframe once
# it gets launched:
url_params
=
self
.
get_partner_url_params
()
url_params
=
self
.
get_partner_url_params
(
self
.
shared_key
)
url_params
[
"id"
]
=
self
.
module_id
# Set up the screenshot URL:
screenshot_url
=
"
%
s/page/screenshot/
%
s"
%
(
self
.
base_url
,
...
...
schoolyourself/schoolyourself_review.py
View file @
e79740de
...
...
@@ -28,7 +28,8 @@ class SchoolYourselfReviewXBlock(SchoolYourselfXBlock):
"""
# Construct the URL we're going to stuff into the iframe once
# it gets launched:
url_params
=
self
.
get_partner_url_params
()
url_params
=
self
.
get_partner_url_params
(
self
.
shared_key
)
url_params
[
"module"
]
=
self
.
module_id
# Set up the screenshot URL:
screenshot_url
=
"
%
s/page/screenshot/
%
s"
%
(
self
.
base_url
,
...
...
@@ -73,7 +74,8 @@ class SchoolYourselfReviewXBlock(SchoolYourselfXBlock):
"""
\
<vertical_demo>
<schoolyourself_review
module_id="geometry/lines_rays"
module_id="algebra/multiplication"
shared_key="test"
/>
</vertical_demo>
"""
),
...
...
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