Module:Mooc/IndexParser/doc

This module is part of the MOOC interface. The index parser is a central script of the MOOC module. It parses the MOOC index and creates a Lua object holding the single MOOC items along with their meta data stored in the index.

=Instance functions=

parseIndexOverview(indexPlain, rootPath)
Parses the MOOC index and extracts the MOOC root item in order to display an overview page.

Parameters: Returns:
 * 1)   indexPlain: MOOC index content
 * 2)   rootPath: title of the MOOC index page
 * table t with
 * t.item: MOOC root item

parseIndex(indexPlain, itemPath, rootPath)
Parses the MOOC index and extracts the MOOC item you are searching for (aka. target item).

Parameters: Returns:
 * 1)   indexPlain: MOOC index content
 * 2)   itemPath: path of the target item
 * 3)   rootPath: title of the MOOC index page
 * table t with
 * t.navigation: MOOC root item
 * t.item: target item itself (may be  if the item was not found)
 * t.parent: direct parent of the target item
 * t.previous: item preceding the target item (may be  if first item in its context)
 * t.next: item following the target item (may be  if last item in its context)

=Local functions=

splitLines(text)
Splits a text into its single lines.

Parameters: Returns:
 * 1)   stringValue: String that will be splitted up into single lines
 * table containing the single lines

splitPath(itemPath)
Splits an item path into its single parts.

Parameters: Returns:
 * 1)   itemPath: item path with its single parts separated by
 * 1)   item name (last part of the path)
 * 2)  table containing the single parts

getLevel(itemHeaderLine)
Calculates the level of an item according to the number of heading symbols  in it's header line. Q: This is a copy of, why don't we use it?

Parameters: Returns:
 * 1)   itemHeaderLine: header line of the item
 * item's level if the line is an item header
 * zero otherwise

isItem(header, itemName, itemType)
Checks if a header represents a certain item you search for.

Parameters: Returns:
 * 1)   header: header of an item
 * 2)   itemName: name of the item searched for
 * 3)   itemType: type of the item searched for
 * if the header is the item searched for
 * otherwise

loadParam(textLines, iParamStart)
Loads a parameter (aka. meta data entry) from the index.

Parameters: Returns:
 * 1)   textLines: MOOC index lines
 * 2)   iParamStart: index of the (first) line the parameter declaration occupies
 * table t with
 * t.name: parameter key
 * t.value: parameter value
 * t.iEnd: last line the parameter declaration occupies
 * if the line did not contain a parameter (or is malformed)

loadParams(textLines, iItemStart)
Loads all parameters of an item.

Parameters: Returns:
 * 1)   textLines: MOOC index lines
 * 2)   iItemStart: index of the (first) line the item occupies
 * 1)   table containing the parameter values loaded from the index, accessible using the parameter key
 * 2)   index of the last line the item occupies

extractItem(textLines, iItemStart, parent, maxLevel, section)
Extracts a MOOC item from the index including its meta data and all children up to the maximum level defined.

Parameters: Returns:
 * 1)   textLines: MOOC index lines
 * 2)   iItemStart: index of the (first) line the item occupies
 * 3)   parent: parental MOOC item
 * 4)   maxLevel: maximum item level that will be extracted, children at deeper level will be ignored
 * 5)   section: section number of the previous item
 * 1)   item object extracted from the index
 * 2)   index of the last line the item occupies
 * 3)   highest section number in use

extractIndex(baseItem, searchPath, searchLevel)
Extract the item objects related to a certain MOOC item you are searching for (aka. target item).

Parameters: Returns:
 * 1)   baseItem: any parental item of the target item
 * 2)   searchPath: path of the target item
 * 3)   searchLevel: current item level searching at
 * table t with
 * t.item: target item itself (may be  if the item was not found)
 * t.parent: direct parent of the target item
 * t.previous: item preceding the target item (may be  if first item in its context)
 * t.next: item following the target item (may be  if last item in its context)