diff --git a/lib/models/Courseware/BlockTypes/Embed.json b/lib/models/Courseware/BlockTypes/Embed.json index aad4063e20be052a7029bb9c09aa60ecc34734ef..05e3b2a01fbd6239edecdf38a1d19f1a386f05e3 100755 --- a/lib/models/Courseware/BlockTypes/Embed.json +++ b/lib/models/Courseware/BlockTypes/Embed.json @@ -16,25 +16,10 @@ }, "endtime": { "type": "string" - }, - "oembed_request": { - "type": "string" - }, - "oembed-unauthorized": { - "type": "boolean" - }, - "oembed-not-found": { - "type": "boolean" - }, - "oembed": { - "type": "object" - }, - "request": { - "type": "string" } }, "required": [ "url", "source" ], - "additionalProperties": false + "additionalProperties": true } diff --git a/resources/vue/components/courseware/CoursewareCourseManager.vue b/resources/vue/components/courseware/CoursewareCourseManager.vue index 0faf537f6e523e9472391086e8da79c2c12f4956..4992fc79c3bbcca992261713bbdbf7a7772d6bcb 100755 --- a/resources/vue/components/courseware/CoursewareCourseManager.vue +++ b/resources/vue/components/courseware/CoursewareCourseManager.vue @@ -131,6 +131,10 @@ <translate>Alles importieren</translate> </button> + <ul v-if="importErrors.length > 0"> + <li v-for="error in importErrors"> {{error}} </li> + </ul> + <input ref="importFile" type="file" accept=".zip" @change="setImport" style="visibility: hidden" /> </courseware-tab> </courseware-tabs> @@ -184,6 +188,7 @@ export default { importFilesProgress: 'importFilesProgress', importStructuresState: 'importStructuresState', importStructuresProgress: 'importStructuresProgress', + importErrors: 'importErrors', exportState: 'exportState', exportProgress: 'exportProgress' }), diff --git a/resources/vue/mixins/courseware/import.js b/resources/vue/mixins/courseware/import.js index 703f010019158dc88b63d4ac89c4f86ab59242fd..39e49cb4a8e97ffe1b4c5537fa0ec88377b642b9 100755 --- a/resources/vue/mixins/courseware/import.js +++ b/resources/vue/mixins/courseware/import.js @@ -7,6 +7,7 @@ export default { file_mapping: {}, elementCounter: 0, importElementCounter: 0, + currentImportErrors: [], }; }, @@ -27,6 +28,7 @@ export default { this.elementCounter = await this.countImportElements([element]); this.setImportStructuresState(''); this.importElementCounter = 0; + this.setImportErrors([]); await this.importStructuralElement([element], parent_id, files); @@ -61,7 +63,6 @@ export default { async importStructuralElement(element, parent_id, files) { if (element.length) { for (var i = 0; i < element.length; i++) { - // TODO: create element on server and fetch new id this.setImportStructuresState('Lege Seite an: ' + element[i].attributes.title); await this.createStructuralElement({ attributes: element[i].attributes, @@ -93,8 +94,10 @@ export default { let new_block = null; for (var k = 0; k < container.blocks.length; k++) { new_block = await this.importBlock(container.blocks[k], new_container, files); - this.importElementCounter++; - await this.updateContainerPayload(new_container, new_element.id, container.blocks[k].id, new_block.id); + if (new_block !== null) { + this.importElementCounter++; + await this.updateContainerPayload(new_container, new_element.id, container.blocks[k].id, new_block.id); + } } } @@ -105,12 +108,17 @@ export default { }, async importBlock(block, block_container, files) { - // TODO: create element this.setImportStructuresState('Lege neuen Block an: ' + block.attributes.title); - await this.createBlockInContainer({ - container: {type: block_container.type, id: block_container.id}, - blockType: block.attributes['block-type'], - }); + try { + await this.createBlockInContainer({ + container: {type: block_container.type, id: block_container.id}, + blockType: block.attributes['block-type'], + }); + } catch(error) { + this.currentImportErrors.push(this.$gettext('Block konnte nicht erstellt werden') + ': ' + block.attributes.title); + + return null; + } let new_block = this.$store.getters['courseware-blocks/lastCreated']; @@ -155,7 +163,6 @@ export default { await this.unlockObject({ id: container.id, type: 'courseware-containers' }); }, - async uploadAllFiles(files) { // create folder for importing the files into this.setImportFilesProgress(0); @@ -241,6 +248,7 @@ export default { 'setImportFilesProgress', 'setImportStructuresState', 'setImportStructuresProgress', + 'setImportErrors', ]), }, watch: { @@ -250,6 +258,11 @@ export default { } else { this.setImportStructuresProgress(100); } + }, + currentImportErrors(errors) { + if(errors.length > 0) { + this.setImportErrors(errors); + } } }, }; diff --git a/resources/vue/store/courseware/courseware.module.js b/resources/vue/store/courseware/courseware.module.js index 23d239f85bab9c700637d70e1857eec8d2e14577..d0d41a97232bb8459d14273dd2d00a5d97c6ef86 100755 --- a/resources/vue/store/courseware/courseware.module.js +++ b/resources/vue/store/courseware/courseware.module.js @@ -37,6 +37,7 @@ const getDefaultState = () => { importFilesProgress: 0, importStructuresState: '', importStructuresProgress: 0, + importErrors: [], exportState: '', exportProgress: 0, @@ -154,6 +155,9 @@ const getters = { importStructuresProgress(state) { return state.importStructuresProgress; }, + importErrors(state) { + return state.importErrors; + }, exportState(state) { return state.exportState; }, @@ -716,6 +720,9 @@ export const actions = { setImportStructuresProgress({commit}, percent ) { commit('setImportStructuresProgress', percent) }, + setImportErrors({commit}, errors) { + commit('setImportErrors', errors); + }, setExportState({commit}, state) { commit('setExportState', state) @@ -1074,6 +1081,9 @@ export const mutations = { setImportFilesProgress(state, importFilesProgress) { state.importFilesProgress = importFilesProgress; }, + setImportErrors(state, importErrors) { + state.importErrors = importErrors; + }, setImportStructuresState(state, importStructuresState) { state.importStructuresState = importStructuresState;