Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 4.0.x will end 8 May 2023 (12 months).
  • Bug fixes for security issues in 4.0.x will end 13 November 2023 (18 months).
  • PHP version: minimum PHP 7.3.0 Note: the minimum PHP version has increased since Moodle 3.10. PHP 7.4.x is also supported.

xAPI LRS IRI values generator.

Copyright: 2020 Ferran Recio
License: http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
File Size: 93 lines (3 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 1 class

iri:: (3 methods):
  generate()
  extract()
  check()


Class: iri  - X-Ref

Class to translate Moodle objects to xAPI elements.

generate(string $value, string $type = null)   X-Ref
Generate a valid IRI element from a $value and an optional $type.

Verbs and Objects in xAPI are in IRI format. This function could get
a valid IRI value (and will return without modifiyng it) or a simple
string and a type and generate a fake IRI valir for any xAPI statement.

return: string a valid IRI value
param: string $value a valid IRI value or any string
param: string|null $type if none passed $type will be 'element'

extract(string $value, string $type = null)   X-Ref
Try to extract the original value from an IRI.

If a real IRI value is passed, it will return it without any change. If a
fake IRI is passed (generated by iri::generate)
it will try to extract the original value.

return: string the original value used in iri::generate.
param: string $value the currewnt IRI value.
param: string|null $type if $value is a fake IRI, the $type must be provided.

check(string $value)   X-Ref
Check if a $value could be a valid IRI or not.

return: bool if the $value could be an IRI.
param: string $value the currewnt IRI value.