|
1
|
|
|
<?php |
|
2
|
|
|
/* For licensing terms, see /license.txt */ |
|
3
|
|
|
|
|
4
|
|
|
class Cc1p3Convert extends CcBase |
|
5
|
|
|
{ |
|
6
|
|
|
public const CC_TYPE_FORUM = 'imsdt_xmlv1p3'; |
|
7
|
|
|
public const CC_TYPE_QUIZ = 'imsqti_xmlv1p3/imscc_xmlv1p3/assessment'; |
|
8
|
|
|
public const CC_TYPE_QUESTION_BANK = 'imsqti_xmlv1p3/imscc_xmlv1p3/question-bank'; |
|
9
|
|
|
public const CC_TYPE_WEBLINK = 'imswl_xmlv1p3'; |
|
10
|
|
|
public const CC_TYPE_ASSOCIATED_CONTENT = 'associatedcontent/imscc_xmlv1p3/learning-application-resource'; |
|
11
|
|
|
public const CC_TYPE_WEBCONTENT = 'webcontent'; |
|
12
|
|
|
public const CC_TYPE_BASICLTI = 'imsbasiclti_xmlv1p3'; |
|
13
|
|
|
|
|
14
|
|
|
public static $namespaces = ['imscc' => 'http://www.imsglobal.org/xsd/imsccv1p3/imscp_v1p1', |
|
15
|
|
|
'lomimscc' => 'http://ltsc.ieee.org/xsd/imsccv1p3/LOM/manifest', |
|
16
|
|
|
'lom' => 'http://ltsc.ieee.org/xsd/imsccv1p3/LOM/resource', |
|
17
|
|
|
'xsi' => 'http://www.w3.org/2001/XMLSchema-instance', |
|
18
|
|
|
'cc' => 'http://www.imsglobal.org/xsd/imsccv1p3/imsccauth_v1p1', ]; |
|
19
|
|
|
|
|
20
|
|
|
public static $restypes = ['associatedcontent/imscc_xmlv1p3/learning-application-resource', 'webcontent']; |
|
21
|
|
|
public static $forumns = ['dt' => 'http://www.imsglobal.org/xsd/imsccv1p3/imsdt_v1p3']; |
|
22
|
|
|
public static $quizns = ['xmlns' => 'http://www.imsglobal.org/xsd/ims_qtiasiv1p2']; |
|
23
|
|
|
public static $resourcens = ['wl' => 'http://www.imsglobal.org/xsd/imsccv1p3/imswl_v1p3']; |
|
24
|
|
|
public static $basicltins = [ |
|
25
|
|
|
'xmlns' => 'http://www.imsglobal.org/xsd/imslticc_v1p0', |
|
26
|
|
|
'blti' => 'http://www.imsglobal.org/xsd/imsbasiclti_v1p0', |
|
27
|
|
|
'lticm' => 'http://www.imsglobal.org/xsd/imslticm_v1p0', |
|
28
|
|
|
'lticp' => 'http://www.imsglobal.org/xsd/imslticp_v1p0', |
|
29
|
|
|
]; |
|
30
|
|
|
|
|
31
|
|
|
public function __construct($path_to_manifest) |
|
32
|
|
|
{ |
|
33
|
|
|
parent::__construct($path_to_manifest); |
|
34
|
|
|
} |
|
35
|
|
|
|
|
36
|
|
|
/** |
|
37
|
|
|
* Scan the imsmanifest.xml structure to find elements to import to documents, links, forums, quizzes |
|
38
|
|
|
* @return void |
|
39
|
|
|
*/ |
|
40
|
|
|
public function generateImportData(): void |
|
41
|
|
|
{ |
|
42
|
|
|
$countInstances = 0; |
|
43
|
|
|
$xpath = static::newxPath(static::$manifest, static::$namespaces); |
|
44
|
|
|
// Scan for detached resources of type 'webcontent' |
|
45
|
|
|
$resources = $xpath->query('/imscc:manifest/imscc:resources/imscc:resource[@type="'.static::CC_TYPE_WEBCONTENT.'"]'); |
|
46
|
|
|
$this->createInstances($resources, 0, $countInstances); |
|
47
|
|
|
|
|
48
|
|
|
// Scan for organization items or resources that are tests (question banks) |
|
49
|
|
|
$items = $xpath->query('/imscc:manifest/imscc:organizations/imscc:organization/imscc:item | /imscc:manifest/imscc:resources/imscc:resource[@type="'.static::CC_TYPE_QUESTION_BANK.'"]'); |
|
50
|
|
|
$this->createInstances($items, 0,$countInstances); |
|
51
|
|
|
|
|
52
|
|
|
$resources = new Cc13Resource(); |
|
53
|
|
|
$forums = new Cc13Forum(); |
|
54
|
|
|
$quiz = new Cc13Quiz(); |
|
55
|
|
|
|
|
56
|
|
|
// Get the embedded XML files describing resources to import |
|
57
|
|
|
$documentValues = $resources->generateData('document'); |
|
58
|
|
|
$linkValues = $resources->generateData('link'); |
|
59
|
|
|
$forumValues = $forums->generateData(); |
|
60
|
|
|
$quizValues = $quiz->generateData(); |
|
61
|
|
|
|
|
62
|
|
|
if (!empty($forums) or !empty($quizValues) or !empty($documentValues)) { |
|
63
|
|
|
$courseInfo = api_get_course_info(); |
|
64
|
|
|
$sessionId = api_get_session_id(); |
|
65
|
|
|
$groupId = api_get_group_id(); |
|
66
|
|
|
$documentPath = api_get_path(SYS_COURSE_PATH).$courseInfo['directory'].'/document'; |
|
67
|
|
|
|
|
68
|
|
|
create_unexisting_directory( |
|
69
|
|
|
$courseInfo, |
|
70
|
|
|
api_get_user_id(), |
|
71
|
|
|
$sessionId, |
|
72
|
|
|
$groupId, |
|
73
|
|
|
null, |
|
74
|
|
|
$documentPath, |
|
75
|
|
|
'/commoncartridge', |
|
76
|
|
|
'Common Cartridge folder', |
|
77
|
|
|
0 |
|
78
|
|
|
); |
|
79
|
|
|
} |
|
80
|
|
|
|
|
81
|
|
|
// Import the resources, by type |
|
82
|
|
|
if (!empty($forums)) { |
|
83
|
|
|
$saved = $forums->storeForums($forumValues); |
|
84
|
|
|
} |
|
85
|
|
|
if (!empty($quizValues)) { |
|
86
|
|
|
$saved = $quiz->storeQuizzes($quizValues); |
|
87
|
|
|
} |
|
88
|
|
|
if (!empty($documentValues)) { |
|
89
|
|
|
$saved = $resources->storeDocuments($documentValues, static::$pathToManifestFolder); |
|
90
|
|
|
} |
|
91
|
|
|
if (!empty($linkValues)) { |
|
92
|
|
|
$saved = $resources->storeLinks($linkValues); |
|
93
|
|
|
} |
|
94
|
|
|
} |
|
95
|
|
|
} |
|
96
|
|
|
|