From 5494443533aa25b3a3a117f299b3f87200a35897 Mon Sep 17 00:00:00 2001 From: Tom Arild Jakobsen Date: Tue, 29 Nov 2016 15:44:32 +0100 Subject: [PATCH] validateGroup must handle isSubContent * Update validateGroup in h4p.classes.php to allow subContentId into the data * Fix h5p-content-upgrade-process.js to take into account isSubContent Relates to: #HFP-285 --- h5p.classes.php | 6 ++++-- js/h5p-content-upgrade-process.js | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/h5p.classes.php b/h5p.classes.php index 03d5136..a403856 100644 --- a/h5p.classes.php +++ b/h5p.classes.php @@ -3056,7 +3056,9 @@ class H5PContentValidator { $function = null; $field = null; - if (count($semantics->fields) == 1 && $flatten) { + $isSubContent = isset($semantics->isSubContent) && $semantics->isSubContent === TRUE; + + if (count($semantics->fields) == 1 && $flatten && !$isSubContent) { $field = $semantics->fields[0]; $function = $this->typeMap[$field->type]; $this->$function($group, $field); @@ -3064,7 +3066,7 @@ class H5PContentValidator { else { foreach ($group as $key => &$value) { // If subContentId is set, keep value - if($key == 'subContentId' && $value == TRUE){ + if($isSubContent && ($key == 'subContentId')){ continue; } diff --git a/js/h5p-content-upgrade-process.js b/js/h5p-content-upgrade-process.js index 1d886cc..e54dbb7 100644 --- a/js/h5p-content-upgrade-process.js +++ b/js/h5p-content-upgrade-process.js @@ -182,7 +182,7 @@ H5P.ContentUpgradeProcess = (function (Version) { break; case 'group': - if (field.fields.length === 1) { + if (field.fields.length === 1 && field.isSubContent !== true) { // Single field to process, wrapper will be skipped self.processField(field.fields[0], params, function (err, upgradedParams) { if (upgradedParams) {