Vai al contenuto

Modulo:Mooc/IndexParser/man

Da Wikiversità, l'apprendimento libero.

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:

  1. String indexPlain: MOOC index content
  2. String rootPath: title of the MOOC index page

Returns:

  • Table table t with
    • Mooc/Data/Item t.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:

  1. String indexPlain: MOOC index content
  2. String itemPath: path of the target item
  3. String rootPath: title of the MOOC index page

Returns:

  • Table table t with
    • Mooc/Data/Item t.navigation: MOOC root item
    • Mooc/Data/Item t.item: target item itself (may be nil if the item was not found)
    • Mooc/Data/Item t.parent: direct parent of the target item
    • Mooc/Data/Item t.previous: item preceding the target item (may be nil if first item in its context)
    • Mooc/Data/Item t.next: item following the target item (may be nil if last item in its context)

Local functions

[modifica]

splitLines(text)

[modifica]

Splits a text into its single lines.

Parameters:

  1. String stringValue: 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:

  1. String itemPath: item path with its single parts separated by /

Returns:

  1. String item name (last part of the path)
  2. 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:

  1. String itemHeaderLine: header line of the item

Returns:

  • int item's level if the line is an item header
  • int zero otherwise

isItem(header, itemName, itemType)

[modifica]

Checks if a header represents a certain item you search for.

Parameters:

  1. Mooc/Data/Item.Header header: header of an item
  2. String itemName: name of the item searched for
  3. String itemType: type of the item searched for

Returns:

  • true if the header is the item searched for
  • false otherwise

loadParam(textLines, iParamStart)

[modifica]

Loads a parameter (aka. meta data entry) from the index.

Parameters:

  1. Table<String> textLines: MOOC index lines
  2. int iParamStart: index of the (first) line the parameter declaration occupies

Returns:

  • Table table t with
    • String t.name: parameter key
    • String t.value: parameter value
    • int t.iEnd: last line the parameter declaration occupies
  • nil if the line did not contain a parameter (or is malformed)

loadParams(textLines, iItemStart)

[modifica]

Loads all parameters of an item.

Parameters:

  1. Table<String> textLines: MOOC index lines
  2. int iItemStart: index of the (first) line the item occupies

Returns:

  1. Table<String, String> table containing the parameter values loaded from the index, accessible using the parameter key
  2. int index 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:

  1. Table<String> textLines: MOOC index lines
  2. int iItemStart: index of the (first) line the item occupies
  3. Mooc/Data/Item parent: parental MOOC item
  4. int maxLevel: maximum item level that will be extracted, children at deeper level will be ignored
  5. int section: section number of the previous item

Returns:

  1. Mooc/Data/Item item object extracted from the index
  2. int index of the last line the item occupies
  3. int highest 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:

  1. Mooc/Data/Item baseItem: any parental item of the target item
  2. String searchPath: path of the target item
  3. int searchLevel: current item level searching at

Returns:

  • Table table t with
    • Mooc/Data/Item t.item: target item itself (may be nil if the item was not found)
    • Mooc/Data/Item t.parent: direct parent of the target item
    • Mooc/Data/Item t.previous: item preceding the target item (may be nil if first item in its context)
    • Mooc/Data/Item t.next: item following the target item (may be nil if last item in its context)