aboutsummaryrefslogtreecommitdiff
path: root/app/controllers/evaluation.php
blob: 7ed30df8298cec606377a7f02c3d16a8ebd6d366 (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
<?php

# Lifter010: TODO
/**
 * vote.php - Votecontroller controller
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License as
 * published by the Free Software Foundation; either version 2 of
 * the License, or (at your option) any later version.
 */

class EvaluationController extends AuthenticatedController
{
    public function display_action($range_id)
    {
        // Bind some params
        URLHelper::bindLinkParam('show_expired', $null1);

        // Bind range_id
        $this->range_id = $range_id;

        $this->nobody = !$GLOBALS['user']->id || $GLOBALS['user']->id == 'nobody';

        // Check if we ned administration icons
        $this->admin = $range_id == $GLOBALS['user']->id || $GLOBALS['perm']->have_studip_perm('tutor', $range_id);

        // Load evaluations
        if (!$this->nobody) {
            $eval_db = new EvaluationDB();
            $this->evaluations = StudipEvaluation::findMany($eval_db->getEvaluationIDs($range_id, EVAL_STATE_ACTIVE));
        } else {
            $this->evaluations = [];
        }
        // Check if we got expired
        if (Request::get('show_expired')) {
            if ($this->admin) {
                $this->evaluations = array_merge($this->evaluations, StudipEvaluation::findMany($eval_db->getEvaluationIDs($range_id, EVAL_STATE_STOPPED)));
            }
        }

        // Special case: from widget and no data -> no output
        if (count($this->evaluations) === 0) {
            $this->render_nothing();
        } else {
            $this->visit();
        }
    }

    public function visit()
    {
        if ($GLOBALS['user']->id && $GLOBALS['user']->id != 'nobody' && Request::option('contentbox_open') && in_array(Request::option('contentbox_type'), words('vote eval'))) {
            object_set_visit(Request::option('contentbox_open'), Request::option('contentbox_type'));
        }
    }

    public function visit_action()
    {
        $this->visit();
        $this->render_nothing();
    }

}