Commit c91ea8fc by Calen Pennington

Update the __init__ for XModule to the new interface specification

parent 744652d7
...@@ -10,10 +10,6 @@ class_priority = ['video', 'problem'] ...@@ -10,10 +10,6 @@ class_priority = ['video', 'problem']
class VerticalModule(XModule): class VerticalModule(XModule):
''' Layout module for laying out submodules vertically.''' ''' Layout module for laying out submodules vertically.'''
def __init__(self, system, location, definition, descriptor, instance_state=None, shared_state=None, **kwargs):
XModule.__init__(self, system, location, definition, descriptor, instance_state, shared_state, **kwargs)
self.contents = None
def get_html(self): def get_html(self):
if self.contents is None: if self.contents is None:
self.contents = [child.get_html() for child in self.get_display_items()] self.contents = [child.get_html() for child in self.get_display_items()]
......
...@@ -152,64 +152,32 @@ class XModule(Plugin, HTMLSnippet): ...@@ -152,64 +152,32 @@ class XModule(Plugin, HTMLSnippet):
entry_point = "xmodule.v2" entry_point = "xmodule.v2"
def __init__(self, system, location, definition, descriptor, def __init__(self, runtime, content, course_settings, user_preferences, student_state, *args, **kwargs):
instance_state=None, shared_state=None, **kwargs):
''' '''
Construct a new xmodule Construct a new xmodule
system: A ModuleSystem allowing access to external resources runtime: A ModuleSystem allowing access to external resources
location: Something Location-like that identifies this xmodule content: A dictionary containing the data that the content author
created to define this module instance
definition: A dictionary containing 'data' and 'children'. Both are course_settings: A dictionary containing the data that describes how the module
optional should operate
'data': is JSON-like (string, dictionary, list, bool, or None, user_preferences: A dictionary containing the data that describes the
optionally nested). global preferences for this user about this module type
This defines all of the data necessary for a problem to display student_state: A dictionary containing the data that a student has
that is intrinsic to the problem. It should not include any entered for this module
data that would vary between two courses using the same problem
(due dates, grading policy, randomization, etc.)
'children': is a list of Location-like values for child modules that
this module depends on
descriptor: the XModuleDescriptor that this module is an instance of.
TODO (vshnayder): remove the definition parameter and location--they
can come from the descriptor.
instance_state: A string of serialized json that contains the state of
this module for current student accessing the system, or None if
no state has been saved
shared_state: A string of serialized json that contains the state that
is shared between this module and any modules of the same type with
the same shared_state_key. This state is only shared per-student,
not across different students
kwargs: Optional arguments. Subclasses should always accept kwargs and kwargs: Optional arguments. Subclasses should always accept kwargs and
pass them to the parent class constructor. pass them to the parent class constructor.
Current known uses of kwargs:
metadata: SCAFFOLDING - This dictionary will be split into
several different types of metadata in the future (course
policy, modification history, etc). A dictionary containing
data that specifies information that is particular to a
problem in the context of a course
''' '''
self.system = system self.runtime = runtime
self.location = Location(location) self.content = content
self.definition = definition self.course_settings = course_settings
self.descriptor = descriptor self.user_preferences = user_preferences
self.instance_state = instance_state self.student_state = student_state
self.shared_state = shared_state
self.id = self.location.url()
self.url_name = self.location.name
self.category = self.location.category
self.metadata = kwargs.get('metadata', {})
self._loaded_children = None
@property @property
def display_name(self): def display_name(self):
...@@ -220,9 +188,6 @@ class XModule(Plugin, HTMLSnippet): ...@@ -220,9 +188,6 @@ class XModule(Plugin, HTMLSnippet):
return self.metadata.get('display_name', return self.metadata.get('display_name',
self.url_name.replace('_', ' ')) self.url_name.replace('_', ' '))
def __unicode__(self):
return '<x_module(id={0})>'.format(self.id)
def get_children(self): def get_children(self):
''' '''
Return module instances for all the children of this module. Return module instances for all the children of this module.
......
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