1<?php
2
3/* Copyright (c) 1998-2011 ILIAS open source, Extended GPL, see docs/LICENSE */
4
5include_once("./Services/Table/classes/class.ilTable2GUI.php");
6
7/**
8 * Self evaluation, second simplier implementation
9 *
10 * @author Alex Killing <alex.killing@gmx.de>
11 * @version $Id$
12 *
13 * @ingroup ServicesSkill
14 */
15class ilSelfEvaluationSimpleTableGUI extends ilTable2GUI
16{
17    /**
18     * @var ilCtrl
19     */
20    protected $ctrl;
21
22    /**
23     * @var ilAccessHandler
24     */
25    protected $access;
26
27    /**
28     * @var ilObjUser
29     */
30    protected $user;
31
32
33    /**
34     * Constructor
35     */
36    public function __construct(
37        $a_parent_obj,
38        $a_parent_cmd,
39        $a_top_skill_id,
40        $a_tref_id,
41        $a_basic_skill_id
42    ) {
43        global $DIC;
44
45        $this->ctrl = $DIC->ctrl();
46        $this->lng = $DIC->language();
47        $this->access = $DIC->access();
48        $this->user = $DIC->user();
49
50        $ilCtrl = $DIC->ctrl();
51        $lng = $DIC->language();
52        $ilUser = $DIC->user();
53
54        $this->top_skill_id = $a_top_skill_id;
55        $this->tref_id = (int) $a_tref_id;
56        $this->basic_skill_id = $a_basic_skill_id;
57
58        $this->cur_level_id = ilPersonalSkill::getSelfEvaluation(
59            $ilUser->getId(),
60            $this->top_skill_id,
61            $this->tref_id,
62            $this->basic_skill_id
63        );
64
65        // build title
66        include_once("./Services/Skill/classes/class.ilSkillTree.php");
67        $stree = new ilSkillTree();
68        $path = $stree->getPathFull($this->basic_skill_id);
69        $title = $sep = "";
70        foreach ($path as $p) {
71            if ($p["type"] != "skrt") {
72                $title .= $sep . $p["title"];
73                $sep = " > ";
74            }
75        }
76
77        parent::__construct($a_parent_obj, $a_parent_cmd);
78        $this->setData($this->getLevels());
79        $this->setTitle($title);
80        $this->setLimit(9999);
81
82        $this->addColumn("", "", "", true);
83        $this->addColumn($this->lng->txt("skmg_skill_level"));
84        $this->addColumn($this->lng->txt("description"));
85
86        $this->setEnableHeader(true);
87        $this->setRowTemplate("tpl.simple_self_eval.html", "Services/Skill");
88        $this->disable("footer");
89        $this->setEnableTitle(true);
90
91        $this->addCommandButton(
92            "saveSelfEvaluation",
93            $lng->txt("save")
94        );
95        $this->setFormAction($ilCtrl->getFormAction($a_parent_obj));
96    }
97
98    /**
99     * Get levels
100     *
101     * @param
102     * @return
103     */
104    public function getLevels()
105    {
106        $lng = $this->lng;
107
108        include_once("./Services/Skill/classes/class.ilSkillTreeNodeFactory.php");
109        $this->skill = ilSkillTreeNodeFactory::getInstance($this->basic_skill_id);
110        $levels[] = array("id" => 0, "description" => $lng->txt("skmg_no_skills"));
111        foreach ($this->skill->getLevelData() as $k => $v) {
112            $levels[] = $v;
113        }
114
115        return $levels;
116    }
117
118    /**
119     * Fill table row
120     */
121    protected function fillRow($a_set)
122    {
123        $lng = $this->lng;
124        $ilCtrl = $this->ctrl;
125        $ilUser = $this->user;
126
127        include_once("./Services/Skill/classes/class.ilPersonalSkill.php");
128
129        if ($this->cur_level_id == $a_set["id"]) {
130            $this->tpl->setVariable("CHECKED", "checked='checked'");
131        }
132
133        $this->tpl->setVariable("LEVEL_ID", $a_set["id"]);
134        $this->tpl->setVariable("SKILL_ID", $this->basic_skill_id);
135        $this->tpl->setVariable("TXT_SKILL", $a_set["title"]);
136        $this->tpl->setVariable("TXT_SKILL_DESC", $a_set["description"]);
137    }
138}
139