aboutsummaryrefslogtreecommitdiff
path: root/lib/models/Courseware/BlockTypes/Audio.php
blob: 22dc16710d36b1ddb53ce6843b765a012957de77 (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
<?php

namespace Courseware\BlockTypes;

/**
 * This class represents the content of a Courseware audio block.
 *
 * @author  Ron Lucke <lucke@elan-ev.de>
 * @license GPL2 or any later version
 *
 * @since   Stud.IP 5.0
 */
class Audio extends BlockType
{
    public static function getType(): string
    {
        return 'audio';
    }

    public static function getTitle(): string
    {
        return _('Audio');
    }

    public static function getDescription(): string
    {
        return _('Spielt eine Audiodatei aus dem Dateibereich oder von ' .
                 'einer URL ab und ermöglicht Audioaufnahmen direkt im Block.');
    }

    public function initialPayload(): array
    {
        return [
            'title' => 'Audio',
            'source' => 'studip_folder',
            'file_id' => '',
            'folder_id' => '',
            'web_url' => '',
            'recorder_enabled' => false
        ];
    }

    public static function getJsonSchema(): string
    {
        $schemaFile = __DIR__.'/Audio.json';
        return file_get_contents($schemaFile);
    }

    /**
     * get all files related to this block.
     *
     * @return \FileRef[] list of file references related to this block
     */
    public function getFiles(): array
    {
        $payload = $this->getPayload();
        if (!$payload['file_id'] && !$payload['folder_id']) {
            return [];
        }

        if ($payload['file_id']) {
            $files = [];

            if ($fileRef = \FileRef::find($payload['file_id'])) {
                $files[] = $fileRef;
            }

            return $files;
        } else {
            return \FileRef::findByFolder_id($payload['folder_id']);
        }
    }

    public function copyPayload(string $rangeId = ''): array
    {
        $payload = $this->getPayload();

        if ('' != $payload['file_id']) {
            $payload['file_id'] = $this->copyFileById($payload['file_id'], $rangeId);
        }

        return $payload;
    }

    public static function getCategories(): array
    {
        return ['multimedia', 'interaction'];
    }

    public static function getContentTypes(): array
    {
        return ['audio'];
    }

    public static function getFileTypes(): array
    {
        return ['audio'];
    }

    public static function getTags(): array
    {
        return [
            'mp3', _('Interaktion'), _('Sprachnachricht'), _('Audiogalerie'),
            _('Studierende aktivieren'), _('Austausch'), _('Musik'), _('Sprache'),
            _('Ton'), _('Tonaufzeichnung'), _('O Ton'), _('Zitat'), _('Sprachmemo'),
            _('Tonaufnahme'), _('Vorstellungsrunde'), _('Podcast'), _('Audioforum'),
            _('Sprachaufzeichnung'), _('Aufzeichnung'), _('Multimedia'),
            _('Inhalt erstellen'), _('Studierende interagieren'), _('Einstieg'),
            _('hochladen'), _('Aufnahme'), _('Abspielen'), _('Aktivierung'),
            _('Interview'), _('Radio'), _('Tonspur'), _('Stimme'), _('Sprachaufnahme')
        ];
    }
}