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): ...@@ -253,8 +253,11 @@ class SequenceModule(SequenceFields, ProctoringFields, XModule):
display depending on whether staff is masquerading. display depending on whether staff is masquerading.
""" """
course = self._get_course() course = self._get_course()
if not self._can_user_view_content(course): content_gated = self._is_content_gated()
if course.self_paced: 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.") banner_text = _("Because the course has ended, this assignment is hidden from the learner.")
else: else:
banner_text = _("Because the due date has passed, this assignment is hidden from the learner.") banner_text = _("Because the due date has passed, this assignment is hidden from the learner.")
...@@ -264,6 +267,7 @@ class SequenceModule(SequenceFields, ProctoringFields, XModule): ...@@ -264,6 +267,7 @@ class SequenceModule(SequenceFields, ProctoringFields, XModule):
{ {
'self_paced': course.self_paced, 'self_paced': course.self_paced,
'progress_url': context.get('progress_url'), 'progress_url': context.get('progress_url'),
'content_gated': content_gated
} }
) )
...@@ -274,14 +278,22 @@ class SequenceModule(SequenceFields, ProctoringFields, XModule): ...@@ -274,14 +278,22 @@ class SequenceModule(SequenceFields, ProctoringFields, XModule):
Checks whether the content is gated for learners. If so, Checks whether the content is gated for learners. If so,
returns a banner_text depending on whether user is staff. 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') milestones_service = self.runtime.service(self, 'milestones')
if milestones_service: if milestones_service:
content_milestones = milestones_service.get_course_content_milestones( content_milestones = milestones_service.get_course_content_milestones(
self.course_id, self.location, 'requires' self.course_id, self.location, 'requires'
) )
banner_text = _('This subsection is unlocked for learners when they meet the prerequisite requirements.') return content_milestones
if content_milestones and self.runtime.user_is_staff:
return banner_text return False
def _can_user_view_content(self, course): def _can_user_view_content(self, course):
""" """
...@@ -291,7 +303,7 @@ class SequenceModule(SequenceFields, ProctoringFields, XModule): ...@@ -291,7 +303,7 @@ class SequenceModule(SequenceFields, ProctoringFields, XModule):
hidden_date = course.end if course.self_paced else self.due hidden_date = course.end if course.self_paced else self.due
return ( return (
self.runtime.user_is_staff or self.runtime.user_is_staff or
self.verify_current_content_visibility(hidden_date, self.hide_after_due) self.verify_current_content_visibility(hidden_date, self.hide_after_due)
) )
def is_user_authenticated(self, context): def is_user_authenticated(self, context):
......
...@@ -66,8 +66,8 @@ class MilestonesAndSpecialExamsTransformer(BlockStructureTransformer): ...@@ -66,8 +66,8 @@ class MilestonesAndSpecialExamsTransformer(BlockStructureTransformer):
if usage_info.has_staff_access: if usage_info.has_staff_access:
return False return False
elif self.has_pending_milestones_for_user(block_key, usage_info): # elif self.has_pending_milestones_for_user(block_key, usage_info):
return True # return True
elif self.gated_by_required_content(block_key, block_structure, required_content): elif self.gated_by_required_content(block_key, block_structure, required_content):
return True return True
elif (settings.FEATURES.get('ENABLE_SPECIAL_EXAMS', False) and elif (settings.FEATURES.get('ENABLE_SPECIAL_EXAMS', False) and
......
...@@ -493,7 +493,7 @@ def _has_access_descriptor(user, action, descriptor, course_key=None): ...@@ -493,7 +493,7 @@ def _has_access_descriptor(user, action, descriptor, course_key=None):
return ( return (
_visible_to_nonstaff_users(descriptor) and _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 _has_detached_class_tag(descriptor) or
check_start_date(user, descriptor.days_early_for_beta, descriptor.start, course_key) 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 ...@@ -15,7 +15,7 @@ from openedx.features.course_experience import COURSE_PRE_START_ACCESS_FLAG
from student.roles import CourseBetaTesterRole from student.roles import CourseBetaTesterRole
from xmodule.util.django import get_current_request_hostname from xmodule.util.django import get_current_request_hostname
DEBUG_ACCESS = False DEBUG_ACCESS = True
log = getLogger(__name__) log = getLogger(__name__)
ACCESS_GRANTED = AccessResponse(True) ACCESS_GRANTED = AccessResponse(True)
......
...@@ -6,7 +6,9 @@ from openedx.core.djangolib.markup import HTML, Text ...@@ -6,7 +6,9 @@ from openedx.core.djangolib.markup import HTML, Text
<div class="sequence hidden-content proctored-exam completed"> <div class="sequence hidden-content proctored-exam completed">
<h3> <h3>
% if self_paced: % if content_gated:
${_("Prerequistes not met.")}
% elif self_paced:
${_("The course has ended.")} ${_("The course has ended.")}
% else: % else:
${_("The due date for this assignment has passed.")} ${_("The due date for this assignment has passed.")}
...@@ -14,7 +16,16 @@ from openedx.core.djangolib.markup import HTML, Text ...@@ -14,7 +16,16 @@ from openedx.core.djangolib.markup import HTML, Text
</h3> </h3>
<hr> <hr>
<p> <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(_( ${Text(_(
"Because the course has ended, this assignment is no longer " "Because the course has ended, this assignment is no longer "
"available.{line_break}If you have completed this assignment, your " "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