Skip to content

Commit a0d384b

Browse files
committed
Course validation fix
1 parent 5725be7 commit a0d384b

1 file changed

Lines changed: 11 additions & 6 deletions

File tree

plugins/output/adapt/outputHelpers.js

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -281,9 +281,6 @@ function getPluginFrameworkVersionCategory(serverFrameworkVersion, pluginMetaDat
281281
function validateCourse(data, cb) {
282282
let errors = '';
283283
let contentObjects = data.contentobject;
284-
let articles = data.article;
285-
let blocks = data.block;
286-
let components = data.component;
287284

288285
if (typeof contentObjects === 'undefined') {
289286
let courseString = app.polyglot.t('app.course');
@@ -295,9 +292,17 @@ function validateCourse(data, cb) {
295292
return cb(errors, false);
296293
}
297294

298-
errors += iterateThroughChildren(contentObjects, articles);
299-
errors += iterateThroughChildren(articles, blocks);
300-
errors += iterateThroughChildren(blocks, components);
295+
const contentHierarchy = [
296+
contentObjects.filter(contentObject => contentObject._type === 'menu'),
297+
contentObjects.filter(contentObject => contentObject._type === 'page'),
298+
data.article,
299+
data.block,
300+
data.component
301+
];
302+
303+
for (let i = 0, j = contentHierarchy.length - 1; i < j; i++) {
304+
errors += iterateThroughChildren(contentHierarchy[i], contentHierarchy[i + 1]);
305+
}
301306

302307
if (errors.length !== 0) return cb(errors, false);
303308

0 commit comments

Comments
 (0)