Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 3.11.x will end 14 Nov 2022 (12 months plus 6 months extension).
  • Bug fixes for security issues in 3.11.x will end 13 Nov 2023 (18 months plus 12 months extension).
  • PHP version: minimum PHP 7.3.0 Note: minimum PHP version has increased since Moodle 3.10. PHP 7.4.x is supported too.

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.

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

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.

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

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

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