-
Notifications
You must be signed in to change notification settings - Fork 3.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix self paced course content visiblity #11452
Changes from 4 commits
f9c3759
df0b983
3559bd1
d3fc262
5485d0c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,6 +13,8 @@ | |
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 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you check if there is any table in mysql where this mapping is added? I mean where we add information about course if it is self paced? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I have checked but there is no such SelfPaced to Course mapping table in MySQL. |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -31,6 +31,8 @@ | |
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 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I have a suggestion, Instead of passing How about something like this? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nice catch, but I didn't wanted to pass whole course object which was unnecessary, so I passed only what is required in However, I should make |
||
if child_info and child_info.get('children', []): | ||
all_staff_only = True | ||
all_unscheduled = True | ||
all_live = True | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this is worthwhile to abstract out into its own utility. Also,
self_paced
should always return a boolean: https://github.com/edx/edx-platform/blob/master/common/lib/xmodule/xmodule/course_module.py#L753-L763.If it's not set, it'll return
False
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It needs utility because, we can not always use
course. self_paced
because increate_xblock_info
method it does not have to be a course always ( sometimes library may be). Thus,course
object may be None. Also, we still need to check onSelfPacedConfiguration
is enabled or not.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ugh