Commit 224bbf5b by Victor Shnayder

Docstring tweaks in x_module.py

parent 982026bb
...@@ -84,25 +84,37 @@ class XModule(object): ...@@ -84,25 +84,37 @@ class XModule(object):
Construct a new xmodule Construct a new xmodule
system: A ModuleSystem allowing access to external resources system: A ModuleSystem allowing access to external resources
location: Something Location-like that identifies this xmodule location: Something Location-like that identifies this xmodule
definition: A dictionary containing 'data' and 'children'. Both are optional definition: A dictionary containing 'data' and 'children'. Both are optional
'data': is JSON-like (string, dictionary, list, bool, or None, optionally nested). 'data': is JSON-like (string, dictionary, list, bool, or None, optionally nested).
This defines all of the data necessary for a problem to display that is intrinsic to the problem. This defines all of the data necessary for a problem to display
It should not include any data that would vary between two courses using the same problem that is intrinsic to the problem. It should not include any
data that would vary between two courses using the same problem
(due dates, grading policy, randomization, etc.) (due dates, grading policy, randomization, etc.)
'children': is a list of Location-like values for child modules that this module depends on
instance_state: A string of serialized json that contains the state of this module for 'children': is a list of Location-like values for child modules that
current student accessing the system, or None if no state has been saved this module depends on
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 instance_state: A string of serialized json that contains the state of
state is only shared per-student, not across different students this module for current student accessing the system, or None if no
kwargs: Optional arguments. Subclasses should always accept kwargs and pass them state has been saved
to the parent class constructor.
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
pass them to the parent class constructor.
Current known uses of kwargs: Current known uses of kwargs:
metadata: SCAFFOLDING - This dictionary will be split into several different types of metadata metadata: SCAFFOLDING - This dictionary will be split into
in the future (course policy, modification history, etc). several different types of metadata in the future (course
A dictionary containing data that specifies information that is particular policy, modification history, etc). A dictionary containing
to a problem in the context of a course data that specifies information that is particular to a
problem in the context of a course
''' '''
self.system = system self.system = system
self.location = Location(location) self.location = Location(location)
...@@ -174,25 +186,30 @@ class XModule(object): ...@@ -174,25 +186,30 @@ class XModule(object):
return None return None
def max_score(self): def max_score(self):
''' Maximum score. Two notes: ''' Maximum score. Two notes:
* This is generic; in abstract, a problem could be 3/5 points on one randomization, and 5/7 on another
* In practice, this is a Very Bad Idea, and (a) will break some code in place (although that code * This is generic; in abstract, a problem could be 3/5 points on one
should get fixed), and (b) break some analytics we plan to put in place. randomization, and 5/7 on another
'''
* In practice, this is a Very Bad Idea, and (a) will break some code
in place (although that code should get fixed), and (b) break some
analytics we plan to put in place.
'''
return None return None
def get_progress(self): def get_progress(self):
''' Return a progress.Progress object that represents how far the student has gone ''' Return a progress.Progress object that represents how far the
in this module. Must be implemented to get correct progress tracking behavior in student has gone in this module. Must be implemented to get correct
nesting modules like sequence and vertical. progress tracking behavior in nesting modules like sequence and
vertical.
If this module has no notion of progress, return None. If this module has no notion of progress, return None.
''' '''
return None return None
def handle_ajax(self, dispatch, get): def handle_ajax(self, dispatch, get):
''' dispatch is last part of the URL. ''' dispatch is last part of the URL.
get is a dictionary-like object ''' get is a dictionary-like object '''
return "" return ""
# ================================== HTML INTERFACE DEFINITIONS ====================== # ================================== HTML INTERFACE DEFINITIONS ======================
...@@ -210,9 +227,12 @@ class XModule(object): ...@@ -210,9 +227,12 @@ class XModule(object):
return cls.js return cls.js
def get_html(self): def get_html(self):
''' HTML, as shown in the browser. This is the only method that must be implemented ''' HTML, as shown in the browser. This is the only method that must be
implemented.
''' '''
raise NotImplementedError("get_html must be defined for all XModules that appear on the screen. Not defined in %s" % self.__class__.__name__) raise NotImplementedError("get_html must be defined for all XModules "
"that appear on the screen. Not defined in %s"
% self.__class__.__name__)
...@@ -235,14 +255,15 @@ class XModuleDescriptor(Plugin): ...@@ -235,14 +255,15 @@ class XModuleDescriptor(Plugin):
inheritable_metadata = ( inheritable_metadata = (
'graded', 'due', 'graceperiod', 'showanswer', 'rerandomize', 'graded', 'due', 'graceperiod', 'showanswer', 'rerandomize',
# This is used by the XMLModuleStore to provide for locations for static files, # TODO: This is used by the XMLModuleStore to provide for locations for
# and will need to be removed when that code is removed # static files, and will need to be removed when that code is removed
'data_dir' 'data_dir'
) )
# A list of descriptor attributes that must be equal for the descriptors to be # A list of descriptor attributes that must be equal for the descriptors to be
# equal # equal
equality_attributes = ('definition', 'metadata', 'location', 'shared_state_key', '_inherited_metadata') equality_attributes = ('definition', 'metadata', 'location',
'shared_state_key', '_inherited_metadata')
# ============================= STRUCTURAL MANIPULATION =========================== # ============================= STRUCTURAL MANIPULATION ===========================
def __init__(self, def __init__(self,
......
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