Modulo:Mooc/IndexParser/man
Questa è la pagina di documentazione per Modulo:Mooc/IndexParser
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
[modifica]parseIndexOverview(indexPlain, rootPath)
[modifica]Parses the MOOC index and extracts the MOOC root item in order to display an overview page.
Parameters:
StringindexPlain: MOOC index contentStringrootPath: title of the MOOC index page
Returns:
Tabletable t withMooc/Data/Itemt.item: MOOC root item
parseIndex(indexPlain, itemPath, rootPath)
[modifica]Parses the MOOC index and extracts the MOOC item you are searching for (aka. target item).
Parameters:
StringindexPlain: MOOC index contentStringitemPath: path of the target itemStringrootPath: title of the MOOC index page
Returns:
Tabletable t withMooc/Data/Itemt.navigation: MOOC root itemMooc/Data/Itemt.item: target item itself (may benilif the item was not found)Mooc/Data/Itemt.parent: direct parent of the target itemMooc/Data/Itemt.previous: item preceding the target item (may benilif first item in its context)Mooc/Data/Itemt.next: item following the target item (may benilif last item in its context)
Local functions
[modifica]splitLines(text)
[modifica]Splits a text into its single lines.
Parameters:
StringstringValue: String that will be splitted up into single lines
Returns:
Table<String>table containing the single lines
splitPath(itemPath)
[modifica]Splits an item path into its single parts.
Parameters:
StringitemPath: item path with its single parts separated by/
Returns:
Stringitem name (last part of the path)Table<String>table containing the single parts
getLevel(itemHeaderLine)
[modifica]Calculates the level of an item according to the number of heading symbols = in it's header line.
Q: This is a copy of Mooc/Data/Item.getLevel, why don't we use it?
Parameters:
StringitemHeaderLine: header line of the item
Returns:
intitem's level if the line is an item headerintzero otherwise
isItem(header, itemName, itemType)
[modifica]Checks if a header represents a certain item you search for.
Parameters:
Mooc/Data/Item.Headerheader: header of an itemStringitemName: name of the item searched forStringitemType: type of the item searched for
Returns:
trueif the header is the item searched forfalseotherwise
loadParam(textLines, iParamStart)
[modifica]Loads a parameter (aka. meta data entry) from the index.
Parameters:
Table<String>textLines: MOOC index linesintiParamStart: index of the (first) line the parameter declaration occupies
Returns:
Tabletable t withStringt.name: parameter keyStringt.value: parameter valueintt.iEnd: last line the parameter declaration occupies
nilif the line did not contain a parameter (or is malformed)
loadParams(textLines, iItemStart)
[modifica]Loads all parameters of an item.
Parameters:
Table<String>textLines: MOOC index linesintiItemStart: index of the (first) line the item occupies
Returns:
Table<String, String>table containing the parameter values loaded from the index, accessible using the parameter keyintindex of the last line the item occupies
extractItem(textLines, iItemStart, parent, maxLevel, section)
[modifica]Extracts a MOOC item from the index including its meta data and all children up to the maximum level defined.
Parameters:
Table<String>textLines: MOOC index linesintiItemStart: index of the (first) line the item occupiesMooc/Data/Itemparent: parental MOOC itemintmaxLevel: maximum item level that will be extracted, children at deeper level will be ignoredintsection: section number of the previous item
Returns:
Mooc/Data/Itemitem object extracted from the indexintindex of the last line the item occupiesinthighest section number in use
extractIndex(baseItem, searchPath, searchLevel)
[modifica]Extract the item objects related to a certain MOOC item you are searching for (aka. target item).
Parameters:
Mooc/Data/ItembaseItem: any parental item of the target itemStringsearchPath: path of the target itemintsearchLevel: current item level searching at
Returns:
Tabletable t withMooc/Data/Itemt.item: target item itself (may benilif the item was not found)Mooc/Data/Itemt.parent: direct parent of the target itemMooc/Data/Itemt.previous: item preceding the target item (may benilif first item in its context)Mooc/Data/Itemt.next: item following the target item (may benilif last item in its context)