Commit d4eb285f by Bill Filler

pass information about the gating section to the template such that link and…

pass information about the gating section to the template such that link and required score can be displayed
parent 2867ee51
......@@ -322,9 +322,12 @@ class SequenceModule(SequenceFields, ProctoringFields, XModule):
if self.runtime.user_is_staff:
banner_text = _('This subsection is unlocked for learners when they meet the prerequisite requirements.')
elif not self._is_prereq_met(milestones[0]):
banner_text = _('This subsection is locked until prerequisite requirements are met.')
gate_content = True
# TODO - force a subsection grade recalcuation and then check again
required_grade = milestones[0]['requirements']['min_score']
# figure out correct way to formulate this url
preqreq_url = '../../../jump_to/' + milestones[0]['namespace'].replace('.gating', '')
# figure out how to get the display name of the gating section
preqreq_section_name = 'Test Section'
else:
print('\nBF!! Hurray the prequesite has been met!!')
......@@ -340,7 +343,10 @@ class SequenceModule(SequenceFields, ProctoringFields, XModule):
'prev_url': context.get('prev_url'),
'banner_text': banner_text,
'disable_navigation': not self.is_user_authenticated(context),
'gate_content' : gate_content,
'gate_content': gate_content,
'required_grade': required_grade if gate_content else None,
'prereq_url': preqreq_url if gate_content else None,
'prereq_section_name' : preqreq_section_name if gate_content else None
}
fragment.add_content(self.system.render_template("seq_module.html", params))
......
<%page expression_filter="h"/>
<%! from django.utils.translation import ugettext as _ %>
<%!
from django.utils.translation import ugettext as _
from openedx.core.djangolib.markup import HTML, Text
%>
<div id="sequence_${element_id}" class="sequence" data-id="${item_id}" data-position="${position}" data-ajax-url="${ajax_url}" data-next-url="${next_url}" data-prev-url="${prev_url}">
% if banner_text:
% if banner_text or gate_content:
<div class="pattern-library-shim alert alert-information subsection-header" tabindex="-1">
<span class="pattern-library-shim icon alert-icon fa fa-bullhorn" aria-hidden="true"></span>
<div class="pattern-library-shim alert-message">
<p class="pattern-library-shim alert-copy">
% if gate_content:
${Text(_(
"This content is blocked until you reach a grade of {req_grade} in {link_start}{section_name}{link_end}."
)).format(
req_grade=HTML("<b>{}%</b>").format(required_grade),
link_start=HTML("<a href='{}'>").format(prereq_url),
section_name=prereq_section_name,
link_end=HTML("</a>"),
)}
% else:
${banner_text}
% endif
</p>
</div>
</div>
......
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