Skip to content
Snippets Groups Projects
Commit da6aaa1a authored by Ron Lucke's avatar Ron Lucke
Browse files

fix #847

Closes #847 and #905
parent 1b837a1a
No related branches found
No related tags found
No related merge requests found
...@@ -110,7 +110,7 @@ export default { ...@@ -110,7 +110,7 @@ export default {
if (container.blocks?.length) { if (container.blocks?.length) {
let new_block = null; let new_block = null;
for (var k = 0; k < container.blocks.length; k++) { for (var k = 0; k < container.blocks.length; k++) {
new_block = await this.importBlock(container.blocks[k], new_container, files); new_block = await this.importBlock(container.blocks[k], new_container, files, new_element);
if (new_block !== null) { if (new_block !== null) {
this.importElementCounter++; this.importElementCounter++;
await this.updateContainerPayload(new_container, new_element.id, container.blocks[k].id, new_block.id); await this.updateContainerPayload(new_container, new_element.id, container.blocks[k].id, new_block.id);
...@@ -124,15 +124,18 @@ export default { ...@@ -124,15 +124,18 @@ export default {
} }
}, },
async importBlock(block, block_container, files) { async importBlock(block, block_container, files, element) {
this.setImportStructuresState(this.$gettext('Lege neuen Block an:') + ' ' + block.attributes.title); this.setImportStructuresState('Lege neuen Block an: ' + block.attributes.title);
try { try {
await this.createBlockInContainer({ await this.createBlockInContainer({
container: {type: block_container.type, id: block_container.id}, container: {type: block_container.type, id: block_container.id},
blockType: block.attributes['block-type'], blockType: block.attributes['block-type'],
}); });
} catch(error) { } catch(error) {
this.currentImportErrors.push(this.$gettext('Block konnte nicht erstellt werden') + ': ' + block.attributes.title); this.currentImportErrors.push(this.$gettext('Block konnte nicht erstellt werden') + ': '
+ element.attributes.title + ''
+ block_container.attributes.title + ''
+ block.attributes.title);
return null; return null;
} }
...@@ -152,12 +155,22 @@ export default { ...@@ -152,12 +155,22 @@ export default {
block.attributes.payload = JSON.parse(payload); block.attributes.payload = JSON.parse(payload);
} }
} }
this.setImportStructuresState(this.$gettext('Aktualisiere neuen Block:') + ' ' + block.attributes.title); this.setImportStructuresState('Aktualisiere neuen Block: ' + block.attributes.title);
await this.updateBlockInContainer({ try {
attributes: block.attributes, await this.updateBlockInContainer({
blockId: new_block.id, attributes: block.attributes,
containerId: block_container.id, blockId: new_block.id,
}); containerId: block_container.id,
});
} catch(error) {
this.currentImportErrors.push(this.$gettext('Blockdaten sind beschädigt. Es werden die Standardwerte eingesetzt.') + ': '
+ element.attributes.title + ''
+ block_container.attributes.title + ''
+ block.attributes.title);
this.unlockObject({ id: new_block.id, type: 'courseware-blocks' });
}
return new_block; return new_block;
}, },
......
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