Template:AKTOC
Create an Answer Key's Table of Contents.
Parameters
- page
- This should be the title of an honor's landing page. If omitted, the template will assume that it has been invoked from a landing page or a subpage of one and construct a page title for the landing page from the first two elements of {{PAGENAME}}. Note that language detection is based on the invoking page rather than on the {{{page}}} parameter.
Mechanics
The template starts by defining two variables to sort out the page title of the landing page and the requirements page.
After that it has three nested while loops. The outer loop is for the primary requirement numbers (1), then the secondary (1.b), and finally, the tertiary (1.b.iii)
Within each loop, it determines if the proposed requirement exists or not with this fragment:
- {{#vardefineecho:req|{{#lst:{{#var:reqpage}}|req{{#var:primary}}}}}}
This snippet defines a variable and echos the definition. The echo is important, because this line of code serves as the condition for the while loop. As long as this snippet returns a non-empty string, the loop will continue. The requirement is extracted from the requirements page by transcluding a labeled section with {{#lst:...}}. The section label is simply "req" with the requirement number as a suffix.
For the two inner loops it's slightly more complex since the label will be of the form "1b" or "1biii", but the loops must operate on numeric quantities. To do this, the loop variables (primary, secondary, and tertiary) are numeric, and we rely on template:boiler to convert them to the form "1biii". For the secondary requirements this is done with this fragment:
- {{#vardefine:reqnum|{{boiler|{{#var:primary}}|{{#var:secondary}}}}}}
and for the tertiary:
- {{#vardefine:reqnum|{{boiler|{{#var:primary}}|{{#var:secondary}}|{{#var:tertiary}}}}}}
Once the while condition has been specified, we have the body to execute when the condition is true. This is simply:
- {{reqreqlink|page={{#var:landing}}|num={{#var:reqnum}}|dispreq=<li>}}<li/>
plus the loop variable incrementer:
- {{#vardefine:tertiary|{{#expr: {{#var:tertiary}} + 1 }} }}
Note that the "dispreq" parameter to reqreqlink is simply an html list element.
Each loop is nested inside an order list tag <ol>, and the tag speficies how the list elements should be rendered. For the primary loop, we rely on the default of decimal. For the secondary we specify <ol style="list-style-type:lower-alpha">, and for the tertiary <style="list-style-type:lower-roman">
template:reqreqlink returns a link to an anchor within the answer key (created by template:ansreq.
Bugs
This template has problems rendering honors with unconventional requirement numbering. It returns nothing for Abseiling, for example, and I have no intention of fixing this. It would be far easier to hand-craft the TOC for that honor if we choose to give it one.
Example
{{AKTOC|page=AY Honors/Map and Compass}}
- The Map
- Know the following:
- What is a topographical map?
- What is found on a topographical map?
- Give three uses of a topographical map.
- What is an orthophoto map?
- Be able to recognize twenty signs and symbols found on a topographical map, giving some in each of the following categories:
- Know and explain the following as they relate to elevation:
- Elevation.
- Contour interval.
- Ground formations (Valey, Ridge, Spur, Bluff or Cliff, Saddle, Sholder, Escarpment, Knoll, Brow) defined by their contour lines
- Know and explain the following as they relate to distance:
- Know and explain the following as they relate to a map grid system:
- Know and explain the following in relation to map reading:
- The Compass
- What are the eight major points of the compass and their bearings?
- Identify the type of compass most popular with bushwalkers.
- Know the parts of an orienteering compass.
- Know and explain the following as they relate to Grid Bearings and Magnetic Bearings:
- What are Bearings?
- How to calculate Grid Bearings from the map
- How to convert a Grid Bearing to a Magnetic Bearing
- How to convert a Magnetic Bearing to a Grid Bearing
- How to take and march on a Magnetic Bearing
- What is Slipping and how to correct for it?
- How to take a back bearing
- Know and explain the following in relation to Resection:
- Know and explain how to Orient your map by:
- Direction without the aid of a Compass
- Practical
- Demonstrate how to:
- Read six figure Grid Refences. Refer to Requirement 1.6c.
- Calculate a Grid Bearing from the map. Refer to Requirement 2.4b.
- Convert Grid Bearing to a Magnetic Bearing. Refer to Requirement 2.4c.
- Take a Magnetic Bearing. Refer to Requirement 2.4c
- Locate a position using Resection. Refer to Requirement 2.5
- Navigate to a target feature using a Magnetic Bearing. Refer Requirement 2.4c
- Prove your ability in the use of a map and compass by following a cross-country course with at least ten given readings or control points.