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
e092aadb
Commit
e092aadb
authored
Jun 04, 2013
by
Joe Blaylock
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #48 from edx/jrbl/substitute-anonymous-user-id-in-html
Expose site-wide anonymized ids to HTML module
parents
946c36e4
62622748
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
42 additions
and
0 deletions
+42
-0
common/lib/xmodule/xmodule/html_module.py
+2
-0
common/lib/xmodule/xmodule/tests/test_html_module.py
+40
-0
No files found.
common/lib/xmodule/xmodule/html_module.py
View file @
e092aadb
...
...
@@ -32,6 +32,8 @@ class HtmlModule(HtmlFields, XModule):
css
=
{
'scss'
:
[
resource_string
(
__name__
,
'css/html/display.scss'
)]}
def
get_html
(
self
):
if
self
.
system
.
anonymous_student_id
:
return
self
.
data
.
replace
(
"
%%
USER_ID
%%
"
,
self
.
system
.
anonymous_student_id
)
return
self
.
data
...
...
common/lib/xmodule/xmodule/tests/test_html_module.py
0 → 100644
View file @
e092aadb
import
unittest
from
mock
import
Mock
from
xmodule.html_module
import
HtmlModule
from
xmodule.modulestore
import
Location
from
.
import
test_system
class
HtmlModuleSubstitutionTestCase
(
unittest
.
TestCase
):
location
=
Location
([
"i4x"
,
"edX"
,
"toy"
,
"html"
,
"simple_html"
])
descriptor
=
Mock
()
def
test_substitution_works
(
self
):
sample_xml
=
'''
%%
USER_ID
%%
'''
module_data
=
{
'data'
:
sample_xml
}
module_system
=
test_system
()
module
=
HtmlModule
(
module_system
,
self
.
location
,
self
.
descriptor
,
module_data
)
self
.
assertEqual
(
module
.
get_html
(),
str
(
module_system
.
anonymous_student_id
))
def
test_substitution_without_magic_string
(
self
):
sample_xml
=
'''
<html>
<p>Hi USER_ID!11!</p>
</html>
'''
module_data
=
{
'data'
:
sample_xml
}
module
=
HtmlModule
(
test_system
(),
self
.
location
,
self
.
descriptor
,
module_data
)
self
.
assertEqual
(
module
.
get_html
(),
sample_xml
)
def
test_substitution_without_anonymous_student_id
(
self
):
sample_xml
=
'''
%%
USER_ID
%%
'''
module_data
=
{
'data'
:
sample_xml
}
module_system
=
test_system
()
module_system
.
anonymous_student_id
=
None
module
=
HtmlModule
(
module_system
,
self
.
location
,
self
.
descriptor
,
module_data
)
self
.
assertEqual
(
module
.
get_html
(),
sample_xml
)
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