Commit 0914acd5 by Bill Filler

show gated content in outline and navigation, but don't show actual content when goto page

parent c1abf432
......@@ -253,8 +253,11 @@ class SequenceModule(SequenceFields, ProctoringFields, XModule):
display depending on whether staff is masquerading.
"""
course = self._get_course()
if not self._can_user_view_content(course):
if course.self_paced:
content_gated = self._is_content_gated()
if not self._can_user_view_content(course) or content_gated:
if content_gated:
banner_text = _('This subsection is locked until prerequisite requirements met.')
elif course.self_paced:
banner_text = _("Because the course has ended, this assignment is hidden from the learner.")
else:
banner_text = _("Because the due date has passed, this assignment is hidden from the learner.")
......@@ -264,6 +267,7 @@ class SequenceModule(SequenceFields, ProctoringFields, XModule):
{
'self_paced': course.self_paced,
'progress_url': context.get('progress_url'),
'content_gated': content_gated
}
)
......@@ -274,14 +278,22 @@ class SequenceModule(SequenceFields, ProctoringFields, XModule):
Checks whether the content is gated for learners. If so,
returns a banner_text depending on whether user is staff.
"""
banner_text = _('This subsection is unlocked for learners when they meet the prerequisite requirements.')
if self._is_content_gated() and self.runtime.user_is_staff:
return banner_text
def _is_content_gated(self):
"""
Checks whether the content is gated for learners.
"""
milestones_service = self.runtime.service(self, 'milestones')
if milestones_service:
content_milestones = milestones_service.get_course_content_milestones(
self.course_id, self.location, 'requires'
)
banner_text = _('This subsection is unlocked for learners when they meet the prerequisite requirements.')
if content_milestones and self.runtime.user_is_staff:
return banner_text
return content_milestones
return False
def _can_user_view_content(self, course):
"""
......
......@@ -66,8 +66,8 @@ class MilestonesAndSpecialExamsTransformer(BlockStructureTransformer):
if usage_info.has_staff_access:
return False
elif self.has_pending_milestones_for_user(block_key, usage_info):
return True
# elif self.has_pending_milestones_for_user(block_key, usage_info):
# return True
elif self.gated_by_required_content(block_key, block_structure, required_content):
return True
elif (settings.FEATURES.get('ENABLE_SPECIAL_EXAMS', False) and
......
......@@ -493,7 +493,7 @@ def _has_access_descriptor(user, action, descriptor, course_key=None):
return (
_visible_to_nonstaff_users(descriptor) and
_can_access_descriptor_with_milestones(user, descriptor, course_key) and
# _can_access_descriptor_with_milestones(user, descriptor, course_key) and
(
_has_detached_class_tag(descriptor) or
check_start_date(user, descriptor.days_early_for_beta, descriptor.start, course_key)
......
......@@ -15,7 +15,7 @@ from openedx.features.course_experience import COURSE_PRE_START_ACCESS_FLAG
from student.roles import CourseBetaTesterRole
from xmodule.util.django import get_current_request_hostname
DEBUG_ACCESS = False
DEBUG_ACCESS = True
log = getLogger(__name__)
ACCESS_GRANTED = AccessResponse(True)
......
......@@ -6,7 +6,9 @@ from openedx.core.djangolib.markup import HTML, Text
<div class="sequence hidden-content proctored-exam completed">
<h3>
% if self_paced:
% if content_gated:
${_("Prerequistes not met.")}
% elif self_paced:
${_("The course has ended.")}
% else:
${_("The due date for this assignment has passed.")}
......@@ -14,7 +16,16 @@ from openedx.core.djangolib.markup import HTML, Text
</h3>
<hr>
<p>
% if self_paced:
% if content_gated:
${Text(_(
"This content is locked until all prerequistes have been met.{line_break}Press refresh to try again. "
"Grade is available on the {link_start}progress page{link_end}."
)).format(
line_break=HTML("<br>"),
link_start=HTML("<a href='{}'>").format(progress_url),
link_end=HTML("</a>"),
)}
% elif self_paced:
${Text(_(
"Because the course has ended, this assignment is no longer "
"available.{line_break}If you have completed this assignment, your "
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment