EDUCATOR-2303 allow learners to see gated banner before starting proctored or timed exam

This commit is contained in:
rabiaiftikhar
2018-10-24 02:03:55 +05:00
parent c992edc83d
commit 6fbd86108c
3 changed files with 99 additions and 25 deletions

View File

@@ -241,13 +241,23 @@ class SequenceModule(SequenceFields, ProctoringFields, XModule):
context = context or {}
self._capture_basic_metrics()
banner_text = None
special_html_view = self._hidden_content_student_view(context) or self._special_exam_student_view()
if special_html_view:
masquerading_as_specific_student = context.get('specific_masquerade', False)
banner_text, special_html = special_html_view
if special_html and not masquerading_as_specific_student:
return Fragment(special_html)
return self._student_view(context, banner_text)
prereq_met = True
prereq_meta_info = {}
if self._required_prereq():
if self.runtime.user_is_staff:
banner_text = _('This subsection is unlocked for learners when they meet the prerequisite requirements.')
else:
# check if prerequisite has been met
prereq_met, prereq_meta_info = self._compute_is_prereq_met(True)
if prereq_met:
special_html_view = self._hidden_content_student_view(context) or self._special_exam_student_view()
if special_html_view:
masquerading_as_specific_student = context.get('specific_masquerade', False)
banner_text, special_html = special_html_view
if special_html and not masquerading_as_specific_student:
return Fragment(special_html)
return self._student_view(context, prereq_met, prereq_meta_info, banner_text)
def _special_exam_student_view(self):
"""
@@ -299,7 +309,7 @@ class SequenceModule(SequenceFields, ProctoringFields, XModule):
# NOTE (CCB): We default to true to maintain the behavior in place prior to allowing anonymous access access.
return context.get('user_authenticated', True)
def _student_view(self, context, banner_text=None):
def _student_view(self, context, prereq_met, prereq_meta_info, banner_text=None):
"""
Returns the rendered student view of the content of this
sequential. If banner_text is given, it is added to the
@@ -307,15 +317,7 @@ class SequenceModule(SequenceFields, ProctoringFields, XModule):
"""
display_items = self.get_display_items()
self._update_position(context, len(display_items))
prereq_met = True
prereq_meta_info = {}
if self._required_prereq():
if self.runtime.user_is_staff:
banner_text = _('This subsection is unlocked for learners when they meet the prerequisite requirements.')
else:
# check if prerequisite has been met
prereq_met, prereq_meta_info = self._compute_is_prereq_met(True)
if prereq_met and not self._is_gate_fulfilled():
banner_text = _('This section is a prerequisite. You must complete this section in order to unlock additional content.')