Commit 2671801f by David Ormsbee

Add optional hide_from_toc attribute to XML elements to support Tutorials (which…

Add optional hide_from_toc attribute to XML elements to support Tutorials (which don't show up in the navigation).
parent 1d554c76
......@@ -104,7 +104,8 @@ class HTMLSnippet(object):
"""
Return the html used to display this snippet
"""
raise NotImplementedError("get_html() must be provided by specific modules")
raise NotImplementedError("get_html() must be provided by specific modules - not present in {0}"
.format(self.__class__))
class XModule(HTMLSnippet):
......
......@@ -88,7 +88,7 @@ class XmlDescriptor(XModuleDescriptor):
# The attributes will be removed from the definition xml passed
# to definition_from_xml, and from the xml returned by definition_to_xml
metadata_attributes = ('format', 'graceperiod', 'showanswer', 'rerandomize',
'start', 'due', 'graded', 'name', 'slug')
'start', 'due', 'graded', 'name', 'slug', 'hide_from_toc')
# A dictionary mapping xml attribute names to functions of the value
# that return the metadata key and value
......
......@@ -56,11 +56,13 @@ def toc_for_course(user, request, course, active_chapter, active_section):
active = (chapter.metadata.get('display_name') == active_chapter and
section.metadata.get('display_name') == active_section)
hide_from_toc = section.metadata.get('hide_from_toc', 'false').lower() == 'true'
sections.append({'name': section.metadata.get('display_name'),
'format': section.metadata.get('format', ''),
'due': section.metadata.get('due', ''),
'active': active})
'active': active,
'hide_from_toc' : hide_from_toc})
chapters.append({'name': chapter.metadata.get('display_name'),
'sections': sections,
......
......@@ -3,20 +3,22 @@
<%def name="make_chapter(chapter)">
<h3><a href="#">${chapter['name']}</a></h3>
<ul>
% for section in chapter['sections']:
<li${' class="active"' if 'active' in section and section['active'] else ''}>
<a href="${reverse('courseware_section', args=[course_id] + format_url_params([chapter['name'], section['name']]))}">
<p>${section['name']}
<span class="subtitle">
${section['format']} ${"due " + section['due'] if 'due' in section and section['due'] != '' else ''}
</span>
</p>
</a>
% endfor
</ul>
</%def>
<ul>
% for section in chapter['sections']:
% if not section['hide_from_toc']:
<li${' class="active"' if 'active' in section and section['active'] else ''}>
<a href="${reverse('courseware_section', args=[course_id] + format_url_params([chapter['name'], section['name']]))}">
<p>${section['name']}
<span class="subtitle">
${section['format']} ${"due " + section['due'] if 'due' in section and section['due'] != '' else ''}
</span>
</p>
</a>
</li>
% endif
% endfor
</ul>
</%def>
% for chapter in toc:
${make_chapter(chapter)}
......
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