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
|
<template>
<div class="cw-dashboard-progress">
<nav aria-label="Breadcrumb" class="cw-dashboard-progress-breadcrumb">
<a
v-if="parent"
href="#"
:title="$gettext('Hauptseite')"
@click="visitRoot"
>
<studip-icon shape="home" />
</a>
<a
v-if="parent"
href="#"
:title="parent.name"
@click="selectChapter(parent.id)"
>
/ {{ parent.name }}
</a>
</nav>
<div v-if="selected" class="cw-dashboard-progress-chapter">
<a :href="chapterUrl" :title="$gettextInterpolate('%{ pageTitle } öffnen', {pageTitle: selected.name})">
<h1>{{ selected.name }}</h1>
</a>
<courseware-progress-circle
:title="$gettext('diese Seite inkl. darunter liegende Seiten')"
:value="parseInt(selected.progress.cumulative)"
/>
<courseware-progress-circle
:title="$gettext('diese Seite')"
class="cw-dashboard-progress-current"
:value="parseInt(selected.progress.self)"
/>
</div>
<div class="cw-dashboard-progress-subchapter-list">
<courseware-dashboard-progress-item
v-for="chapter in children"
:key="chapter.id"
:name="chapter.name"
:value="chapter.progress.cumulative"
:chapterId="chapter.id"
@selectChapter="selectChapter"
/>
<div v-if="!children.length" class="cw-dashboard-empty-info">
<courseware-companion-box
mood="sad"
:msgCompanion="$gettext('Diese Seite enthält keine darunter liegenden Seiten.')"
/>
</div>
</div>
</div>
</template>
<script>
import StudipIcon from '../StudipIcon.vue';
import CoursewareCompanionBox from './CoursewareCompanionBox.vue';
import CoursewareDashboardProgressItem from './CoursewareDashboardProgressItem.vue';
import CoursewareProgressCircle from './CoursewareProgressCircle.vue';
export default {
name: 'courseware-dashboard-progress',
components: {
CoursewareCompanionBox,
CoursewareDashboardProgressItem,
CoursewareProgressCircle,
StudipIcon,
},
data() {
return {
selected: null,
};
},
computed: {
progressData() {
return STUDIP.courseware_progress_data;
},
chapterUrl() {
return (
STUDIP.URLHelper.base_url +
'dispatch.php/course/courseware/?cid=' +
STUDIP.URLHelper.parameters.cid +
'#/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 = Object.values(this.progressData).find(({ parent_id }) => !!parent_id) ?? null;
},
selectChapter(id) {
this.selected = this.progressData[id] ?? null;
},
},
mounted() {
this.visitRoot();
},
};
</script>
|