aboutsummaryrefslogtreecommitdiff
path: root/lib/models/Courseware/StructuralElementFeedback.php
blob: f13d47314956ba9424fc47212467a2b20c52182e (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
<?php

namespace Courseware;

use User;

/**
 * Courseware's feedback on structural elements.
 *
 * @author  Ron Lucke <lucke@elan-ev.de>
 * @license GPL2 or any later version
 *
 * @since   Stud.IP 5.1
 *
 * @property int $id database column
 * @property int $structural_element_id database column
 * @property string $user_id database column
 * @property string $feedback database column
 * @property int $mkdate database column
 * @property int $chdate database column
 * @property \User $user belongs_to \User
 * @property StructuralElement $structural_element belongs_to StructuralElement
 */
class StructuralElementFeedback extends \SimpleORMap implements \PrivacyObject
{
    protected static function configure($config = [])
    {
        $config['db_table'] = 'cw_structural_element_feedbacks';

        $config['belongs_to']['user'] = [
            'class_name' => User::class,
            'foreign_key' => 'user_id',
        ];

        $config['belongs_to']['structural_element'] = [
            'class_name' => StructuralElement::class,
            'foreign_key' => 'structural_element_id',
        ];

        parent::configure($config);
    }

    /**
     * Export available data of a given user into a storage object
     * (an instance of the StoredUserData class) for that user.
     *
     * @param StoredUserData $storage object to store data into
     */
    public static function exportUserData(\StoredUserData $storage)
    {
        $feedback = \DBManager::get()->fetchAll(
            'SELECT * FROM cw_structural_element_feedbacks WHERE user_id = ?',
            [$storage->user_id]
        );
        if ($feedback) {
            $storage->addTabularData(_('Courseware Seiten Feedback'), 'cw_structural_element_feedbacks', $feedback);
        }
    }
}