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
cd1eaf30
Commit
cd1eaf30
authored
Oct 23, 2017
by
Nimisha Asthagiri
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Dynamic Pacing: Waffle switch
parent
2211ae33
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
47 additions
and
8 deletions
+47
-8
cms/djangoapps/contentstore/views/item.py
+8
-1
cms/djangoapps/contentstore/views/tests/test_item.py
+9
-1
cms/envs/common.py
+0
-3
cms/envs/test.py
+0
-2
openedx/core/djangoapps/waffle_utils/__init__.py
+30
-1
No files found.
cms/djangoapps/contentstore/views/item.py
View file @
cd1eaf30
...
...
@@ -47,6 +47,7 @@ from contentstore.views.helpers import (
from
contentstore.views.preview
import
get_preview_fragment
from
edxmako.shortcuts
import
render_to_string
from
models.settings.course_grading
import
CourseGradingModel
from
openedx.core.djangoapps.waffle_utils
import
WaffleSwitch
from
openedx.core.lib.gating
import
api
as
gating_api
from
openedx.core.lib.xblock_utils
import
request_token
,
wrap_xblock
from
static_replace
import
replace_static_urls
...
...
@@ -1185,7 +1186,7 @@ def create_xblock_info(xblock, data=None, metadata=None, include_ancestor_info=F
elif
xblock
.
category
==
'chapter'
:
xblock_info
.
update
({
'highlights'
:
xblock
.
highlights
,
'highlights_enabled'
:
settings
.
FEATURES
.
get
(
'ENABLE_SECTION_HIGHLIGHTS'
,
False
),
'highlights_enabled'
:
highlights_setting
()
.
is_enabled
(
),
})
# update xblock_info with special exam information if the feature flag is enabled
...
...
@@ -1247,6 +1248,12 @@ def create_xblock_info(xblock, data=None, metadata=None, include_ancestor_info=F
return
xblock_info
def
highlights_setting
():
namespace
=
u'dynamic_pacing'
switch
=
u'studio_course_update'
return
WaffleSwitch
(
namespace
,
switch
)
def
add_container_page_publishing_info
(
xblock
,
xblock_info
):
# pylint: disable=invalid-name
"""
Adds information about the xblock's publish state to the supplied
...
...
cms/djangoapps/contentstore/views/tests/test_item.py
View file @
cd1eaf30
...
...
@@ -33,7 +33,8 @@ from contentstore.views.item import (
_get_source_index
,
_xblock_type_and_display_name
,
add_container_page_publishing_info
,
create_xblock_info
create_xblock_info
,
highlights_setting
,
)
from
lms_xblock.mixin
import
NONSENSICAL_ACCESS_RESTRICTION
from
openedx.core.djangoapps.self_paced.models
import
SelfPacedConfiguration
...
...
@@ -2571,6 +2572,12 @@ class TestXBlockInfo(ItemTest):
self
.
assertEqual
(
xblock_info
[
'start'
],
DEFAULT_START_DATE
.
strftime
(
'
%
Y-
%
m-
%
dT
%
H:
%
M:
%
SZ'
))
def
test_highlights_enabled
(
self
):
chapter
=
modulestore
()
.
get_item
(
self
.
chapter
.
location
)
with
highlights_setting
()
.
override
():
xblock_info
=
create_xblock_info
(
chapter
)
self
.
assertTrue
(
xblock_info
[
'highlights_enabled'
])
def
validate_course_xblock_info
(
self
,
xblock_info
,
has_child_info
=
True
,
course_outline
=
False
):
"""
Validate that the xblock info is correct for the test course.
...
...
@@ -2598,6 +2605,7 @@ class TestXBlockInfo(ItemTest):
self
.
assertEqual
(
xblock_info
[
'due'
],
None
)
self
.
assertEqual
(
xblock_info
[
'format'
],
None
)
self
.
assertEqual
(
xblock_info
[
'highlights'
],
self
.
chapter
.
highlights
)
self
.
assertFalse
(
xblock_info
[
'highlights_enabled'
])
# Finally, validate the entire response for consistency
self
.
validate_xblock_info_consistency
(
xblock_info
,
has_child_info
=
has_child_info
)
...
...
cms/envs/common.py
View file @
cd1eaf30
...
...
@@ -265,9 +265,6 @@ FEATURES = {
# Whether archived courses (courses with end dates in the past) should be
# shown in Studio in a separate list.
'ENABLE_SEPARATE_ARCHIVED_COURSES'
:
True
,
# Whether section-level highlights are enabled on the platform.
'ENABLE_SECTION_HIGHLIGHTS'
:
False
,
}
ENABLE_JASMINE
=
False
...
...
cms/envs/test.py
View file @
cd1eaf30
...
...
@@ -326,8 +326,6 @@ SEARCH_ENGINE = "search.tests.mock_search_engine.MockSearchEngine"
FEATURES
[
'ENABLE_ENROLLMENT_TRACK_USER_PARTITION'
]
=
True
FEATURES
[
'ENABLE_SECTION_HIGHLIGHTS'
]
=
True
########################## AUTHOR PERMISSION #######################
FEATURES
[
'ENABLE_CREATOR_GROUP'
]
=
False
...
...
openedx/core/djangoapps/waffle_utils/__init__.py
View file @
cd1eaf30
...
...
@@ -48,10 +48,14 @@ To test WaffleSwitchNamespace, use the provided context managers. For example:
import
logging
from
abc
import
ABCMeta
from
contextlib
import
contextmanager
import
six
from
opaque_keys.edx.keys
import
CourseKey
from
request_cache
import
get_cache
as
get_request_cache
,
get_request
from
waffle
import
flag_is_active
,
switch_is_active
from
request_cache
import
get_cache
as
get_request_cache
from
request_cache
import
get_request
log
=
logging
.
getLogger
(
__name__
)
...
...
@@ -165,6 +169,31 @@ class WaffleSwitchNamespace(WaffleNamespace):
return
self
.
_get_request_cache
()
.
setdefault
(
'switches'
,
{})
class
WaffleSwitch
(
object
):
"""
Represents a single waffle switch, using a cached namespace.
"""
def
__init__
(
self
,
waffle_namespace
,
switch_name
):
"""
Arguments:
waffle_namespace (WaffleSwitchNamespace | String): Namespace for this switch.
switch_name (String): The name of the switch (without namespacing).
"""
if
isinstance
(
waffle_namespace
,
six
.
string_types
):
waffle_namespace
=
WaffleSwitchNamespace
(
name
=
waffle_namespace
)
self
.
waffle_namespace
=
waffle_namespace
self
.
switch_name
=
switch_name
def
is_enabled
(
self
):
return
self
.
waffle_namespace
.
is_enabled
(
self
.
switch_name
)
@contextmanager
def
override
(
self
,
active
=
True
):
with
self
.
waffle_namespace
.
override
(
self
.
switch_name
,
active
):
yield
class
WaffleFlagNamespace
(
WaffleNamespace
):
"""
Provides a single namespace for a set of waffle flags.
...
...
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