Search moodle.org's
Developer Documentation

See Release Notes
Long Term Support Release

  • Bug fixes for general core bugs in 4.1.x will end 13 November 2023 (12 months).
  • Bug fixes for security issues in 4.1.x will end 10 November 2025 (36 months).
  • PHP version: minimum PHP 7.4.0 Note: minimum PHP version has increased since Moodle 4.0. PHP 8.0.x is supported too.

Differences Between: [Versions 401 and 402] [Versions 401 and 403]

   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  class ToolProfile
  16  {
  17  
  18      public $product_instance;
  19  
  20  /**
  21   * Class constructor.
  22   *
  23   * @param ToolProvider $toolProvider   Tool Provider object
  24   */
  25      function __construct($toolProvider)
  26      {
  27  
  28          $this->lti_version = 'LTI-2p0';
  29  
  30          if (!empty($toolProvider->product)) {
  31              $this->product_instance = new \stdClass;
  32          }
  33          if (!empty($toolProvider->product->id)) {
  34              $this->product_instance->guid = $toolProvider->product->id;
  35          }
  36          if (!empty($toolProvider->product->name)) {
  37              $this->product_instance->product_info = new \stdClass;
  38              $this->product_instance->product_info->product_name = new \stdClass;
  39              $this->product_instance->product_info->product_name->default_value = $toolProvider->product->name;
  40              $this->product_instance->product_info->product_name->key = 'tool.name';
  41          }
  42          if (!empty($toolProvider->product->description)) {
  43              $this->product_instance->product_info->description = new \stdClass;
  44              $this->product_instance->product_info->description->default_value = $toolProvider->product->description;
  45              $this->product_instance->product_info->description->key = 'tool.description';
  46          }
  47          if (!empty($toolProvider->product->url)) {
  48              $this->product_instance->guid = $toolProvider->product->url;
  49          }
  50          if (!empty($toolProvider->product->version)) {
  51              $this->product_instance->product_info->product_version = $toolProvider->product->version;
  52          }
  53          if (!empty($toolProvider->vendor)) {
  54              $this->product_instance->product_info->product_family = new \stdClass;
  55              $this->product_instance->product_info->product_family->vendor = new \stdClass;
  56          }
  57          if (!empty($toolProvider->vendor->id)) {
  58              $this->product_instance->product_info->product_family->vendor->code = $toolProvider->vendor->id;
  59          }
  60          if (!empty($toolProvider->vendor->name)) {
  61              $this->product_instance->product_info->product_family->vendor->vendor_name = new \stdClass;
  62              $this->product_instance->product_info->product_family->vendor->vendor_name->default_value = $toolProvider->vendor->name;
  63              $this->product_instance->product_info->product_family->vendor->vendor_name->key = 'tool.vendor.name';
  64          }
  65          if (!empty($toolProvider->vendor->description)) {
  66              $this->product_instance->product_info->product_family->vendor->description = new \stdClass;
  67              $this->product_instance->product_info->product_family->vendor->description->default_value = $toolProvider->vendor->description;
  68              $this->product_instance->product_info->product_family->vendor->description->key = 'tool.vendor.description';
  69          }
  70          if (!empty($toolProvider->vendor->url)) {
  71              $this->product_instance->product_info->product_family->vendor->website = $toolProvider->vendor->url;
  72          }
  73          if (!empty($toolProvider->vendor->timestamp)) {
  74              $this->product_instance->product_info->product_family->vendor->timestamp = date('Y-m-d\TH:i:sP', $toolProvider->vendor->timestamp);
  75          }
  76  
  77          $this->resource_handler = array();
  78          foreach ($toolProvider->resourceHandlers as $resourceHandler) {
  79              $this->resource_handler[] = new ResourceHandler($toolProvider, $resourceHandler);
  80          }
  81          if (!empty($toolProvider->baseUrl)) {
  82              $this->base_url_choice = array();
  83              $this->base_url_choice[] = new \stdClass;
  84              $this->base_url_choice[0]->default_base_url = $toolProvider->baseUrl;
  85          }
  86  
  87      }
  88  
  89  }