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  use IMSGlobal\LTI\Profile\ResourceHandler as ProfileResourceHandler;
   6  
   7  /**
   8   * Class to represent an LTI Resource Handler
   9   *
  10   * @author  Stephen P Vickers <svickers@imsglobal.org>
  11   * @copyright  IMS Global Learning Consortium Inc
  12   * @date  2016
  13   * @version  3.0.0
  14   * @license  GNU Lesser General Public License, version 3 (<http://www.gnu.org/licenses/lgpl.html>)
  15   */
  16  class ResourceHandler
  17  {
  18  
  19  /**
  20   * Class constructor.
  21   *
  22   * @param ToolProvider $toolProvider   Tool Provider object
  23   * @param ProfileResourceHandler $resourceHandler   Resource handler object
  24   */
  25      function __construct($toolProvider, $resourceHandler)
  26      {
  27  
  28          $this->resource_type = new \stdClass;
  29          $this->resource_type->code = $resourceHandler->item->id;
  30          $this->resource_name = new \stdClass;
  31          $this->resource_name->default_value = $resourceHandler->item->name;
  32          $this->resource_name->key = "{$resourceHandler->item->id}.resource.name";
  33          $this->description = new \stdClass;
  34          $this->description->default_value = $resourceHandler->item->description;
  35          $this->description->key = "{$resourceHandler->item->id}.resource.description";
  36          $this->icon_info = new \stdClass;
  37          $this->icon_info->default_location = new \stdClass;
  38          $this->icon_info->default_location->path = $resourceHandler->icon;
  39          $this->icon_info->key = "{$resourceHandler->item->id}.icon.path";
  40          $this->message = array();
  41          foreach ($resourceHandler->requiredMessages as $message) {
  42              $this->message[] = new Message($message, $toolProvider->consumer->profile->capability_offered);
  43          }
  44          foreach ($resourceHandler->optionalMessages as $message) {
  45              if (in_array($message->type, $toolProvider->consumer->profile->capability_offered)) {
  46                  $this->message[] = new Message($message, $toolProvider->consumer->profile->capability_offered);
  47              }
  48          }
  49  
  50      }
  51  
  52  }