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
modificaparseIndexOverview(indexPlain, rootPath)
modificaParses the MOOC index and extracts the MOOC root item in order to display an overview page.
Parameters:
String
indexPlain: MOOC index contentString
rootPath: title of the MOOC index page
Returns:
Table
table t withMooc/Data/Item
t.item: MOOC root item
parseIndex(indexPlain, itemPath, rootPath)
modificaParses the MOOC index and extracts the MOOC item you are searching for (aka. target item).
Parameters:
String
indexPlain: MOOC index contentString
itemPath: path of the target itemString
rootPath: title of the MOOC index page
Returns:
Table
table t withMooc/Data/Item
t.navigation: MOOC root itemMooc/Data/Item
t.item: target item itself (may benil
if the item was not found)Mooc/Data/Item
t.parent: direct parent of the target itemMooc/Data/Item
t.previous: item preceding the target item (may benil
if first item in its context)Mooc/Data/Item
t.next: item following the target item (may benil
if last item in its context)
Local functions
modificasplitLines(text)
modificaSplits a text into its single lines.
Parameters:
String
stringValue: String that will be splitted up into single lines
Returns:
Table<String>
table containing the single lines
splitPath(itemPath)
modificaSplits an item path into its single parts.
Parameters:
String
itemPath: item path with its single parts separated by/
Returns:
String
item name (last part of the path)Table<String>
table containing the single parts
getLevel(itemHeaderLine)
modificaCalculates 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:
String
itemHeaderLine: header line of the item
Returns:
int
item's level if the line is an item headerint
zero otherwise
isItem(header, itemName, itemType)
modificaChecks if a header represents a certain item you search for.
Parameters:
Mooc/Data/Item.Header
header: header of an itemString
itemName: name of the item searched forString
itemType: type of the item searched for
Returns:
true
if the header is the item searched forfalse
otherwise
loadParam(textLines, iParamStart)
modificaLoads a parameter (aka. meta data entry) from the index.
Parameters:
Table<String>
textLines: MOOC index linesint
iParamStart: index of the (first) line the parameter declaration occupies
Returns:
Table
table t withString
t.name: parameter keyString
t.value: parameter valueint
t.iEnd: last line the parameter declaration occupies
nil
if the line did not contain a parameter (or is malformed)
loadParams(textLines, iItemStart)
modificaLoads all parameters of an item.
Parameters:
Table<String>
textLines: MOOC index linesint
iItemStart: 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 keyint
index of the last line the item occupies
extractItem(textLines, iItemStart, parent, maxLevel, section)
modificaExtracts 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 linesint
iItemStart: index of the (first) line the item occupiesMooc/Data/Item
parent: parental MOOC itemint
maxLevel: maximum item level that will be extracted, children at deeper level will be ignoredint
section: section number of the previous item
Returns:
Mooc/Data/Item
item object extracted from the indexint
index of the last line the item occupiesint
highest section number in use
extractIndex(baseItem, searchPath, searchLevel)
modificaExtract the item objects related to a certain MOOC item you are searching for (aka. target item).
Parameters:
Mooc/Data/Item
baseItem: any parental item of the target itemString
searchPath: path of the target itemint
searchLevel: current item level searching at
Returns:
Table
table t withMooc/Data/Item
t.item: target item itself (may benil
if the item was not found)Mooc/Data/Item
t.parent: direct parent of the target itemMooc/Data/Item
t.previous: item preceding the target item (may benil
if first item in its context)Mooc/Data/Item
t.next: item following the target item (may benil
if last item in its context)