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
f9c37595
Commit
f9c37595
authored
Feb 04, 2016
by
Mushtaq Ali
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix self-paced course displaying "published, not yet released" issue in Studio ECOM-3615
parent
a26d5764
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
51 additions
and
5 deletions
+51
-5
cms/djangoapps/contentstore/utils.py
+15
-0
cms/djangoapps/contentstore/views/item.py
+9
-5
cms/djangoapps/contentstore/views/tests/test_item.py
+27
-0
No files found.
cms/djangoapps/contentstore/utils.py
View file @
f9c37595
...
...
@@ -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,16 @@ 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.
"""
if
course
:
try
:
return
course
.
self_paced
and
SelfPacedConfiguration
.
current
()
.
enabled
except
AttributeError
:
# if course object has no self_paced attribute
pass
return
False
cms/djangoapps/contentstore/views/item.py
View file @
f9c37595
...
...
@@ -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
):
"""
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 @
f9c37595
...
...
@@ -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
)
...
...
@@ -2169,3 +2170,29 @@ 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
)
def
test_self_paced_item_visibility_state
(
self
):
"""
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 chapter and setup future release date to make chapter in scheduled state
chapter
=
self
.
_create_child
(
self
.
course
,
'chapter'
,
"Test Chapter"
)
self
.
_set_release_date
(
chapter
.
location
,
datetime
.
now
(
UTC
)
+
timedelta
(
days
=
1
))
# Check that has scheduled state
xblock_info
=
self
.
_get_xblock_info
(
chapter
.
location
)
self
.
_verify_visibility_state
(
xblock_info
,
VisibilityState
.
ready
)
self
.
assertFalse
(
self
.
course
.
self_paced
)
# Change course pacing to self paced
self
.
course
.
self_paced
=
True
self
.
store
.
update_item
(
self
.
course
,
self
.
user
.
id
)
self
.
assertTrue
(
self
.
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