aboutsummaryrefslogtreecommitdiff
path: root/resources/vue/components/courseware/tasks/TaskGroupTaskItem.vue
blob: 31e8efb03ac9391c39ee5cad07caa4defe82c1be (plain)
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>
    <tr>
        <td>
            <studip-icon
                v-if="status.shape !== undefined"
                :shape="status.shape"
                :role="status.role"
                :title="status.description"
                aria-hidden="true"
            />
            <span class="sr-only">{{ status.description }}</span>
        </td>
        <td>
            <span v-if="user" class="cw-taskgroup-task-item-solver-info">
                <studip-icon shape="person2" role="info" aria-hidden="true" :title="$gettext('Teilnehmende Person')" />
                <span class="sr-only">{{ $gettext('Teilnehmende Person') }}</span>
                {{ user.attributes['formatted-name'] }}
            </span>
            <span v-if="group">
                <studip-icon shape="group2" role="info" aria-hidden="true" :title="$gettext('Gruppe')" />
                <span class="sr-only">{{ $gettext('Gruppe') }}</span>
                {{ group.attributes['name'] }}
            </span>
        </td>
        <td class="responsive-hidden">
            <a v-if="task.attributes.submitted" :href="getLinkToElement(element)">
                {{ element.attributes.title }}
            </a>
            <span v-else>{{ element.attributes.title }}</span>
        </td>
        <td>{{ task.attributes?.progress?.toFixed(2) || '-.--' }}%</td>
        <td>{{ getReadableDate(task.attributes['submission-date']) }}</td>
        <td>
            <studip-icon v-if="task.attributes.submitted" shape="accept" role="status-green" />
        </td>
        <td class="responsive-hidden">
            <button v-show="task.attributes.renewal === 'pending'" class="button" @click="$emit('solve-renewal', task)">
                {{ $gettext('Anfrage bearbeiten') }}
            </button>
            <span v-show="task.attributes.renewal === 'declined'">
                <studip-icon shape="decline" role="status-red" />
                {{ $gettext('Anfrage abgelehnt') }}
            </span>
            <span v-show="task.attributes.renewal === 'granted'">
                {{ $gettext('verlängert bis') }}:
                {{ getReadableDate(task.attributes['renewal-date']) }}
            </span>
            <studip-icon
                v-if="task.attributes.renewal === 'declined' || task.attributes.renewal === 'granted'"
                :title="$gettext('Anfrage bearbeiten')"
                class="edit"
                shape="edit"
                @click="$emit('solve-renewal', task)"
            />
        </td>
        <td class="responsive-hidden">
            <span
                v-if="feedback"
                :title="$gettext(
                    'Feedback geschrieben am: %{ date }',
                    { date: getReadableDate(feedback.attributes['chdate']) }
                )"
            >
                <studip-icon shape="accept" role="status-green" />
                {{ $gettext('Feedback gegeben') }}
                <studip-icon
                    :title="$gettext('Feedback bearbeiten')"
                    class="edit"
                    shape="edit"
                    @click="$emit('edit-feedback', feedback)"
                />
            </span>

            <button v-show="!feedback && task.attributes.submitted" class="button" @click="$emit('add-feedback', task)">
                {{ $gettext('Feedback geben') }}
            </button>
        </td>
    </tr>
</template>
<script>
import taskHelper from '../../../mixins/courseware/task-helper.js';
import { mapGetters } from 'vuex';

export default {
    mixins: [taskHelper],
    emits: ['add-feedback', 'edit-feedback', 'solve-renewal'],
    props: ['task', 'taskGroup'],
    computed: {
        ...mapGetters({
            elementById: 'courseware-structural-elements/byId',
            feedbackById: 'courseware-task-feedback/byId',
            statusGroupById: 'status-groups/byId',
            userById: 'users/byId',
        }),
        element() {
            return this.elementById({ id: this.task.relationships['structural-element'].data.id });
        },
        feedback() {
            const id = this.task.relationships['task-feedback'].data?.id;
            return id ? this.feedbackById({ id }) : null;
        },
        group() {
            const { id, type } = this.solver;
            return type === 'status-groups' ? this.statusGroupById({ id }) : null;
        },
        solver() {
            return this.task.relationships.solver.data;
        },
        status() {
            return this.getStatus(this.task);
        },
        user() {
            const { id, type } = this.solver;
            return type === 'users' ? this.userById({ id }) : null;
        },
    },
};
</script>