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.

Differences Between: [Versions 311 and 402] [Versions 311 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  }