1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
|
<template>
<div class="cw-unit-progress">
<p v-if="userIsTeacher">
{{
$gettext('Die Fortschrittsanzeige bezieht sich auf den Anteil der Teilnehmenden, die eine Seite aufgerufen haben.')
}}
</p>
<nav aria-label="Breadcrumb" class="cw-unit-progress-breadcrumb">
<a v-if="parent" href="#" :title="$gettext('Hauptseite')" @click="visitRoot">
<studip-icon shape="home" />
</a>
<a v-if="parent && parent.id !== rootId" href="#" :title="parent.name" @click="selectChapter(parent.id)">
| {{ parent.name }}
</a>
</nav>
<div v-if="selected" class="cw-unit-progress-chapter">
<h1>
<a
:href="chapterUrl"
:title="$gettextInterpolate('%{ pageTitle } öffnen', { pageTitle: selected.name }, true)"
>
{{ selected.name }}
</a>
</h1>
<courseware-progress-circle
:title="selected.id === rootId ? $gettext('Gesamtes Lernmaterial') : $gettext('diese Seite inkl. darunter liegender Seiten')"
:value="parseInt(selected.progress.cumulative)"
/>
<courseware-progress-circle
:title="$gettext('diese Seite')"
class="cw-unit-progress-current"
:value="parseInt(selected.progress.self)"
/>
</div>
<div v-if="children.length > 0" class="cw-unit-progress-subchapter-list">
<courseware-unit-progress-item
v-for="chapter in children"
:key="chapter.id"
:name="chapter.name"
:value="chapter.progress.cumulative"
:chapterId="chapter.id"
@selectChapter="selectChapter"
/>
</div>
<div v-else class="cw-unit-empty-info">
<courseware-companion-box
mood="sad"
:msgCompanion="$gettext('Diese Seite enthält keine darunter liegenden Seiten.')"
/>
</div>
</div>
</template>
<script>
import CoursewareCompanionBox from '../layouts/CoursewareCompanionBox.vue';
import CoursewareUnitProgressItem from './CoursewareUnitProgressItem.vue';
import CoursewareProgressCircle from './CoursewareProgressCircle.vue';
import StudipIcon from '../../StudipIcon.vue';
import { mapGetters } from 'vuex';
export default {
name: 'courseware-unit-progress',
components: {
CoursewareCompanionBox,
CoursewareUnitProgressItem,
CoursewareProgressCircle,
StudipIcon,
},
props: {
progressData: Object,
unitId: String,
rootId: Number,
},
data() {
return {
selected: null,
};
},
computed: {
...mapGetters({
userIsTeacher: 'userIsTeacher',
}),
chapterUrl() {
return (
STUDIP.URLHelper.getURL('dispatch.php/course/courseware/courseware/' + this.unitId) +
'#/structural_element/' +
this.selected.id
);
},
parent() {
if (!this.selected?.parent_id) {
return null;
}
return this.progressData[this.selected.parent_id];
},
children() {
if (!this.selected) {
return [];
}
return Object.values(this.progressData).filter(({ parent_id }) => parent_id === this.selected.id);
},
},
methods: {
visitRoot() {
this.selected = this.progressData[this.rootId];
},
selectChapter(id) {
this.selected = this.progressData[id] ?? null;
},
},
mounted() {
this.visitRoot();
},
};
</script>
|