Skip to content
Snippets Groups Projects
Commit d93fd7f8 authored by \nrlucke's avatar \nrlucke
Browse files

refs #26

parent 9dcc0a0e
No related branches found
No related tags found
No related merge requests found
...@@ -136,7 +136,9 @@ export default { ...@@ -136,7 +136,9 @@ export default {
let blocks = 0; let blocks = 0;
this.sectionsWithBlocksCurrentState.forEach((section) => { this.sectionsWithBlocksCurrentState.forEach((section) => {
blocks += section.blocks.length; if (section.blocks !== undefined) {
blocks += section.blocks.length;
}
}); });
return blocks; return blocks;
...@@ -173,15 +175,17 @@ export default { ...@@ -173,15 +175,17 @@ export default {
const blockSections = JSON.parse(JSON.stringify(this.container.attributes.payload.sections)); //copy array AND objects without references const blockSections = JSON.parse(JSON.stringify(this.container.attributes.payload.sections)); //copy array AND objects without references
blockSections.forEach((section) => { blockSections.forEach((section) => {
section.blocks = section.blocks.flatMap( if(section.blocks !== undefined) {
(id) => { section.blocks = section.blocks.flatMap(
return this.blockById({ id }) ?? [] //remove blocks which could not be loaded (id) => {
} return this.blockById({ id }) ?? [] //remove blocks which could not be loaded
); }
);
section.blocks.sort((a, b) => { section.blocks.sort((a, b) => {
return a.attributes.position > b.attributes.position; return a.attributes.position > b.attributes.position;
}); });
}
}); });
return blockSections; return blockSections;
...@@ -196,7 +200,9 @@ export default { ...@@ -196,7 +200,9 @@ export default {
const container = this.container; const container = this.container;
this.sectionsWithBlocksCurrentState.forEach((section, index)=> { this.sectionsWithBlocksCurrentState.forEach((section, index)=> {
container.attributes.payload.sections[index].blocks = section.blocks.map(({ id }) => ( id )); if (section.blocks !== undefined) {
container.attributes.payload.sections[index].blocks = section.blocks.map(({ id }) => ( id ));
}
}); });
await this.lockObject({id: container.id, type: 'courseware-containers'}); await this.lockObject({id: container.id, type: 'courseware-containers'});
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment