ILIAS  release_4-3 Revision
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilSkillSelfEvaluationGUI.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (c) 1998-2010 ILIAS open source, Extended GPL, see docs/LICENSE */
3 
13 {
20  function __construct()
21  {
22  global $ilCtrl, $lng;
23 
24  $ilCtrl->saveParameter($this, array("se_id", "sn_id"));
25  $lng->loadLanguageModule("skmg");
26 
27  $this->readSelfEvaluation();
28 
29  $this->se_id = (int) $_GET["se_id"];
30  $this->sn_id = ((int) $_POST["sn_id"] > 0)
31  ? (int) $_POST["sn_id"]
32  : (int) $_GET["sn_id"];
33  $ilCtrl->setParameter($this, "sn_id", $this->sn_id);
34  }
35 
39  function executeCommand()
40  {
41  global $ilCtrl;
42 
43  $cmd = $ilCtrl->getCmd("listSelfEvaluations");
44  $this->$cmd();
45  }
46 
53  function readSelfEvaluation()
54  {
55 // $this->self_evaluation = new ilSelfEvaluation((int) $_GET[save_param]);
56  }
57 
62  {
63  global $tpl, $ilToolbar, $ilCtrl, $lng;
64 
65  $ilToolbar->setFormAction($ilCtrl->getFormAction($this));
66 
67  // desc
68  /*$ne = new ilNonEditableValueGUI($lng->txt("lang"), var);
69  $ne->setValue();
70  $ne->setInfo();
71  $this->form->addItem($ne);*/
72 
73  // select skill for self evaluation
74  include_once("./Services/Skill/classes/class.ilSkillTreeNode.php");
76  foreach ($se_nodes as $n_id => $title)
77  {
78 
79  $options[$n_id] = $title;
80  }
81  include_once("./Services/Form/classes/class.ilSelectInputGUI.php");
82  $si = new ilSelectInputGUI($lng->txt("skmg_please_select_self_skill"), "sn_id");
83  $si->setOptions($options);
84 
85  //$si->setInfo($lng->txt(""));
86  $ilToolbar->addInputItem($si, true);
87 
88  $ilToolbar->addFormButton($lng->txt("skmg_execute_self_evaluation"), "startSelfEvaluation");
89 
90  include_once("./Services/Skill/classes/class.ilSelfEvaluationTableGUI.php");
91  $table = new ilSelfEvaluationTableGUI($this, "listSelfEvaluations");
92 
93  $tpl->setContent($table->getHTML());
94  }
95 
96 
101  {
102  global $ilCtrl, $tpl, $lng;
103 
104  if (!is_array($_POST["id"]) || count($_POST["id"]) == 0)
105  {
106  ilUtil::sendInfo($lng->txt("no_checkbox"), true);
107  $ilCtrl->redirect($this, "listSelfEvaluations");
108  }
109  else
110  {
111  include_once("./Services/Skill/classes/class.ilSkillSelfEvaluation.php");
112  include_once("./Services/Skill/classes/class.ilSkillTreeNode.php");
113  include_once("./Services/Utilities/classes/class.ilConfirmationGUI.php");
114  $cgui = new ilConfirmationGUI();
115  $cgui->setFormAction($ilCtrl->getFormAction($this));
116  $cgui->setHeaderText($lng->txt("skmg_sure_delete_self_evaluation"));
117  $cgui->setCancel($lng->txt("cancel"), "listSelfEvaluations");
118  $cgui->setConfirm($lng->txt("delete"), "deleteSelfEvaluation");
119 
120  foreach ($_POST["id"] as $i)
121  {
122  $se = new ilSkillSelfEvaluation((int) $i);
123  $se_title =
124  ilSkillTreeNode::_lookupTitle($se->getTopSkillId());
125  $cgui->addItem("id[]", $i, $se_title.", ".$lng->txt("created").": ".
126  $se->getCreated().", ".$lng->txt("last_update").": ".$se->getLastUpdate());
127  }
128 
129  $tpl->setContent($cgui->getHTML());
130  }
131  }
132 
140  {
141  global $ilCtrl, $lng, $ilUser;
142 
143  include_once("./Services/Skill/classes/class.ilSkillSelfEvaluation.php");
144  if (is_array($_POST["id"]))
145  {
146  foreach ($_POST["id"] as $i)
147  {
148  $se = new ilSkillSelfEvaluation((int) $i);
149  if ($se->getUserId() == $ilUser->getId())
150  {
151  $se->delete();
152  }
153  }
154  }
155  ilUtil::sendSuccess("msg_obj_modified");
156  $ilCtrl->redirect($this, "listSelfEvaluations");
157  }
158 
159 
166  function startSelfEvaluation($a_mode = "create")
167  {
168  global $tpl, $ilCtrl, $lng;
169 
170  $se = null;
171  if ($a_mode == "edit")
172  {
173  include_once("./Services/Skill/classes/class.ilSkillSelfEvaluation.php");
174  $se = new ilSkillSelfEvaluation((int) $_GET["se_id"]);
175  $this->sn_id = $se->getTopSkillId();
176  }
177  ilUtil::sendInfo($lng->txt("skmg_please_select_your_skill_levels"));
178 
179  $se_tpl = new ilTemplate("tpl.self_evaluation.html", true, true, "Services/Skill");
180  include_once("./Services/Skill/classes/class.ilSkillSelfEvaluation.php");
181 
183  $cstep = (int) $_GET["step"];
184  $ilCtrl->setParameter($this, "step", $cstep);
185  include_once("./Services/Skill/classes/class.ilSkillSelfEvalSkillTableGUI.php");
186  $table = new ilSkillSelfEvalSkillTableGUI($this, "startSelfEvaluation",
187  $steps[$cstep], $se);
188 
189  $se_tpl->setCurrentBlock("se_table");
190  $se_tpl->setVariable("SE_TABLE", $table->getHTML());
191  $se_tpl->parseCurrentBlock();
192 
193  include_once("./Services/UIComponent/Toolbar/classes/class.ilToolbarGUI.php");
194  $tb = new ilToolbarGUI();
195  if ($a_mode == "edit")
196  {
197  if ($cstep > 0)
198  {
199  $tb->addFormButton("< ".$lng->txt("skmg_previous_step"), "updateBackSelfEvaluation");
200  }
201  if ($cstep < count($steps) - 1)
202  {
203  $tb->addFormButton($lng->txt("skmg_next_step")." >", "updateSelfEvaluation");
204  }
205  else if ($cstep == count($steps) - 1)
206  {
207  $tb->addFormButton($lng->txt("skmg_save_self_evaluation"), "updateSelfEvaluation");
208  }
209  }
210  else
211  {
212  if ($cstep < count($steps) - 1)
213  {
214  $tb->addFormButton($lng->txt("skmg_next_step")." >", "saveSelfEvaluation");
215  }
216  else if ($cstep == count($steps) - 1)
217  {
218  $tb->addFormButton($lng->txt("skmg_save_self_evaluation"), "saveSelfEvaluation");
219  }
220  }
221  $se_tpl->setVariable("FORM_ACTION", $ilCtrl->getFormAction($this));
222  $se_tpl->setVariable("TOOLBAR", $tb->getHTML());
223  $tpl->setContent($se_tpl->get());
224  }
225 
233  {
234  global $ilUser, $lng, $ilCtrl;
235 
236  include_once("./Services/Skill/classes/class.ilSkillSelfEvaluation.php");
237 
238  $se = new ilSkillSelfEvaluation();
239  $se->setUserId($ilUser->getId());
240  $se->setTopSkillId($_GET["sn_id"]);
241  if (is_array($_POST["se_sk"]))
242  {
243  $se->setLevels($_POST["se_sk"]);
244  }
245  $se->create();
246 
248  $cstep = (int) $_GET["step"];
249 
250  if (count($steps))
251  {
252  $ilCtrl->setParameter($this, "step", 1);
253  $ilCtrl->setParameter($this, "se_id", $se->getId());
254  $ilCtrl->redirect($this, "editSelfEvaluation");
255  }
256 
257  ilUtil::sendInfo($lng->txt("msg_obj_modified"), true);
258  $ilCtrl->redirect($this, "");
259  }
260 
268  {
269  $this->startSelfEvaluation("edit");
270  }
271 
279  {
280  $this->updateSelfEvaluation(true);
281  }
282 
283 
284 
291  function updateSelfEvaluation($a_back = false)
292  {
293  global $ilUser, $lng, $ilCtrl;
294 
295  include_once("./Services/Skill/classes/class.ilSkillSelfEvaluation.php");
296  $se = new ilSkillSelfEvaluation((int) $_GET["se_id"]);
297 
298  if ($se->getUserId() == $ilUser->getId())
299  {
301  $cstep = (int) $_GET["step"];
302 
303  if (is_array($_POST["se_sk"]))
304  {
305  $se->setLevels($_POST["se_sk"], true);
306  }
307  $se->update();
308 
309  if ($a_back)
310  {
311  $ilCtrl->setParameter($this, "step", (int) $_GET["step"] - 1);
312  $ilCtrl->setParameter($this, "se_id", $se->getId());
313  $ilCtrl->redirect($this, "editSelfEvaluation");
314  }
315  else if (count($steps) - 1 > $cstep)
316  {
317  $ilCtrl->setParameter($this, "step", (int) $_GET["step"] + 1);
318  $ilCtrl->setParameter($this, "se_id", $se->getId());
319  $ilCtrl->redirect($this, "editSelfEvaluation");
320  }
321 
322  ilUtil::sendInfo($lng->txt("msg_obj_modified"), true);
323  }
324 
325  $ilCtrl->redirect($this, "");
326  }
327 
331 
338  function getPresentationView($a_user_id)
339  {
340  include_once("./Services/Skill/classes/class.ilSkillSelfEvaluation.php");
342 
343  $html = "";
344  foreach ($ses as $se)
345  {
347  $html.= $this->form->getHTML()."<br /><br />";
348  }
349 
350  return $html;
351  }
352 
357  {
358  global $lng, $ilCtrl;
359 
360  include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
361  $this->form = new ilPropertyFormGUI();
362 
364  $dates = ", ".
365  $lng->txt("created").": ".
367  new ilDateTime($se["created"], IL_CAL_DATETIME));
368  if ($se["created"] != $se["last_update"])
369  {
370  $dates.= ", ".$lng->txt("last_update").": ".
372  new ilDateTime($se["last_update"], IL_CAL_DATETIME));
373  }
375 
376  $se = new ilSkillSelfEvaluation($se["id"]);
377  $levels = $se->getLevels();
378 
379  $this->form->setTitle($lng->txt("skmg_self_evaluation").$dates);
380 
381  include_once("./Services/Skill/classes/class.ilBasicSkill.php");
382  include_once("./Services/Skill/classes/class.ilSkillTree.php");
383  $stree = new ilSkillTree();
384 
385  if ($stree->isInTree($se->getTopSkillId()))
386  {
387  $cnode = $stree->getNodeData($se->getTopSkillId());
388  $childs = $stree->getSubTree($cnode);
389  foreach ($childs as $child)
390  {
391  if ($child["type"] == "skll")
392  {
393  // build title
394  $path = $stree->getPathFull($child["child"]);
395  $title = $sep = "";
396  foreach ($path as $p)
397  {
398  if ($p["type"] != "skrt")
399  {
400  $title.= $sep.$p["title"];
401  $sep = " > ";
402  }
403  }
404 
405  $sk = new ilBasicSkill($child["child"]);
406  $ls = $sk->getLevelData();
407 
408  $ne = new ilNonEditableValueGUI($title, "");
409  foreach ($ls as $ld)
410  {
411  if ($ld["id"] == $levels[$child["child"]])
412  {
413  $ne->setValue($ld["title"]);
414  }
415  }
416  $this->form->addItem($ne);
417  }
418  }
419  }
420 
421  }
422 
423 }
424 
425 ?>