Merge pull request #19361 from edx/nedbat/cri-136
Use XBlock services to get translation at runtime CRI-136
This commit is contained in:
@@ -165,6 +165,7 @@ class ProctoringFields(object):
|
||||
@XBlock.wants('completion')
|
||||
@XBlock.needs('user')
|
||||
@XBlock.needs('bookmarks')
|
||||
@XBlock.needs('i18n')
|
||||
class SequenceModule(SequenceFields, ProctoringFields, XModule):
|
||||
"""
|
||||
Layout module which lays out content in a temporal sequence
|
||||
@@ -238,6 +239,7 @@ class SequenceModule(SequenceFields, ProctoringFields, XModule):
|
||||
)
|
||||
|
||||
def student_view(self, context):
|
||||
_ = self.runtime.service(self, "i18n").ugettext
|
||||
context = context or {}
|
||||
self._capture_basic_metrics()
|
||||
banner_text = None
|
||||
@@ -265,6 +267,7 @@ class SequenceModule(SequenceFields, ProctoringFields, XModule):
|
||||
a banner_text or the fragment to display depending on whether
|
||||
staff is masquerading.
|
||||
"""
|
||||
_ = self.runtime.service(self, "i18n").ugettext
|
||||
if self.is_time_limited:
|
||||
special_exam_html = self._time_limited_student_view()
|
||||
if special_exam_html:
|
||||
@@ -277,6 +280,7 @@ class SequenceModule(SequenceFields, ProctoringFields, XModule):
|
||||
runtime user. If so, returns a banner_text or the fragment to
|
||||
display depending on whether staff is masquerading.
|
||||
"""
|
||||
_ = self.runtime.service(self, "i18n").ugettext
|
||||
course = self._get_course()
|
||||
if not self._can_user_view_content(course):
|
||||
if course.self_paced:
|
||||
@@ -315,6 +319,7 @@ class SequenceModule(SequenceFields, ProctoringFields, XModule):
|
||||
sequential. If banner_text is given, it is added to the
|
||||
content.
|
||||
"""
|
||||
_ = self.runtime.service(self, "i18n").ugettext
|
||||
display_items = self.get_display_items()
|
||||
self._update_position(context, len(display_items))
|
||||
|
||||
|
||||
@@ -166,7 +166,7 @@ class SequenceBlockTestCase(XModuleXmlImportTest):
|
||||
)
|
||||
self.assertIn("seq_module.html", html)
|
||||
self.assertIn(
|
||||
"'banner_text': 'Because the due date has passed, "
|
||||
"'banner_text': u'Because the due date has passed, "
|
||||
"this assignment is hidden from the learner.'",
|
||||
html
|
||||
)
|
||||
@@ -208,7 +208,7 @@ class SequenceBlockTestCase(XModuleXmlImportTest):
|
||||
"""
|
||||
self.assertIn("seq_module.html", html)
|
||||
self.assertIn(
|
||||
"'banner_text': 'This section is a prerequisite. "
|
||||
"'banner_text': u'This section is a prerequisite. "
|
||||
"You must complete this section in order to unlock additional content.'",
|
||||
html
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user