Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 4.2.x will end 22 April 2024 (12 months).
  • Bug fixes for security issues in 4.2.x will end 7 October 2024 (18 months).
  • PHP version: minimum PHP 8.0.0 Note: minimum PHP version has increased since Moodle 4.1. PHP 8.1.x is supported too.

Differences Between: [Versions 310 and 402] [Versions 311 and 402] [Versions 39 and 402] [Versions 400 and 402] [Versions 401 and 402]

   1  <?php
   2  
   3  namespace IMSGlobal\LTI\ToolProvider\MediaType;
   4  use IMSGlobal\LTI\ToolProvider\ToolProvider;
   5  
   6  /**
   7   * Class to represent an LTI Tool Profile
   8   *
   9   * @author  Stephen P Vickers <svickers@imsglobal.org>
  10   * @copyright  IMS Global Learning Consortium Inc
  11   * @date  2016
  12   * @version  3.0.0
  13   * @license  GNU Lesser General Public License, version 3 (<http://www.gnu.org/licenses/lgpl.html>)
  14   */
  15  #[\AllowDynamicProperties]
  16  class ToolProfile
  17  {
  18  
  19      public $product_instance;
  20  
  21  /**
  22   * Class constructor.
  23   *
  24   * @param ToolProvider $toolProvider   Tool Provider object
  25   */
  26      function __construct($toolProvider)
  27      {
  28  
  29          $this->lti_version = 'LTI-2p0';
  30  
  31          if (!empty($toolProvider->product)) {
  32              $this->product_instance = new \stdClass;
  33          }
  34          if (!empty($toolProvider->product->id)) {
  35              $this->product_instance->guid = $toolProvider->product->id;
  36          }
  37          if (!empty($toolProvider->product->name)) {
  38              $this->product_instance->product_info = new \stdClass;
  39              $this->product_instance->product_info->product_name = new \stdClass;
  40              $this->product_instance->product_info->product_name->default_value = $toolProvider->product->name;
  41              $this->product_instance->product_info->product_name->key = 'tool.name';
  42          }
  43          if (!empty($toolProvider->product->description)) {
  44              $this->product_instance->product_info->description = new \stdClass;
  45              $this->product_instance->product_info->description->default_value = $toolProvider->product->description;
  46              $this->product_instance->product_info->description->key = 'tool.description';
  47          }
  48          if (!empty($toolProvider->product->url)) {
  49              $this->product_instance->guid = $toolProvider->product->url;
  50          }
  51          if (!empty($toolProvider->product->version)) {
  52              $this->product_instance->product_info->product_version = $toolProvider->product->version;
  53          }
  54          if (!empty($toolProvider->vendor)) {
  55              $this->product_instance->product_info->product_family = new \stdClass;
  56              $this->product_instance->product_info->product_family->vendor = new \stdClass;
  57          }
  58          if (!empty($toolProvider->vendor->id)) {
  59              $this->product_instance->product_info->product_family->vendor->code = $toolProvider->vendor->id;
  60          }
  61          if (!empty($toolProvider->vendor->name)) {
  62              $this->product_instance->product_info->product_family->vendor->vendor_name = new \stdClass;
  63              $this->product_instance->product_info->product_family->vendor->vendor_name->default_value = $toolProvider->vendor->name;
  64              $this->product_instance->product_info->product_family->vendor->vendor_name->key = 'tool.vendor.name';
  65          }
  66          if (!empty($toolProvider->vendor->description)) {
  67              $this->product_instance->product_info->product_family->vendor->description = new \stdClass;
  68              $this->product_instance->product_info->product_family->vendor->description->default_value = $toolProvider->vendor->description;
  69              $this->product_instance->product_info->product_family->vendor->description->key = 'tool.vendor.description';
  70          }
  71          if (!empty($toolProvider->vendor->url)) {
  72              $this->product_instance->product_info->product_family->vendor->website = $toolProvider->vendor->url;
  73          }
  74          if (!empty($toolProvider->vendor->timestamp)) {
  75              $this->product_instance->product_info->product_family->vendor->timestamp = date('Y-m-d\TH:i:sP', $toolProvider->vendor->timestamp);
  76          }
  77  
  78          $this->resource_handler = array();
  79          foreach ($toolProvider->resourceHandlers as $resourceHandler) {
  80              $this->resource_handler[] = new ResourceHandler($toolProvider, $resourceHandler);
  81          }
  82          if (!empty($toolProvider->baseUrl)) {
  83              $this->base_url_choice = array();
  84              $this->base_url_choice[] = new \stdClass;
  85              $this->base_url_choice[0]->default_base_url = $toolProvider->baseUrl;
  86          }
  87  
  88      }
  89  
  90  }