Note: You are currently viewing documentation for Moodle 2.4. Up-to-date documentation for the latest stable version of Moodle may be available here: Sharedresource Technical Developper Information.

Sharedresource Technical Developper Information

From MoodleDocs

Related Documentation

This documentation is related to the Sharedresource module

How it has been implemented

Coding and memory structures

Major orientation has been to convert the XML schema into a PHP structure that is strictely the expression of the XML organisation. This allows then to implement all data manipulation as PHP libraries.

Storage

Metadata is stored into a flatten storage in DB, unsing a single table. Metadata values are indexed by schema name (in case we have old data attached to another previously used schema), and by the element ID. Element ID reflects two things :

  • The metadata model element ID as the DC node index
  • The instance path for each model node, as many elements can admit multiple instances as a list.

For example : Lets see how multiple keywords are stored for LOM :

The model DC index for a keyword in LOM definition is 1.5 (we record it as 1_5). Although the parent element "General" (node 1) is a single element, the 1_5 (Keyword) element admits to be a list of multiple values. Say we add "moodle" and "documentation" as keywords, there are two records for this element in the storage table. Both records are using the unique available instance (0) for the parent node, and use their own value instance for the node corresponding to "Keyword".

Thus both storage records are :

id1 lom 1_5:0_0 moodle id2 lom 1_5:0_1 documentation


Metadata Plugin

A metadata plugin resides in a subdirectory of the mod/sharedresource/plugins folder. It will contain two main files plus the language locaisation files :

  • <plugin>.class.php : the main implementation of the metadata standard
  • xmlparser.php : a Saxon parser definition to get metadata information from a text metadata XML as input.