Proyectos de Subversion Moodle

Rev

| Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
1 efrain 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
#[\AllowDynamicProperties]
17
class ResourceHandler
18
{
19
 
20
/**
21
 * Class constructor.
22
 *
23
 * @param ToolProvider $toolProvider   Tool Provider object
24
 * @param ProfileResourceHandler $resourceHandler   Resource handler object
25
 */
26
    function __construct($toolProvider, $resourceHandler)
27
    {
28
 
29
        $this->resource_type = new \stdClass;
30
        $this->resource_type->code = $resourceHandler->item->id;
31
        $this->resource_name = new \stdClass;
32
        $this->resource_name->default_value = $resourceHandler->item->name;
33
        $this->resource_name->key = "{$resourceHandler->item->id}.resource.name";
34
        $this->description = new \stdClass;
35
        $this->description->default_value = $resourceHandler->item->description;
36
        $this->description->key = "{$resourceHandler->item->id}.resource.description";
37
        $this->icon_info = new \stdClass;
38
        $this->icon_info->default_location = new \stdClass;
39
        $this->icon_info->default_location->path = $resourceHandler->icon;
40
        $this->icon_info->key = "{$resourceHandler->item->id}.icon.path";
41
        $this->message = array();
42
        foreach ($resourceHandler->requiredMessages as $message) {
43
            $this->message[] = new Message($message, $toolProvider->consumer->profile->capability_offered);
44
        }
45
        foreach ($resourceHandler->optionalMessages as $message) {
46
            if (in_array($message->type, $toolProvider->consumer->profile->capability_offered)) {
47
                $this->message[] = new Message($message, $toolProvider->consumer->profile->capability_offered);
48
            }
49
        }
50
 
51
    }
52
 
53
}