aboutsummaryrefslogtreecommitdiff
path: root/resources/vue/mixins/courseware/task-helper.js
blob: ecf4ff304921c3456d2a117dff14b47b6612ae61 (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
export default {
    methods: {
        getStatus(task) {
            let status = {};
            const now = new Date(Date.now());
            const submissionDate = new Date(task.attributes['submission-date']);
            let limit = new Date();
            limit.setDate(now.getDate() + 3);
            status.canSubmit = true;

            if (now < submissionDate) {
                status.shape = 'span-empty';
                status.role = 'status-green';
                status.description = this.$gettext('Aufgabe bereit');
            }
            if (task.attributes.renewal !== 'granted') {
                if (limit > submissionDate) {
                    status.shape = 'span-3quarter';
                    status.role = 'status-yellow';
                    status.description = this.$gettext('Aufgabe muss bald abgegeben werden');
                }

                if (now >= submissionDate) {
                    status.canSubmit = false;
                    status.shape = 'span-full';
                    status.role = 'status-red';
                    status.description = this.$gettext('Abgabe ist nicht bis zur Abgabefrist erfolgt');
                }
            } else {
                const renewalDate = new Date(task.attributes['renewal-date']);
                if (limit > renewalDate) {
                    status.shape = 'span-3quarter';
                    status.role = 'status-yellow';
                    status.description = this.$gettext('Aufgabe muss bald abgegeben werden');
                }

                if (now >= renewalDate) {
                    status.canSubmit = false;
                    status.shape = 'span-full';
                    status.role = 'status-red';
                    status.description = this.$gettext('Abgabe ist nicht bis zur verlängerten Abgabefrist erfolgt');
                }
            }

            if (task.attributes.submitted) {
                status.shape = 'span-full';
                status.role = 'status-green';
                status.description = this.$gettext('Aufgabe abgegeben');
            }

            return status;
        },
        getLinkToElement(elementId) {
            return (
                STUDIP.URLHelper.base_url +
                'dispatch.php/course/courseware/?cid=' +
                STUDIP.URLHelper.parameters.cid +
                '#/structural_element/' +
                elementId
            );
        },
        getReadableDate(date) {
            return new Date(date).toLocaleDateString();
        },
    },
};