You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: doc/en/Authoring/Metadata.md
+10-6Lines changed: 10 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -17,10 +17,11 @@ New questions will be created with editable `metadata` similar to the following:
17
17
],
18
18
"license": "unknown", // $CFG->sitedefaultlicense
19
19
"isPartOf": "",
20
-
"additional": {}
20
+
"additional": {},
21
+
"freeform" {}
21
22
}
22
23
```
23
-
A question has one creator but can have multiple contributors.
24
+
A question has one creator but can have multiple contributors.`Last name` is required.
24
25
25
26
Additional metadata is stored in Scope->Property->Qualifier->Value or Scope->Property->Value format. Scope identifies the metadata scheme being used. For instance, two institutions might have the property `Level` that has different meanings. Scope allows differentiation between the two:
26
27
```
@@ -77,13 +78,15 @@ If any entry for a property has a qualifier, then all entries must do so in orde
77
78
}
78
79
}
79
80
```
80
-
All information in the `metadata` field can be updated via the button 'View and edit full metadata' in the question edit form. This launches a pop-up where the metadata information can be updated via input boxes or the JSON can be manually amended and validated.
81
+
The freeform metadata input allows entry of further metadata in whatever format the user requires. It simply has to be valid JSON. This can also be added in the main JSON metadata input field but (unlike `additional` entries) does not create additional input fields and buttons. This field is for power users who require greater nesting depth in their metadata.
82
+
83
+
All information in the question `metadata` field can be updated via the button 'View and edit full metadata' in the question edit form. This launches a pop-up where the metadata information can be updated via input boxes or the JSON can be manually amended and validated.
81
84
82
85

83
86
84
87
Update the input boxes and click 'Validate inputs and update JSON' to display the JSON output. Update the JSON and click 'Update inputs from JSON' to fill in the input boxes from the JSON. 'Validate and close' will take the contents of the input boxes, validate them and then create and store JSON ready to be saved as part of the STACK question. The question edit form must still be saved normally once the pop-up has closed in order to save this JSON to the question.
85
88
86
-
Please note that although you can update either the JSON or the input boxes, the form saves the contents of the input boxes. If you update the JSON you must click 'Update inputs from JSON' without a JSON error being displayed before clicking 'Validate and close'.
89
+
Please note that although you can update either the JSON or the input boxes, the form saves the contents of the input boxes. If you update the JSON you must click 'Update inputs from JSON' without a JSON error being displayed before clicking 'Validate and close'.
87
90
88
91
Example metadata:
89
92
```
@@ -135,7 +138,8 @@ Example metadata:
135
138
"Workbook": "10",
136
139
"Level": "Basic"
137
140
}
138
-
}
141
+
},
142
+
"freeform": {}
139
143
}
140
144
```
141
145
Both metadata fields are exported and imported normally as part of Moodle XML, allowing automated addition of metadata to large question banks with the aid of Gitsync.
@@ -144,6 +148,6 @@ Both metadata fields are exported and imported normally as part of Moodle XML, a
Copy file name to clipboardExpand all lines: tests/behat/metadata.feature
+86Lines changed: 86 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -261,6 +261,92 @@ Feature: Create and edit STACK metadata
261
261
Then I should see "v2 (latest)"
262
262
And I check the hidden input "metadata" is '{"creator":{"firstName":"Bob","lastName":"Smith","institution":"MIT","year":"2024"},"contributor":[{"firstName":"Mike","lastName":"Jones","institution":"Bath","year":"2023"}],"language":["en"],"isPartOf":"Everything","license":"cc-nc-4.1","additional":{"Added":{"Cat":{"Breed":"Al$%&^"},"Horse":["Dobbin","Champion"],"Dog":{"Teeth":"50","Tails":"1"}},"Added too":{"Fish":{"Gills":["2","3"]}}},"freeform":{}}'
263
263
264
+
@javascript@current
265
+
Scenario: Create and edit STACK freeform metadata
266
+
When I am on the "Algebraic input""core_question > edit" page logged in as teacher
267
+
And I click on "View and edit full metadata""button"
268
+
And I should see "STACK metadata is stored as a JSON object."
269
+
And I set the field "id_metadata_json" to multiline:
270
+
"""
271
+
{
272
+
"creator": {
273
+
"firstName": "Bob",
274
+
"lastName": "Smith",
275
+
"institution": "MIT",
276
+
"year": "2024"
277
+
},
278
+
"contributor": [
279
+
{
280
+
"firstName": "Mike",
281
+
"lastName": "Jones",
282
+
"institution": "Bath",
283
+
"year": "2023"
284
+
}
285
+
],
286
+
"language": [
287
+
"en"
288
+
],
289
+
"isPartOf": "Everything",
290
+
"license": "cc-nc-4.1",
291
+
"additional":
292
+
{
293
+
"additional": {
294
+
"Cat": {
295
+
"Breed": "Al$%&^"
296
+
},
297
+
"Horse": "Dobbin",
298
+
"Dog": {
299
+
"Teeth": "50",
300
+
"Tails": "1"
301
+
},
302
+
"Multi": [
303
+
1,2,3
304
+
],
305
+
"Multi1": {
306
+
"Multi2": [
307
+
4,5,6
308
+
]
309
+
}
310
+
},
311
+
"Added too": {
312
+
"Fish": {
313
+
"Gills": "2"
314
+
}
315
+
}
316
+
},
317
+
"freeform":
318
+
{
319
+
"license": {
320
+
"Cat": {
321
+
"Breed": "Al$%&^"
322
+
},
323
+
"Horse": "Dobbin",
324
+
"Dog": {
325
+
"Teeth": "50",
326
+
"Tails": "1"
327
+
}
328
+
},
329
+
"Freeform too": {
330
+
"Fish": {
331
+
"Gills": "2"
332
+
}
333
+
}
334
+
}
335
+
}
336
+
"""
337
+
And I click on "Update inputs from JSON""button"
338
+
And I should see "{\"license\":{\"Cat\":{\"Breed\":\"Al$%&^\"},\"Horse\":\"Dobbin\",\"Dog\":{\"Teeth\":\"50\",\"Tails\":\"1\"}},\"Freeform too\":{\"Fish\":{\"Gills\":\"2\"}}}"
339
+
And I click on "Validate and close""button"
340
+
And I check the hidden input "metadata" is '{"creator":{"firstName":"Bob","lastName":"Smith","institution":"MIT","year":"2024"},"contributor":[{"firstName":"Mike","lastName":"Jones","institution":"Bath","year":"2023"}],"language":["en"],"isPartOf":"Everything","license":"cc-nc-4.1","additional":{"additional":{"Cat":{"Breed":"Al$%&^"},"Horse":"Dobbin","Dog":{"Teeth":"50","Tails":"1"},"Multi":["1","2","3"],"Multi1":{"Multi2":["4","5","6"]}},"Added too":{"Fish":{"Gills":"2"}}},"freeform":{"license":{"Cat":{"Breed":"Al$%&^"},"Horse":"Dobbin","Dog":{"Teeth":"50","Tails":"1"}},"Freeform too":{"Fish":{"Gills":"2"}}}}'
341
+
And I click on "View and edit full metadata""button"
342
+
And I should see "STACK metadata is stored as a JSON object."
343
+
And I set the field "smdi_0_freeform_value" to multiline:
344
+
"""
345
+
{"x":[{"additional":"b"},{"license":"d"}]}
346
+
"""
347
+
And I click on "Validate and close""button"
348
+
And I check the hidden input "metadata" is '{"creator":{"firstName":"Bob","lastName":"Smith","institution":"MIT","year":"2024"},"contributor":[{"firstName":"Mike","lastName":"Jones","institution":"Bath","year":"2023"}],"language":["en"],"isPartOf":"Everything","license":"cc-nc-4.1","additional":{"additional":{"Cat":{"Breed":"Al$%&^"},"Horse":"Dobbin","Dog":{"Teeth":"50","Tails":"1"},"Multi":["1","2","3"],"Multi1":{"Multi2":["4","5","6"]}},"Added too":{"Fish":{"Gills":"2"}}},"freeform":{"x":[{"additional":"b"},{"license":"d"}]}}'
349
+
264
350
@javascript
265
351
Scenario: New question metadata
266
352
When I am on the "Course 1""core_question > course question bank" page logged in as "teacher"
0 commit comments