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
05817614
Commit
05817614
authored
Dec 02, 2014
by
Jonathan Piacenti
Committed by
E. Kolpakov
Jan 12, 2015
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Removed the ability to add Discussion and advanced components to Content Libraries.
parent
3e0f08eb
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
78 additions
and
7 deletions
+78
-7
cms/djangoapps/contentstore/views/component.py
+15
-5
cms/djangoapps/contentstore/views/item.py
+7
-0
cms/djangoapps/contentstore/views/library.py
+1
-1
cms/djangoapps/contentstore/views/tests/test_item.py
+35
-0
cms/djangoapps/contentstore/views/tests/test_library.py
+14
-0
common/test/acceptance/tests/studio/test_studio_library.py
+6
-1
No files found.
cms/djangoapps/contentstore/views/component.py
View file @
05817614
...
...
@@ -217,9 +217,9 @@ def container_handler(request, usage_key_string):
return
HttpResponseBadRequest
(
"Only supports HTML requests"
)
def
get_component_templates
(
course
):
def
get_component_templates
(
course
like
,
library
=
False
):
"""
Returns the applicable component templates that can be used by the specified course.
Returns the applicable component templates that can be used by the specified course
or library
.
"""
def
create_template_dict
(
name
,
cat
,
boilerplate_name
=
None
,
is_common
=
False
):
"""
...
...
@@ -250,7 +250,13 @@ def get_component_templates(course):
categories
=
set
()
# The component_templates array is in the order of "advanced" (if present), followed
# by the components in the order listed in COMPONENT_TYPES.
for
category
in
COMPONENT_TYPES
:
component_types
=
COMPONENT_TYPES
[:]
# Libraries do not support discussions
if
library
:
component_types
=
[
component
for
component
in
component_types
if
component
!=
'discussion'
]
for
category
in
component_types
:
templates_for_category
=
[]
component_class
=
_load_mixed_class
(
category
)
# add the default template with localized display name
...
...
@@ -264,7 +270,7 @@ def get_component_templates(course):
if
hasattr
(
component_class
,
'templates'
):
for
template
in
component_class
.
templates
():
filter_templates
=
getattr
(
component_class
,
'filter_templates'
,
None
)
if
not
filter_templates
or
filter_templates
(
template
,
course
):
if
not
filter_templates
or
filter_templates
(
template
,
course
like
):
templates_for_category
.
append
(
create_template_dict
(
_
(
template
[
'metadata'
]
.
get
(
'display_name'
)),
...
...
@@ -289,11 +295,15 @@ def get_component_templates(course):
"display_name"
:
component_display_names
[
category
]
})
# Libraries do not support advanced components at this time.
if
library
:
return
component_templates
# Check if there are any advanced modules specified in the course policy.
# These modules should be specified as a list of strings, where the strings
# are the names of the modules in ADVANCED_COMPONENT_TYPES that should be
# enabled for the course.
course_advanced_keys
=
course
.
advanced_modules
course_advanced_keys
=
course
like
.
advanced_modules
advanced_component_templates
=
{
"type"
:
"advanced"
,
"templates"
:
[],
"display_name"
:
_
(
"Advanced"
)}
advanced_component_types
=
_advanced_component_types
()
# Set component types according to course policy file
...
...
cms/djangoapps/contentstore/views/item.py
View file @
05817614
...
...
@@ -460,6 +460,13 @@ def _create_item(request):
if
not
has_course_author_access
(
request
.
user
,
usage_key
.
course_key
):
raise
PermissionDenied
()
if
isinstance
(
usage_key
,
LibraryUsageLocator
):
# Only these categories are supported at this time.
if
category
not
in
[
'html'
,
'problem'
,
'video'
]:
return
HttpResponseBadRequest
(
"Category '
%
s' not supported for Libraries"
%
category
,
content_type
=
'text/plain'
)
store
=
modulestore
()
with
store
.
bulk_operations
(
usage_key
.
course_key
):
parent
=
store
.
get_item
(
usage_key
)
...
...
cms/djangoapps/contentstore/views/library.py
View file @
05817614
...
...
@@ -175,7 +175,7 @@ def library_blocks_view(library, response_format):
})
xblock_info
=
create_xblock_info
(
library
,
include_ancestor_info
=
False
,
graders
=
[])
component_templates
=
get_component_templates
(
library
)
component_templates
=
get_component_templates
(
library
,
library
=
True
)
return
render_to_response
(
'library.html'
,
{
'context_library'
:
library
,
...
...
cms/djangoapps/contentstore/views/tests/test_item.py
View file @
05817614
...
...
@@ -1469,6 +1469,41 @@ class TestLibraryXBlockInfo(ModuleStoreTestCase):
self
.
assertIsNone
(
xblock_info
.
get
(
'graders'
,
None
))
class
TestLibraryXBlockCreation
(
ItemTest
):
"""
Tests the adding of XBlocks to Library
"""
def
test_add_xblock
(
self
):
"""
Verify we can add an XBlock to a Library.
"""
lib
=
LibraryFactory
.
create
()
self
.
create_xblock
(
parent_usage_key
=
lib
.
location
,
display_name
=
'Test'
,
category
=
"html"
)
lib
=
self
.
store
.
get_library
(
lib
.
location
.
library_key
)
self
.
assertTrue
(
lib
.
children
)
xblock_locator
=
lib
.
children
[
0
]
self
.
assertEqual
(
self
.
store
.
get_item
(
xblock_locator
)
.
display_name
,
'Test'
)
def
test_no_add_discussion
(
self
):
"""
Verify we cannot add a discussion module to a Library.
"""
lib
=
LibraryFactory
.
create
()
response
=
self
.
create_xblock
(
parent_usage_key
=
lib
.
location
,
display_name
=
'Test'
,
category
=
'discussion'
)
self
.
assertEqual
(
response
.
status_code
,
400
)
lib
=
self
.
store
.
get_library
(
lib
.
location
.
library_key
)
self
.
assertFalse
(
lib
.
children
)
def
test_no_add_advanced
(
self
):
lib
=
LibraryFactory
.
create
()
lib
.
advanced_modules
=
[
'lti'
]
lib
.
save
()
response
=
self
.
create_xblock
(
parent_usage_key
=
lib
.
location
,
display_name
=
'Test'
,
category
=
'lti'
)
self
.
assertEqual
(
response
.
status_code
,
400
)
lib
=
self
.
store
.
get_library
(
lib
.
location
.
library_key
)
self
.
assertFalse
(
lib
.
children
)
class
TestXBlockPublishingInfo
(
ItemTest
):
"""
Unit tests for XBlock's outline handling.
...
...
cms/djangoapps/contentstore/views/tests/test_library.py
View file @
05817614
...
...
@@ -4,6 +4,7 @@ Unit tests for contentstore.views.library
More important high-level tests are in contentstore/tests/test_libraries.py
"""
from
contentstore.tests.utils
import
AjaxEnabledTestClient
,
parse_json
from
contentstore.views.component
import
get_component_templates
from
xmodule.modulestore.tests.django_utils
import
ModuleStoreTestCase
from
xmodule.modulestore.tests.factories
import
LibraryFactory
from
mock
import
patch
...
...
@@ -183,3 +184,16 @@ class UnitTestLibraries(ModuleStoreTestCase):
lib
=
LibraryFactory
.
create
()
response
=
self
.
client
.
get
(
make_url_for_lib
(
lib
.
location
.
library_key
))
self
.
assertEqual
(
response
.
status_code
,
403
)
def
test_get_component_templates
(
self
):
"""
Verify that templates for adding discussion and advanced components to
content libraries are not provided.
"""
lib
=
LibraryFactory
.
create
()
lib
.
advanced_modules
=
[
'lti'
]
lib
.
save
()
templates
=
[
template
[
'type'
]
for
template
in
get_component_templates
(
lib
,
library
=
True
)]
self
.
assertIn
(
'problem'
,
templates
)
self
.
assertNotIn
(
'discussion'
,
templates
)
self
.
assertNotIn
(
'advanced'
,
templates
)
common/test/acceptance/tests/studio/test_studio_library.py
View file @
05817614
"""
Acceptance tests for Content Libraries in Studio
"""
from
.base_studio_test
import
StudioLibraryTest
from
...pages.studio.utils
import
add_component
from
...pages.studio.library
import
LibraryPage
...
...
@@ -102,3 +101,9 @@ class LibraryEditPageTest(StudioLibraryTest):
self
.
assertEqual
(
len
(
self
.
lib_page
.
xblocks
),
1
)
problem_block
=
self
.
lib_page
.
xblocks
[
0
]
self
.
assertIn
(
"Laura Roslin"
,
problem_block
.
student_content
)
def
test_no_discussion_button
(
self
):
"""
Ensure the UI is not loaded for adding discussions.
"""
self
.
assertFalse
(
self
.
browser
.
find_elements_by_css_selector
(
'span.large-discussion-icon'
))
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