diff options
| author | Thomas Hackl <hackl@data-quest.de> | 2023-12-01 12:15:33 +0000 |
|---|---|---|
| committer | Thomas Hackl <hackl@data-quest.de> | 2023-12-01 12:15:33 +0000 |
| commit | f26137d9fe055623e869ea50d0c0d6e0fe61c37f (patch) | |
| tree | 4e7607836e20910e21c96f6a1bf5e4d8efeb2e25 /resources/vue/components/courseware/unit/CoursewareUnitItem.vue | |
| parent | dd20ec005462f4e13d89a44d366bf0ba6714d1d9 (diff) | |
Resolve "Erweiterung der Courseware-Zertifikate"
Closes #3319
Merge request studip/studip!2269
Diffstat (limited to 'resources/vue/components/courseware/unit/CoursewareUnitItem.vue')
| -rw-r--r-- | resources/vue/components/courseware/unit/CoursewareUnitItem.vue | 35 |
1 files changed, 31 insertions, 4 deletions
diff --git a/resources/vue/components/courseware/unit/CoursewareUnitItem.vue b/resources/vue/components/courseware/unit/CoursewareUnitItem.vue index 80bf0a7..bf637ae 100644 --- a/resources/vue/components/courseware/unit/CoursewareUnitItem.vue +++ b/resources/vue/components/courseware/unit/CoursewareUnitItem.vue @@ -16,7 +16,7 @@ <template #image-overlay-with-action-menu> <studip-action-menu class="cw-unit-action-menu" - :items="menuItems" + :items="menuItems" :context="title" :collapseAt="0" @showDelete="openDeleteDialog" @@ -30,6 +30,9 @@ <template #description> {{ description }} </template> + <template #footer v-if="certificate"> + <studip-icon shape="medal" :size="32" role="info_alt"></studip-icon> + </template> </courseware-tile> <studip-dialog v-if="showDeleteDialog" @@ -69,6 +72,7 @@ import CoursewareUnitItemDialogExport from './CoursewareUnitItemDialogExport.vue import CoursewareUnitItemDialogSettings from './CoursewareUnitItemDialogSettings.vue'; import CoursewareUnitItemDialogLayout from './CoursewareUnitItemDialogLayout.vue'; import CoursewareUnitProgress from './CoursewareUnitProgress.vue'; +import axios from 'axios'; import { mapActions, mapGetters } from 'vuex'; @@ -95,7 +99,8 @@ export default { showSettingsDialog: false, showProgressDialog: false, showLayoutDialog: false, - progresses: null + progresses: null, + certificate: null } }, computed: { @@ -108,6 +113,18 @@ export default { let menu = []; if (this.inCourseContext) { menu.push({ id: 1, label: this.$gettext('Fortschritt'), icon: 'progress', emit: 'showProgress' }); + if (this.certificate) { + menu.push({ + id: 2, + label: this.$gettext('Zertifikat'), + icon: 'medal', + url: STUDIP.URLHelper.getURL('sendfile.php', { + type: 0, + file_id: this.certificate, + file_name: this.$gettext('Zertifikat') + '.pdf' + }) + }); + } } if(this.userIsTeacher && this.inCourseContext) { menu.push({ id: 2, label: this.$gettext('Einstellungen'), icon: 'settings', emit: 'showSettings' }); @@ -156,6 +173,7 @@ export default { async mounted() { if (this.inCourseContext) { this.progresses = await this.loadUnitProgresses({unitId: this.unit.id}); + this.checkCertificate(); } }, methods: { @@ -165,6 +183,15 @@ export default { copyUnit: 'copyUnit', companionSuccess: 'companionSuccess' }), + async checkCertificate() { + if (this.getStudipConfig('COURSEWARE_CERTIFICATES_ENABLE')) { + const response = await axios.get(STUDIP.URLHelper.getURL('jsonapi.php/v1/courseware-units/' + + this.unit.id + '/certificate/' + STUDIP.USER_ID)); + if (response.status === 200) { + this.certificate = response.data; + } + } + }, executeDelete() { this.deleteUnit({id: this.unit.id}); }, @@ -185,13 +212,13 @@ export default { this.showProgressDialog = false; }, openSettingsDialog() { - this.showSettingsDialog = true; + this.showSettingsDialog = true; }, closeSettingsDialog() { this.showSettingsDialog = false; }, openLayoutDialog() { - this.showLayoutDialog = true; + this.showLayoutDialog = true; }, closeLayoutDialog() { this.showLayoutDialog = false; |
