MDL-74129 h5p: Preserve metadata information

The metadata information was not restored when an H5P file was uploaded
(it was saved when it was edited directly from the Content bank, but the
original information in the H5P file was lost).
This patch includes all the metadata fields and its values in the original
H5P file to preserve this information too.
This commit is contained in:
Sara Arjona
2023-11-10 10:33:57 +01:00
parent d7e3b07082
commit ee8960fdd7
6 changed files with 149 additions and 6 deletions
+7
View File
@@ -907,6 +907,13 @@ class framework implements H5PFrameworkInterface {
$params->title = $content['title'];
$content['params'] = json_encode($params);
}
// Add metadata to 'params'.
if (!empty($content['metadata'])) {
$params = json_decode($content['params']);
$params->metadata = $content['metadata'];
$content['params'] = json_encode($params);
}
$data = [
'jsoncontent' => $content['params'],
'displayoptions' => $content['disable'],