Put XBlock css and javascript onto the LMS courseware page
This required changing structural XModules to fully implement student_view, rather than just returning the HTML of their children in a get_html call. [LMS-223] [LMS-1170]
This commit is contained in:
@@ -9,6 +9,7 @@ from xmodule.x_module import XModule
|
||||
from xmodule.progress import Progress
|
||||
from xmodule.exceptions import NotFoundError
|
||||
from xblock.fields import Integer, Scope
|
||||
from xblock.fragment import Fragment
|
||||
from pkg_resources import resource_string
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
@@ -43,12 +44,6 @@ class SequenceModule(SequenceFields, XModule):
|
||||
if getattr(self.system, 'position', None) is not None:
|
||||
self.position = int(self.system.position)
|
||||
|
||||
self.rendered = False
|
||||
|
||||
def get_html(self):
|
||||
self.render()
|
||||
return self.content
|
||||
|
||||
def get_progress(self):
|
||||
''' Return the total progress, adding total done and total available.
|
||||
(assumes that each submodule uses the same "units" for progress.)
|
||||
@@ -66,20 +61,24 @@ class SequenceModule(SequenceFields, XModule):
|
||||
return json.dumps({'success': True})
|
||||
raise NotFoundError('Unexpected dispatch type')
|
||||
|
||||
def render(self):
|
||||
def student_view(self, context):
|
||||
# If we're rendering this sequence, but no position is set yet,
|
||||
# default the position to the first element
|
||||
if self.position is None:
|
||||
self.position = 1
|
||||
|
||||
if self.rendered:
|
||||
return
|
||||
## Returns a set of all types of all sub-children
|
||||
contents = []
|
||||
|
||||
fragment = Fragment()
|
||||
|
||||
for child in self.get_display_items():
|
||||
progress = child.get_progress()
|
||||
rendered_child = child.render('student_view', context)
|
||||
fragment.add_frag_resources(rendered_child)
|
||||
|
||||
childinfo = {
|
||||
'content': child.render('student_view').content,
|
||||
'content': rendered_child.content,
|
||||
'title': "\n".join(
|
||||
grand_child.display_name
|
||||
for grand_child in child.get_children()
|
||||
@@ -98,11 +97,12 @@ class SequenceModule(SequenceFields, XModule):
|
||||
'element_id': self.location.html_id(),
|
||||
'item_id': self.id,
|
||||
'position': self.position,
|
||||
'tag': self.location.category
|
||||
'tag': self.location.category,
|
||||
}
|
||||
|
||||
self.content = self.system.render_template('seq_module.html', params)
|
||||
self.rendered = True
|
||||
fragment.add_content(self.system.render_template('seq_module.html', params))
|
||||
|
||||
return fragment
|
||||
|
||||
def get_icon_class(self):
|
||||
child_classes = set(child.get_icon_class()
|
||||
|
||||
Reference in New Issue
Block a user