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
b94204a8
Commit
b94204a8
authored
Feb 17, 2016
by
Mushtaq Ali
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #11452 from edx/mushtaq/ECOM-3615-fix-self-paced-scheduled-content
Fix self paced course content visiblity
parents
af9e26f5
5485d0c2
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
48 additions
and
5 deletions
+48
-5
cms/djangoapps/contentstore/utils.py
+9
-0
cms/djangoapps/contentstore/views/item.py
+9
-5
cms/djangoapps/contentstore/views/tests/test_item.py
+30
-0
No files found.
cms/djangoapps/contentstore/utils.py
View file @
b94204a8
...
...
@@ -13,6 +13,8 @@ from django.utils.translation import ugettext as _
from
django_comment_common.models
import
assign_default_role
from
django_comment_common.utils
import
seed_permissions_roles
from
openedx.core.djangoapps.self_paced.models
import
SelfPacedConfiguration
from
xmodule.modulestore
import
ModuleStoreEnum
from
xmodule.modulestore.django
import
modulestore
from
xmodule.modulestore.exceptions
import
ItemNotFoundError
...
...
@@ -455,3 +457,10 @@ def get_visibility_partition_info(xblock):
"has_selected_groups"
:
has_selected_groups
,
"selected_verified_partition_id"
:
selected_verified_partition_id
,
}
def
is_self_paced
(
course
):
"""
Returns True if course is self-paced, False otherwise.
"""
return
course
and
course
.
self_paced
and
SelfPacedConfiguration
.
current
()
.
enabled
cms/djangoapps/contentstore/views/item.py
View file @
b94204a8
...
...
@@ -31,6 +31,8 @@ from contentstore.utils import (
from
contentstore.views.helpers
import
is_unit
,
xblock_studio_url
,
xblock_primary_child_category
,
\
xblock_type_display_name
,
get_parent_xblock
,
create_xblock
,
usage_key_with_run
from
contentstore.views.preview
import
get_preview_fragment
from
contentstore.utils
import
is_self_paced
from
openedx.core.lib.gating
import
api
as
gating_api
from
edxmako.shortcuts
import
render_to_string
from
models.settings.course_grading
import
CourseGradingModel
...
...
@@ -855,7 +857,9 @@ def create_xblock_info(xblock, data=None, metadata=None, include_ancestor_info=F
release_date
=
_get_release_date
(
xblock
,
user
)
if
xblock
.
category
!=
'course'
:
visibility_state
=
_compute_visibility_state
(
xblock
,
child_info
,
is_xblock_unit
and
has_changes
)
visibility_state
=
_compute_visibility_state
(
xblock
,
child_info
,
is_xblock_unit
and
has_changes
,
is_self_paced
(
course
)
)
else
:
visibility_state
=
None
published
=
modulestore
()
.
has_published_version
(
xblock
)
if
not
is_library_block
else
None
...
...
@@ -1017,7 +1021,7 @@ class VisibilityState(object):
gated
=
'gated'
def
_compute_visibility_state
(
xblock
,
child_info
,
is_unit_with_changes
):
def
_compute_visibility_state
(
xblock
,
child_info
,
is_unit_with_changes
,
is_course_self_paced
=
False
):
"""
Returns the current publish state for the specified xblock and its children
"""
...
...
@@ -1027,10 +1031,10 @@ def _compute_visibility_state(xblock, child_info, is_unit_with_changes):
# Note that a unit that has never been published will fall into this category,
# as well as previously published units with draft content.
return
VisibilityState
.
needs_attention
is_unscheduled
=
xblock
.
start
==
DEFAULT_START_DATE
is_live
=
datetime
.
now
(
UTC
)
>
xblock
.
start
children
=
child_info
and
child_info
.
get
(
'children'
,
[])
if
children
and
len
(
children
)
>
0
:
is_live
=
is_course_self_paced
or
datetime
.
now
(
UTC
)
>
xblock
.
start
if
child_info
and
child_info
.
get
(
'children'
,
[]):
all_staff_only
=
True
all_unscheduled
=
True
all_live
=
True
...
...
cms/djangoapps/contentstore/views/tests/test_item.py
View file @
b94204a8
...
...
@@ -14,6 +14,7 @@ from django.test.client import RequestFactory
from
django.core.urlresolvers
import
reverse
from
contentstore.utils
import
reverse_usage_url
,
reverse_course_url
from
openedx.core.djangoapps.self_paced.models
import
SelfPacedConfiguration
from
contentstore.views.component
import
(
component_handler
,
get_component_templates
)
...
...
@@ -1847,6 +1848,7 @@ class TestLibraryXBlockCreation(ItemTest):
self
.
assertFalse
(
lib
.
children
)
@ddt.ddt
class
TestXBlockPublishingInfo
(
ItemTest
):
"""
Unit tests for XBlock's outline handling.
...
...
@@ -2169,3 +2171,31 @@ class TestXBlockPublishingInfo(ItemTest):
self
.
_verify_has_staff_only_message
(
xblock_info
,
True
)
self
.
_verify_has_staff_only_message
(
xblock_info
,
True
,
path
=
self
.
FIRST_SUBSECTION_PATH
)
self
.
_verify_has_staff_only_message
(
xblock_info
,
True
,
path
=
self
.
FIRST_UNIT_PATH
)
@ddt.data
(
ModuleStoreEnum
.
Type
.
mongo
,
ModuleStoreEnum
.
Type
.
split
)
def
test_self_paced_item_visibility_state
(
self
,
store_type
):
"""
Test that in self-paced course, item has `live` visibility state.
Test that when item was initially in `scheduled` state in instructor mode, change course pacing to self-paced,
now in self-paced course, item should have `live` visibility state.
"""
SelfPacedConfiguration
(
enabled
=
True
)
.
save
()
# Create course, chapter and setup future release date to make chapter in scheduled state
course
=
CourseFactory
.
create
(
default_store
=
store_type
)
chapter
=
self
.
_create_child
(
course
,
'chapter'
,
"Test Chapter"
)
self
.
_set_release_date
(
chapter
.
location
,
datetime
.
now
(
UTC
)
+
timedelta
(
days
=
1
))
# Check that chapter has scheduled state
xblock_info
=
self
.
_get_xblock_info
(
chapter
.
location
)
self
.
_verify_visibility_state
(
xblock_info
,
VisibilityState
.
ready
)
self
.
assertFalse
(
course
.
self_paced
)
# Change course pacing to self paced
course
.
self_paced
=
True
self
.
store
.
update_item
(
course
,
self
.
user
.
id
)
self
.
assertTrue
(
course
.
self_paced
)
# Check that in self paced course content has live state now
xblock_info
=
self
.
_get_xblock_info
(
chapter
.
location
)
self
.
_verify_visibility_state
(
xblock_info
,
VisibilityState
.
live
)
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