Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
11 / 11
100.00% covered (success)
100.00%
9 / 9
CRAP
100.00% covered (success)
100.00%
1 / 1
ImsManifestMetadataValue
100.00% covered (success)
100.00%
11 / 11
100.00% covered (success)
100.00%
9 / 9
9
100.00% covered (success)
100.00%
1 / 1
 __construct
100.00% covered (success)
100.00%
3 / 3
100.00% covered (success)
100.00%
1 / 1
1
 getPath
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 getLanguage
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 getResourceIdentifier
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 getResourceType
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 getResourceHref
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 getValue
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 setResourceHref
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 setResourceType
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
1<?php
2
3/**
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; under version 2
7 * of the License (non-upgradable).
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
17 *
18 * Copyright (c) 2014 (original work) Open Assessment Technologies SA (under the project TAO-PRODUCT);
19 *
20 */
21
22namespace oat\taoQtiItem\model\qti\metadata\imsManifest;
23
24use oat\taoQtiItem\model\qti\metadata\simple\SimpleMetadataValue;
25
26/**
27 * This implementation of MetadataValue represents MetadataValue objects in an IMS Manifest context.
28 *
29 * To illustrate what an instance of a ImsManifestMetadataValue represents, have a look at the IMS Manifest located
30 * at 'http://www.imsglobal.org/question/qti_v2p0/examples/mdexample/imsmanifest.xml'. This manifest describes a single
31 * QTI Item with metadata.
32 *
33 * As an example, the identifier metadata value 'qti_v2_item_01' can by represented by an implementation
34 * of the MetadataValue interface returning the following information. Please note that the terms
35 * "Path", "Resource Identifier", "Resource Type" and "Resource Hypertext Reference" in the example below are
36 * described in depth in the comments about the methods of this interface.
37 *
38 * * A "Path" of 'http://www.imsglobal.org/xsd/imsmd_v1p2#lom' -> 'http://www.imsglobal.org/xsd/imsmd_v1p2#general'
39 *   -> 'http://www.imsglobal.org/xsd/imsmd_v1p2#identifier'
40 * * No particular "Language'
41 * * 'choice' as its "Resource Identifier"
42 * * 'imsqti_item_xmlv2p0' as its "Resource Type"
43 * * 'choice.xml' as its "Resource Hypertext Reference"
44 *
45 * Please see the description of the methods composing this interface for more information.
46 *
47 * @author Antoine Robin <antoine.robin@vesperiagroup.com>
48 * @author Jérôme Bogaerts <jerome@taotesting.com>
49 */
50class ImsManifestMetadataValue extends SimpleMetadataValue
51{
52    private $resourceType;
53    private $resourceHref;
54
55    /**
56     * Create a new ImsManifestMetadataValue object.
57     *
58     */
59    public function __construct($resourceIdentifier, $resourceType, $resourceHref, $path, $value, $language = '')
60    {
61        parent::__construct($resourceIdentifier, $path, $value, $language);
62        $this->setResourceType($resourceType);
63        $this->setResourceHref($resourceHref);
64    }
65
66    /**
67     * Returns an array of strings representing the path to a Metadata Value within
68     * an IMS Manifest file.
69     *
70     * As an example, the following array represents the path to the "imsmd:lom->general->identifier" metadata
71     * value 'qti_v2_item_01' in the IMS Manifest example located at
72     * http://www.imsglobal.org/question/qti_v2p0/examples/mdexample/imsmanifest.xml.
73     *
74     * <code>
75     *     array(
76     *         'http://www.imsglobal.org/xsd/imsmd_v1p2#lom',
77     *         'http://www.imsglobal.org/xsd/imsmd_v1p2#general',
78     *         'http://www.imsglobal.org/xsd/imsmd_v1p2#identifier'
79     *     )
80     * </code>
81     *
82     *
83     * Each entry of the array is a "Path Component" e.g. http://www.imsglobal.org/xsd/imsmd_v1p2#lom in the example
84     * above. A Path Component is composed of 2 values separated by a # (sharp) character.
85     *
86     * * The first value is called the "Base". It is the namespace URI of the related XML tag withing the IMS Manifest
87     *   file.
88     * * The second value is called the "Segment". It is the intrinsic XML tag name.
89     *
90     * In the IMS Manifest example located at
91     * http://www.imsglobal.org/question/qti_v2p0/examples/mdexample/imsmanifest.xml, the Path Component
92     * 'http://www.imsglobal.org/xsd/imsmd_v1p2#lom' correspond to the <imsmd:lom> tag where 'imsmd' prefix resolves
93     * the 'http://www.imsglobal.org/xsd/imsmd_v1p2' namespace.
94     *
95     *
96     * @return array An array of strings representing the descriptive path to the metadata attribute.
97     * @see http://www.imsglobal.org/question/qti_v2p0/examples/mdexample/imsmanifest.xml IMS Manifest example.
98     */
99    public function getPath()
100    {
101        return parent::getPath();
102    }
103
104    /**
105     * Get the language, if specified, of the Metadata value. In the IMS Manifest example located at
106     * http://www.imsglobal.org/question/qti_v2p0/examples/mdexample/imsmanifest.xml, the metadata value with
107     * the given path
108     *
109     * * 'http://www.imsglobal.org/xsd/imsmd_v1p2#lom'
110     * * 'http://www.imsglobal.org/xsd/imsmd_v1p2#general'
111     * * 'http://www.imsglobal.org/xsd/imsmd_v1p2#description'
112     * * 'http://www.imsglobal.org/xsd/imsmd_v1p2#langstring'
113     *
114     * with an intrinsic value of 'This is a dummy item', has language 'en' (English), because of the use of the
115     * existence of the xml:lang attribute. The fact that this attribute is set to the node makes the metadata value
116     * to have a language.
117     *
118     * If a metadata value has no xml:lang defined, this method returns '' (empty string).
119     *
120     * @return string The language of this metadata value or an empty string.
121     * @see http://www.imsglobal.org/question/qti_v2p0/examples/mdexample/imsmanifest.xml IMS Manifest example.
122     */
123    public function getLanguage()
124    {
125        return parent::getLanguage();
126    }
127
128    /**
129     * Obtain the identifier of the <resource> this metadata value belongs to. As an example from
130     * the IMS Manifest file located at http://www.imsglobal.org/question/qti_v2p0/examples/mdexample/imsmanifest.xml,
131     * the metadata value with the given path
132     *
133     * * 'http://www.imsglobal.org/xsd/imsmd_v1p2#lom'
134     * * 'http://www.imsglobal.org/xsd/imsmd_v1p2#general'
135     * * 'http://www.imsglobal.org/xsd/imsmd_v1p2#identifier'
136     *
137     * belongs to resource with identifier 'choice', because its value is contained within the <resource>
138     * node with identifer 'choice'.
139     *
140     * @return string A resource identifier.
141     * @see http://www.imsglobal.org/question/qti_v2p0/examples/mdexample/imsmanifest.xml IMS Manifest example.
142     */
143    public function getResourceIdentifier()
144    {
145        return parent::getResourceIdentifier();
146    }
147
148    /**
149     * Obtain the type of the <resource> this metadata value belongs to. As an example from
150     * the IMS Manifest file located at http://www.imsglobal.org/question/qti_v2p0/examples/mdexample/imsmanifest.xml,
151     * the metadata value with the given path
152     *
153     * * 'http://www.imsglobal.org/xsd/imsmd_v1p2#lom'
154     * * 'http://www.imsglobal.org/xsd/imsmd_v1p2#general'
155     * * 'http://www.imsglobal.org/xsd/imsmd_v1p2#identifier'
156     *
157     * belongs to a resource with type 'imsqti_item_xmlv2p0', because its value is contained within a <resource>
158     * node with a type attribute that has a value of 'imsqti_item_xmlv2p0'.
159     *
160     * @return string A resource type.
161     * @see http://www.imsglobal.org/question/qti_v2p0/examples/mdexample/imsmanifest.xml IMS Manifest example.
162     */
163    public function getResourceType()
164    {
165        return $this->resourceType;
166    }
167
168    /**
169     * Obtain the hypertext reference of the <resource> this metadata value belongs to. As an example from
170     * the IMS Manifest file located at http://www.imsglobal.org/question/qti_v2p0/examples/mdexample/imsmanifest.xml,
171     * the metadata value with the given path
172     *
173     * * 'http://www.imsglobal.org/xsd/imsmd_v1p2#lom'
174     * * 'http://www.imsglobal.org/xsd/imsmd_v1p2#general'
175     * * 'http://www.imsglobal.org/xsd/imsmd_v1p2#identifier'
176     *
177     * belongs to a resource with href 'choice.xml', because its value is contained within a <resource>
178     * node with a href attribute that has a value of 'choice.xml'.
179     *
180     * @return string An hypertext reference.
181     * @see http://www.imsglobal.org/question/qti_v2p0/examples/mdexample/imsmanifest.xml IMS Manifest example.
182     */
183    public function getResourceHref()
184    {
185        return $this->resourceHref;
186    }
187
188    /**
189     * Obtain the intrinsic value of the metadata. As an example from
190     * the IMS Manifest file located at http://www.imsglobal.org/question/qti_v2p0/examples/mdexample/imsmanifest.xml,
191     * the metadata value with the given path
192     *
193     * * 'http://www.imsglobal.org/xsd/imsmd_v1p2#lom'
194     * * 'http://www.imsglobal.org/xsd/imsmd_v1p2#general'
195     * * 'http://www.imsglobal.org/xsd/imsmd_v1p2#identifier'
196     *
197     * is 'qti_v2_item_01'.
198     *
199     * If there is no actual value for this metadata (the node is empty), an empty string is returned.
200     *
201     * @return string A string
202     * @see http://www.imsglobal.org/question/qti_v2p0/examples/mdexample/imsmanifest.xml IMS Manifest example.
203     */
204    public function getValue()
205    {
206        return parent::getValue();
207    }
208
209    /**
210     * @param string $resourceHref
211     */
212    public function setResourceHref($resourceHref)
213    {
214        $this->resourceHref = $resourceHref;
215    }
216
217    /**
218     * @param string $resourceType
219     */
220    public function setResourceType($resourceType)
221    {
222        $this->resourceType = $resourceType;
223    }
224}