aboutsummaryrefslogtreecommitdiff
path: root/lib/models/QuestionnaireEvalCentralProfile.php
blob: 58615dc818d7b94981ba68d5d741a2014d0344de (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
<?php
/**
 * @property Semester $semester belongs_to QuestionnaireEvalCentralProfile
 * @property Questionnaire $template belongs_to QuestionnaireEvalCentralProfile
 * @property string $semester_id database column
 * @property string $template_id database column
 * @property string $optional_templates database column
 * @property int $startdate database column
 * @property int $stopdate database column
 * @property bool $anonymous database column
 * @property bool $editanswers database column
 * @property string $resultvisibility database column
 * @property null|string $result_visible_for database column
 * @property int $minimum_responses database column
 */
class QuestionnaireEvalCentralProfile extends SimpleORMap
{
    public const RESULT_VISIBILITY_OPTIONS =
        ['never' => 'Nie', 'afterending' => 'Nach Ende', 'afterparticipation' => 'Nach Teilnahme'];
    public const RESULT_VISIBLE_FOR_OPTIONS = ['autor' => 'Alle', 'tutor' => 'Tutor/-innen', 'dozent' => 'Lehrende'];

    protected static function configure($config = []): void
    {
        $config['db_table'] = 'questionnaire_eval_central_profiles';

        $config['belongs_to']['semester'] = [
            'class_name'        => Semester::class,
            'foreign_key'       => 'semester_id'
        ];

        $config['belongs_to']['template'] = [
            'class_name'        => Questionnaire::class,
            'foreign_key'       => 'template_id',
            'assoc_foreign_key' => 'questionnaire_id'
        ];

        parent::configure($config);
    }

    public static function getTranslatedVisibilityOptions(bool $is_for = false): array
    {
        return array_map(
            function ($option) {
                return _($option);
            },
            $is_for ? self::RESULT_VISIBLE_FOR_OPTIONS : self::RESULT_VISIBILITY_OPTIONS
        );
    }
}