-
Notifications
You must be signed in to change notification settings - Fork 2
/
moodlemetadata.php
349 lines (315 loc) · 11.9 KB
/
moodlemetadata.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* This file maps several Moodle typical definitions (modules) to Metadata concepts (LOM based)
*
* @package mod_sharedresource
* @author Valery Fremaux <[email protected]>
* @copyright Valery Fremaux (activeprolearn.com)
* @license http://www.gnu.org/copyleft/gpl.html GNU Public License
*/
defined('MOODLE_INTERNAL') || die();
// This is used for a build_vcard utility function.
if (sharedresource_supports_feature() === 'pro') {
require_once($CFG->dirroot.'/local/sharedresources/pro/classes/file_importer_base.php');
}
// MODRESOURCETYPE addesses LOM 5_2 node (Learning Resource Type).
global $modresourcetypes;
$modresourcetypes = [
'advmindmap' => 'graph',
'assign' => 'exam',
'assignment' => 'exam',
'book' => 'lecture',
'certificate' => 'exam',
'checklist' => 'self assessment',
'choice' => 'questionnaire',
'customlabel' => 'narrative text',
'data' => 'table',
'etherpad' => 'narrative text',
'feedback' => 'questionnaire',
'flashcard' => 'self assessment',
'questionnaire' => 'questionnaire',
'folder' => 'lecture',
'glossary' => 'lecture',
'label' => 'narrative text',
'lesson' => 'lecture',
'magtest' => 'self assessment',
'mindmap' => 'graph',
'page' => 'narrative text,lecture',
'quiz' => 'exercice',
'resource' => 'narrative text,lecture',
'scorm' => 'lecture',
'sharedresource' => 'narrative text,lecture',
'survey' => 'questionnaire',
'techproject' => 'experimentation',
'tracker' => 'exercice',
'wiki' => 'narrative text,exercice',
'workshop' => 'exercice,experimentation' ];
// Allow completing from configuration file.
if (isset($CFG->additionalmodresourcetypes) && is_array($CFG->additionalmodresourcetypes)) {
$modresourcetypes = $modresourcetypes + $CFG->additionalmodresourcetypes;
}
// MODRESOURCETYPE addesses LOM 5_3 node (Learning Resource Type).
global $modinteractivitylevels;
$modinteractivitylevels = [
'advmindmap' => 'very high',
'assign' => 'medium',
'assignment' => 'medium',
'book' => 'very low',
'certificate' => 'low',
'checklist' => 'very high',
'choice' => 'medium',
'customlabel' => 'very low',
'data' => 'medium',
'etherpad' => 'very high',
'feedback' => 'high',
'flashcard' => 'high',
'questionnaire' => 'high',
'folder' => 'medium',
'glossary' => 'medium',
'label' => 'very low',
'lesson' => 'medium',
'magtest' => 'medium',
'mindmap' => 'very high',
'page' => 'low',
'quiz' => 'high',
'resource' => 'low',
'scorm' => 'medium',
'sharedresource' => 'low',
'survey' => 'medium',
'techproject' => 'very high',
'tracker' => 'very high',
'wiki' => 'very high',
'workshop' => 'very high' ];
// Allow completing from configuration file.
if (isset($CFG->additionalmodinteractivitylevel) && is_array($CFG->additionalmodinteractivitylevel)) {
$modinteractivitylevels = $modinteractivitylevels + $CFG->additionalmodinteractivitylevel;
}
// MODRESORUCETYPE addesses LOM 5_4 node (Learning Resource Type).
global $modsemanticdensities;
$modsemanticdensities = [
'advmindmap' => 'high',
'assign' => 'low',
'assignment' => 'low',
'book' => 'very high',
'certificate' => 'low',
'checklist' => 'low',
'choice' => 'low',
'customlabel' => 'low',
'data' => 'medium',
'etherpad' => 'medium',
'feedback' => 'low',
'flashcard' => 'low',
'questionnaire' => 'low',
'folder' => 'high',
'glossary' => 'high',
'label' => 'very low',
'lesson' => 'medium',
'magtest' => 'medium',
'mindmap' => 'high',
'page' => 'medium',
'quiz' => 'low',
'resource' => 'high',
'scorm' => 'high',
'sharedresource' => 'high',
'survey' => 'low',
'techproject' => 'very high',
'tracker' => 'high',
'wiki' => 'high',
'workshop' => 'high' ];
// Allow completing from configuration file.
if (isset($CFG->additionalmodsemanticdensity) && is_array($CFG->additionalmodsemanticdensity)) {
$modsemanticdensities = $modsemanticdensities + $CFG->additionalmodsemanticdensity;
}
// MODRESOURCETYPE addesses LOMFR 5_12 node (Learning Activity Type).
global $modlearningactivities;
/*
* animer, apprendre, collaborer, communiquer, coopérer, créer, échanger, expérimenter,
* lire, observer, organiser, produire, publier, rechercher, s\auto-former, s\exercer,
* s\informer, se former, simuler, s\évaluer.
*/
$modlearningactivities = [
'advmindmap' => 'collaborer,créer,organiser',
'assign' => 's\'évaluer',
'assignment' => 's\'évaluer',
'book' => 'lire,apprendre',
'certificate' => 's\'évaluer',
'checklist' => 'organiser,s\'informer',
'choice' => 'animer,échanger',
'customlabel' => 'lire,s\'informer',
'data' => 'organiser,publier,collaborer',
'etherpad' => 'collaborer,publier,échanger,collaborer',
'feedback' => 'communiquer',
'flashcard' => 'apprendre',
'questionnaire' => 'communiquer',
'glossary' => 'rechercher,collaborer,coopérer,publier',
'label' => 'lire,s\'informer',
'lesson' => 'apprendre',
'magtest' => 's\'évaluer,s\auto-former,se former',
'mindmap' => 'créer,organiser',
'page' => 'lire,se former',
'quiz' => 's\'évaluer,apprendre,s\'auto-former,s\'exercer',
'resource' => 'lire,apprendre',
'scorm' => 'se former,lire,s\'exercer',
'sharedresource' => 'lire,apprendre',
'survey' => 'communiquer',
'techproject' => 'expérimenter,organiser,produire',
'tracker' => 'produire,organiser',
'wiki' => 'coopérer,collaborer,publier',
'workshop' => 'apprendre,coopérer,expérimenter' ];
// MODDOCUMENTTYPE addesses LOMFR 1_9 node (Type de documents).
global $moddocumenttypes;
/*
* collection, ensemble de données, événement, image, image en mouvement, image fixe,
* logiciel, objet physique, ressource interactive, service, son, texte.
*/
$moddocumenttypes = [
'advmindmap' => 'ressource interactive',
'assign' => '',
'assignment' => '',
'book' => 'ensemble de données',
'certificate' => 'texte',
'checklist' => 'service',
'choice' => 'service',
'customlabel' => 'texte',
'data' => 'ensemble de données',
'etherpad' => 'texte',
'feedback' => 'service',
'flashcard' => 'son,texte,image fixe,image en mouvement',
'questionnaire' => 'service',
'glossary' => 'ensemble de données',
'label' => 'texte',
'folder' => 'collection',
'lesson' => 'collection',
'lightboxgallery' => 'image fixe',
'magtest' => 'service',
'mindmap' => 'ressource interactive',
'page' => 'texte',
'quiz' => 'service',
'resource' => 'texte',
'richmedia' => 'image en mouvement',
'referentiel' => 'ensemble de données',
'scorm' => 'ressource interactive',
'sharedresource' => 'texte',
'survey' => 'service',
'techproject' => 'ensemble de données',
'tracker' => 'service',
'wiki' => 'texte',
'workshop' => 'collection' ];
// MODGENERALDOCUMENTTYPE addesses ScoLOMFR 1_10 node (Type general de documents).
global $modgeneraldocumenttypes;
/*
* annuaire, archives, article, atlas, bande dessinée, banque de vidéos,
* banque d\images, base de données, bibliographie/sitographie, biographie,
* carte, carte heuristique et conceptuelle, chronologie, collection de documents,
* compte rendu, conférence, diaporama, dossier documentaire, dossier technique,
* exposition, feuille de calcul, film, image numérique, livre numérique,
* maquette/prototype, norme, jeu de données, objet physique, objet 3D,
* ouvrage, partition musicale, périodique, photographie, podcast,
* présentation multimédia, programme scolaire, rapport, référentiel de compétences,
* schéma/graphique, site web, tableau (art), web média.
*/
$modgeneraldocumenttypes = [
'advmindmap' => 'carte heuristique et conceptuelle',
'assign' => '',
'assignment' => '',
'book' => 'livre numerique',
'certificate' => '',
'checklist' => 'rapport',
'choice' => '',
'customlabel' => '',
'data' => 'base de données',
'etherpad' => 'article',
'feedback' => '',
'flashcard' => '',
'questionnaire' => '',
'glossary' => 'base de données',
'label' => '',
'folder' => 'dossier documentaire',
'lesson' => '',
'lightboxgallery' => 'banque d\'images',
'magtest' => '',
'mindmap' => 'carte heuristique et conceptuelle',
'page' => 'article',
'quiz' => '',
'resource' => '',
'richmedia' => 'présentation multimedia',
'referentiel' => 'référentiel de compétences',
'scorm' => 'présentation multimédia',
'sharedresource' => '',
'survey' => '',
'techproject' => 'dossier technique',
'tracker' => '',
'wiki' => 'site web',
'workshop' => ''];
// Allow completing from configuration file.
if (isset($CFG->additionalmodgeneraldocumenttype) && is_array($CFG->additionalmodgeneraldocumenttype)) {
$modgeneraldocumenttypes = $modgeneraldocumenttypes + $CFG->additionalmodgeneraldocumenttype;
}
/**
* Append elements to metadata. A utility function for more complex needs
* @see sharedresource_append_author_data()
* @param array $elements
* @param string $name
* @param string $value
* @param string $plugin the mtd namespace of this element.
*/
function sharedresource_append_metadata_elements(&$elements, $name, $value, $plugin) {
$values = explode(',', $value);
// Extracts parts from indexed node name to generate several instances.
if (!preg_match('/^(.*_)(\d+)$/', $name, $matches)) {
return;
}
$radical = $matches[1];
$index = $matches[2];
foreach ($values as $v) {
$elements[$radical.$index] = (object) ['name' => $radical.$index, 'value' => $v, 'plugin' => $plugin];
$index++;
}
}
/**
* This function searches for editing teachers and add them all as co-authors. This may not be true in reality,
* but there is no real mean to know who really did create the activity. We can just guess that in most cases,
* the course has one author/teacher
* @param array $backupmetadataelements
* @param int $courseid $courseid
* @param int $authoringdate
*/
function sharedresource_append_author_data(&$backupmetadataelements, $courseid = 0, $authoringdate = -1) {
global $COURSE;
$config = get_config('sharedresource');
if (!$courseid) {
$courseid = $COURSE->id;
}
if ($authoringdate == -1) {
$authoringdate = time();
}
$coursecontext = context_course::instance($courseid);
$fields = 'u.id, u.lastname, u.firstname, u.email, u.institution';
$editingteachers = get_users_by_capability($coursecontext, 'moodle/course:anageactivities', $fields);
if (!empty($editingteachers)) {
$i = 0;
foreach ($editingteachers as $et) {
if (sharedresource_supports_feature() === 'pro') {
$vcard = file_importer_base::build_vcard($et);
sharedresource_append_metadata_elements($backupmetadataelements, "2_3_2:0_{$i}_0", $vcard, $config->schema);
}
sharedresource_append_metadata_elements($backupmetadataelements, "2_3_1:0_{$i}_0", 'author', $config->schema);
sharedresource_append_metadata_elements($backupmetadataelements, "2_3_3:0_{$i}_0", date('Y-m-d\Th:i:s\Z',
$authoringdate), $config->schema);
}
}
}