Skip to content
Snippets Groups Projects
Commit f7fabdd9 authored by Ron Lucke's avatar Ron Lucke Committed by Marcus Eibrink-Lunzenauer
Browse files

fix #826

parent 1d918961
No related branches found
No related tags found
No related merge requests found
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
:canEdit="canEdit" :canEdit="canEdit"
:isTeacher="isTeacher" :isTeacher="isTeacher"
:preview="true" :preview="true"
:defaultGrade="false"
@storeEdit="storeBlock" @storeEdit="storeBlock"
@closeEdit="initCurrentData" @closeEdit="initCurrentData"
> >
...@@ -18,7 +19,7 @@ ...@@ -18,7 +19,7 @@
{{ currentSuccess }} {{ currentSuccess }}
</div> </div>
<div class="cw-block-download-file-item"> <div class="cw-block-download-file-item">
<a target="_blank" :download="currentFile.name" :href="currentFile.download_url"> <a target="_blank" :download="currentFile.name" :href="currentFile.download_url" @click="handleDownload">
<span class="cw-block-file-info" :class="['cw-block-file-icon-' + currentFile.icon]"> <span class="cw-block-file-info" :class="['cw-block-file-icon-' + currentFile.icon]">
{{ currentFile.name }} {{ currentFile.name }}
</span> </span>
...@@ -93,7 +94,6 @@ export default { ...@@ -93,7 +94,6 @@ export default {
currentGrade: '', currentGrade: '',
currentFileId: '', currentFileId: '',
currentFile: null, currentFile: null,
userHasDownloaded: false, // Todo set and get user_data
}; };
}, },
computed: { computed: {
...@@ -101,6 +101,7 @@ export default { ...@@ -101,6 +101,7 @@ export default {
fileRefById: 'file-refs/byId', fileRefById: 'file-refs/byId',
urlHelper: 'urlHelper', urlHelper: 'urlHelper',
relatedTermOfUse: 'terms-of-use/related', relatedTermOfUse: 'terms-of-use/related',
getUserDataById: 'courseware-user-data-fields/byId',
}), }),
title() { title() {
return this.block?.attributes?.payload?.title; return this.block?.attributes?.payload?.title;
...@@ -117,9 +118,24 @@ export default { ...@@ -117,9 +118,24 @@ export default {
fileId() { fileId() {
return this.block?.attributes?.payload?.file_id; return this.block?.attributes?.payload?.file_id;
}, },
userData() {
return this.getUserDataById({ id: this.block.relationships['user-data-field'].data.id });
},
userHasDownloaded() {
let downloaded = this.userData?.attributes?.payload?.downloaded;
if (downloaded === undefined) {
return false;
}
return downloaded;
}
}, },
mounted() { mounted() {
this.initCurrentData(); this.initCurrentData();
if (this.userProgress && this.userProgress.attributes.grade === 0 && !this.grade) {
this.userProgress = 1;
}
}, },
methods: { methods: {
...mapActions({ ...mapActions({
...@@ -220,6 +236,27 @@ export default { ...@@ -220,6 +236,27 @@ export default {
containerId: this.block.relationships.container.data.id, containerId: this.block.relationships.container.data.id,
}); });
}, },
handleDownload() {
let data = {
id: this.userData.id,
type: 'courseware-user-data-fields',
relationships: {
block: {
data: {
id: this.block.id,
type: this.block.type
}
}
},
attributes: {
payload: {
downloaded: true
}
}
};
this.$store.dispatch('courseware-user-data-fields/update', data);
this.userProgress = 1;
},
}, },
}; };
</script> </script>
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