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
21b02544
Commit
21b02544
authored
Jan 07, 2015
by
E. Kolpakov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added tests for `editor_saved` library content xblock method
Retriggering Jenkins
parent
2be036fe
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
96 additions
and
3 deletions
+96
-3
cms/djangoapps/contentstore/tests/test_libraries.py
+93
-0
common/lib/xmodule/xmodule/library_content_module.py
+3
-3
No files found.
cms/djangoapps/contentstore/tests/test_libraries.py
View file @
21b02544
...
...
@@ -326,6 +326,99 @@ class TestLibraries(LibraryTestCase):
html_block
=
modulestore
()
.
get_item
(
lc_block
.
children
[
0
])
self
.
assertEqual
(
html_block
.
data
,
data_value
)
def
test_refreshes_children_if_libraries_change
(
self
):
library2key
=
self
.
_create_library
(
"org2"
,
"lib2"
,
"Library2"
)
library2
=
modulestore
()
.
get_library
(
library2key
)
data1
,
data2
=
"Hello world!"
,
"Hello other world!"
ItemFactory
.
create
(
category
=
"html"
,
parent_location
=
self
.
library
.
location
,
user_id
=
self
.
user
.
id
,
publish_item
=
False
,
display_name
=
"Lib1: HTML BLock"
,
data
=
data1
,
)
ItemFactory
.
create
(
category
=
"html"
,
parent_location
=
library2
.
location
,
user_id
=
self
.
user
.
id
,
publish_item
=
False
,
display_name
=
"Lib 2: HTML BLock"
,
data
=
data2
,
)
# Create a course:
with
modulestore
()
.
default_store
(
ModuleStoreEnum
.
Type
.
split
):
course
=
CourseFactory
.
create
()
# Add a LibraryContent block to the course:
lc_block
=
self
.
_add_library_content_block
(
course
,
self
.
lib_key
)
lc_block
=
self
.
_refresh_children
(
lc_block
)
self
.
assertEqual
(
len
(
lc_block
.
children
),
1
)
# Now, change the block settings to have an invalid library key:
resp
=
self
.
_update_item
(
lc_block
.
location
,
{
"source_libraries"
:
[[
str
(
library2key
)]]},
)
self
.
assertEqual
(
resp
.
status_code
,
200
)
lc_block
=
modulestore
()
.
get_item
(
lc_block
.
location
)
self
.
assertEqual
(
len
(
lc_block
.
children
),
1
)
html_block
=
modulestore
()
.
get_item
(
lc_block
.
children
[
0
])
self
.
assertEqual
(
html_block
.
data
,
data2
)
def
test_refreshes_children_if_capa_type_change
(
self
):
name1
,
name2
=
"Option Problem"
,
"Multiple Choice Problem"
ItemFactory
.
create
(
category
=
"problem"
,
parent_location
=
self
.
library
.
location
,
user_id
=
self
.
user
.
id
,
publish_item
=
False
,
display_name
=
name1
,
data
=
"<problem><optionresponse></optionresponse></problem>"
,
)
ItemFactory
.
create
(
category
=
"problem"
,
parent_location
=
self
.
library
.
location
,
user_id
=
self
.
user
.
id
,
publish_item
=
False
,
display_name
=
name2
,
data
=
"<problem><multiplechoiceresponse></multiplechoiceresponse></problem>"
,
)
# Create a course:
with
modulestore
()
.
default_store
(
ModuleStoreEnum
.
Type
.
split
):
course
=
CourseFactory
.
create
()
# Add a LibraryContent block to the course:
lc_block
=
self
.
_add_library_content_block
(
course
,
self
.
lib_key
)
lc_block
=
self
.
_refresh_children
(
lc_block
)
self
.
assertEqual
(
len
(
lc_block
.
children
),
2
)
resp
=
self
.
_update_item
(
lc_block
.
location
,
{
"capa_type"
:
'optionresponse'
},
)
self
.
assertEqual
(
resp
.
status_code
,
200
)
lc_block
=
modulestore
()
.
get_item
(
lc_block
.
location
)
self
.
assertEqual
(
len
(
lc_block
.
children
),
1
)
html_block
=
modulestore
()
.
get_item
(
lc_block
.
children
[
0
])
self
.
assertEqual
(
html_block
.
display_name
,
name1
)
resp
=
self
.
_update_item
(
lc_block
.
location
,
{
"capa_type"
:
'multiplechoiceresponse'
},
)
self
.
assertEqual
(
resp
.
status_code
,
200
)
lc_block
=
modulestore
()
.
get_item
(
lc_block
.
location
)
self
.
assertEqual
(
len
(
lc_block
.
children
),
1
)
html_block
=
modulestore
()
.
get_item
(
lc_block
.
children
[
0
])
self
.
assertEqual
(
html_block
.
display_name
,
name2
)
@ddt.ddt
class
TestLibraryAccess
(
LibraryTestCase
):
...
...
common/lib/xmodule/xmodule/library_content_module.py
View file @
21b02544
...
...
@@ -360,8 +360,8 @@ class LibraryContentDescriptor(LibraryContentFields, MakoModuleDescriptor, XmlDe
# TODO: change this to action_runtime_event='...' once the unit page supports that feature.
# See https://openedx.atlassian.net/browse/TNL-993
action_class
=
'library-update-btn'
,
# Translators:
↻ is an UTF icon symbol, no need translating it.
action_label
=
_
(
u"{
0} Update now."
)
.
format
(
u"↻"
)
# Translators:
{refresh_icon} placeholder is substituted to "↻" (without double quotes)
action_label
=
_
(
u"{
refresh_icon} Update now."
)
.
format
(
refresh_icon
=
u"↻"
)
)
)
return
False
...
...
@@ -445,7 +445,7 @@ class LibraryContentDescriptor(LibraryContentFields, MakoModuleDescriptor, XmlDe
def
editor_saved
(
self
,
user
,
old_metadata
,
old_content
):
"""
If source_libraries has been edited, refresh_children automatically.
If source_libraries
or capa_type
has been edited, refresh_children automatically.
"""
old_source_libraries
=
LibraryList
()
.
from_json
(
old_metadata
.
get
(
'source_libraries'
,
[]))
if
(
set
(
old_source_libraries
)
!=
set
(
self
.
source_libraries
)
or
...
...
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