add docs for conditional module; clean up a bit more
This commit is contained in:
@@ -43,7 +43,6 @@ class ConditionalModule(XModule):
|
||||
"""
|
||||
XModule.__init__(self, system, location, definition, descriptor, instance_state, shared_state, **kwargs)
|
||||
self.contents = None
|
||||
#self.required_modules_list = [tuple(x.split('/',1)) for x in self.metadata.get('required','').split('&')]
|
||||
self.condition = self.metadata.get('condition','')
|
||||
#log.debug('conditional module required=%s' % self.required_modules_list)
|
||||
|
||||
@@ -105,9 +104,7 @@ class ConditionalModule(XModule):
|
||||
if not self.is_condition_satisfied():
|
||||
context = {'module': self}
|
||||
html = self.system.render_template('conditional_module.html', context)
|
||||
# html = render_to_string('conditional_module.html', context)
|
||||
return json.dumps({'html': html})
|
||||
#return self.system.render_template('conditional_module.html', context)
|
||||
|
||||
if self.contents is None:
|
||||
self.contents = [child.get_html() for child in self.get_display_items()]
|
||||
@@ -115,10 +112,7 @@ class ConditionalModule(XModule):
|
||||
# for now, just deal with one child
|
||||
html = self.contents[0]
|
||||
|
||||
#log.debug('rendered conditional module %s' % str(self.location))
|
||||
|
||||
return json.dumps({'html': html})
|
||||
#return html
|
||||
|
||||
class ConditionalDescriptor(SequenceDescriptor):
|
||||
module_class = ConditionalModule
|
||||
|
||||
@@ -141,6 +141,7 @@ That's basically all there is to the organizational structure. Read the next se
|
||||
|
||||
* `abtest` -- Support for A/B testing. TODO: add details..
|
||||
* `chapter` -- top level organization unit of a course. The courseware display code currently expects the top level `course` element to contain only chapters, though there is no philosophical reason why this is required, so we may change it to properly display non-chapters at the top level.
|
||||
* `conditional` -- conditional element, which shows one or more modules only if certain conditions are satisfied.
|
||||
* `course` -- top level tag. Contains everything else.
|
||||
* `customtag` -- render an html template, filling in some parameters, and return the resulting html. See below for details.
|
||||
* `discussion` -- Inline discussion forum
|
||||
@@ -163,6 +164,22 @@ Container tags include `chapter`, `sequential`, `videosequence`, `vertical`, and
|
||||
|
||||
`course` is also a container, and is similar, with one extra wrinkle: the top level pointer tag _must_ have `org` and `course` attributes specified--the organization name, and course name. Note that `course` is referring to the platonic ideal of this course (e.g. "6.002x"), not to any particular run of this course. The `url_name` should be the particular run of this course.
|
||||
|
||||
### `conditional`
|
||||
|
||||
`conditional` is as special kind of container tag as well. Here are two examples:
|
||||
|
||||
<conditional condition="require_completed" required="problem/choiceprob">
|
||||
<video url_name="secret_video" />
|
||||
</conditional>
|
||||
|
||||
<conditional condition="require_attempted" required="problem/choiceprob&problem/sumprob">
|
||||
<html url_name="secret_page" />
|
||||
</conditional>
|
||||
|
||||
The condition can be either `require_completed`, in which case the required modules must be completed, or `require_attempted`, in which case the required modules must have been attempted.
|
||||
|
||||
The required modules are specified as a set of `tag`/`url_name`, joined by an ampersand.
|
||||
|
||||
### `customtag`
|
||||
|
||||
When we see `<customtag impl="special" animal="unicorn" hat="blue"/>`, we will:
|
||||
|
||||
Reference in New Issue
Block a user