| 1 |
efrain |
1 |
<?php
|
|
|
2 |
|
|
|
3 |
namespace IMSGlobal\LTI\ToolProvider\MediaType;
|
|
|
4 |
|
|
|
5 |
/**
|
|
|
6 |
* Class to represent an LTI Message
|
|
|
7 |
*
|
|
|
8 |
* @author Stephen P Vickers <svickers@imsglobal.org>
|
|
|
9 |
* @copyright IMS Global Learning Consortium Inc
|
|
|
10 |
* @date 2016
|
|
|
11 |
* @version 3.0.0
|
|
|
12 |
* @license GNU Lesser General Public License, version 3 (<http://www.gnu.org/licenses/lgpl.html>)
|
|
|
13 |
*/
|
|
|
14 |
#[\AllowDynamicProperties]
|
|
|
15 |
class Message
|
|
|
16 |
{
|
|
|
17 |
|
|
|
18 |
/**
|
|
|
19 |
* Class constructor.
|
|
|
20 |
*
|
|
|
21 |
* @param Message $message Message object
|
|
|
22 |
* @param array $capabilitiesOffered Capabilities offered
|
|
|
23 |
*/
|
|
|
24 |
function __construct($message, $capabilitiesOffered)
|
|
|
25 |
{
|
|
|
26 |
|
|
|
27 |
$this->message_type = $message->type;
|
|
|
28 |
$this->path = $message->path;
|
|
|
29 |
$this->enabled_capability = array();
|
|
|
30 |
foreach ($message->capabilities as $capability) {
|
|
|
31 |
if (in_array($capability, $capabilitiesOffered)) {
|
|
|
32 |
$this->enabled_capability[] = $capability;
|
|
|
33 |
}
|
|
|
34 |
}
|
|
|
35 |
$this->parameter = array();
|
|
|
36 |
foreach ($message->constants as $name => $value) {
|
|
|
37 |
$parameter = new \stdClass;
|
|
|
38 |
$parameter->name = $name;
|
|
|
39 |
$parameter->fixed = $value;
|
|
|
40 |
$this->parameter[] = $parameter;
|
|
|
41 |
}
|
|
|
42 |
foreach ($message->variables as $name => $value) {
|
|
|
43 |
if (in_array($value, $capabilitiesOffered)) {
|
|
|
44 |
$parameter = new \stdClass;
|
|
|
45 |
$parameter->name = $name;
|
|
|
46 |
$parameter->variable = $value;
|
|
|
47 |
$this->parameter[] = $parameter;
|
|
|
48 |
}
|
|
|
49 |
}
|
|
|
50 |
|
|
|
51 |
}
|
|
|
52 |
|
|
|
53 |
}
|