ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
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 {
17  protected $ctrl;
18 
22  protected $lng;
23 
27  protected $tpl;
28 
32  protected $toolbar;
33 
37  protected $user;
38 
45  public function __construct()
46  {
47  global $DIC;
48 
49  $this->ctrl = $DIC->ctrl();
50  $this->lng = $DIC->language();
51  $this->tpl = $DIC["tpl"];
52  $this->toolbar = $DIC->toolbar();
53  $this->user = $DIC->user();
54  $ilCtrl = $DIC->ctrl();
55  $lng = $DIC->language();
56 
57  $ilCtrl->saveParameter($this, array("se_id", "sn_id"));
58  $lng->loadLanguageModule("skmg");
59 
60  $this->readSelfEvaluation();
61 
62  $this->se_id = (int) $_GET["se_id"];
63  $this->sn_id = ((int) $_POST["sn_id"] > 0)
64  ? (int) $_POST["sn_id"]
65  : (int) $_GET["sn_id"];
66  $ilCtrl->setParameter($this, "sn_id", $this->sn_id);
67  }
68 
72  public function executeCommand()
73  {
75 
76  $cmd = $ilCtrl->getCmd("listSelfEvaluations");
77  $this->$cmd();
78  }
79 
86  public function readSelfEvaluation()
87  {
88  // $this->self_evaluation = new ilSelfEvaluation((int) $_GET[save_param]);
89  }
90 
94  public function listSelfEvaluations()
95  {
96  $tpl = $this->tpl;
97  $ilToolbar = $this->toolbar;
99  $lng = $this->lng;
100 
101  $ilToolbar->setFormAction($ilCtrl->getFormAction($this));
102 
103  // desc
104  /*$ne = new ilNonEditableValueGUI($lng->txt("lang"), var);
105  $ne->setValue();
106  $ne->setInfo();
107  $this->form->addItem($ne);*/
108 
109  // select skill for self evaluation
110  include_once("./Services/Skill/classes/class.ilSkillTreeNode.php");
112  foreach ($se_nodes as $n_id => $title) {
113  $options[$n_id] = $title;
114  }
115  include_once("./Services/Form/classes/class.ilSelectInputGUI.php");
116  $si = new ilSelectInputGUI($lng->txt("skmg_please_select_self_skill"), "sn_id");
117  $si->setOptions($options);
118 
119  //$si->setInfo($lng->txt(""));
120  $ilToolbar->addInputItem($si, true);
121 
122  $ilToolbar->addFormButton($lng->txt("skmg_execute_self_evaluation"), "startSelfEvaluation");
123 
124  include_once("./Services/Skill/classes/class.ilSelfEvaluationTableGUI.php");
125  $table = new ilSelfEvaluationTableGUI($this, "listSelfEvaluations");
126 
127  $tpl->setContent($table->getHTML());
128  }
129 
130 
135  {
137  $tpl = $this->tpl;
138  $lng = $this->lng;
139 
140  if (!is_array($_POST["id"]) || count($_POST["id"]) == 0) {
141  ilUtil::sendInfo($lng->txt("no_checkbox"), true);
142  $ilCtrl->redirect($this, "listSelfEvaluations");
143  } else {
144  include_once("./Services/Skill/classes/class.ilSkillSelfEvaluation.php");
145  include_once("./Services/Skill/classes/class.ilSkillTreeNode.php");
146  include_once("./Services/Utilities/classes/class.ilConfirmationGUI.php");
147  $cgui = new ilConfirmationGUI();
148  $cgui->setFormAction($ilCtrl->getFormAction($this));
149  $cgui->setHeaderText($lng->txt("skmg_sure_delete_self_evaluation"));
150  $cgui->setCancel($lng->txt("cancel"), "listSelfEvaluations");
151  $cgui->setConfirm($lng->txt("delete"), "deleteSelfEvaluation");
152 
153  foreach ($_POST["id"] as $i) {
154  $se = new ilSkillSelfEvaluation((int) $i);
155  $se_title =
156  ilSkillTreeNode::_lookupTitle($se->getTopSkillId());
157  $cgui->addItem("id[]", $i, $se_title . ", " . $lng->txt("created") . ": " .
158  $se->getCreated() . ", " . $lng->txt("last_update") . ": " . $se->getLastUpdate());
159  }
160 
161  $tpl->setContent($cgui->getHTML());
162  }
163  }
164 
171  public function deleteSelfEvaluation()
172  {
174  $lng = $this->lng;
176 
177  include_once("./Services/Skill/classes/class.ilSkillSelfEvaluation.php");
178  if (is_array($_POST["id"])) {
179  foreach ($_POST["id"] as $i) {
180  $se = new ilSkillSelfEvaluation((int) $i);
181  if ($se->getUserId() == $ilUser->getId()) {
182  $se->delete();
183  }
184  }
185  }
186  ilUtil::sendSuccess("msg_obj_modified");
187  $ilCtrl->redirect($this, "listSelfEvaluations");
188  }
189 
190 
197  public function startSelfEvaluation($a_mode = "create")
198  {
199  $tpl = $this->tpl;
201  $lng = $this->lng;
202 
203  $se = null;
204  if ($a_mode == "edit") {
205  include_once("./Services/Skill/classes/class.ilSkillSelfEvaluation.php");
206  $se = new ilSkillSelfEvaluation((int) $_GET["se_id"]);
207  $this->sn_id = $se->getTopSkillId();
208  }
209  ilUtil::sendInfo($lng->txt("skmg_please_select_your_skill_levels"));
210 
211  $se_tpl = new ilTemplate("tpl.self_evaluation.html", true, true, "Services/Skill");
212  include_once("./Services/Skill/classes/class.ilSkillSelfEvaluation.php");
213 
215  $cstep = (int) $_GET["step"];
216  $ilCtrl->setParameter($this, "step", $cstep);
217  include_once("./Services/Skill/classes/class.ilSkillSelfEvalSkillTableGUI.php");
219  $this,
220  "startSelfEvaluation",
221  $steps[$cstep],
222  $se
223  );
224 
225  $se_tpl->setCurrentBlock("se_table");
226  $se_tpl->setVariable("SE_TABLE", $table->getHTML());
227  $se_tpl->parseCurrentBlock();
228 
229  include_once("./Services/UIComponent/Toolbar/classes/class.ilToolbarGUI.php");
230  $tb = new ilToolbarGUI();
231  if ($a_mode == "edit") {
232  if ($cstep > 0) {
233  $tb->addFormButton("< " . $lng->txt("skmg_previous_step"), "updateBackSelfEvaluation");
234  }
235  if ($cstep < count($steps) - 1) {
236  $tb->addFormButton($lng->txt("skmg_next_step") . " >", "updateSelfEvaluation");
237  } elseif ($cstep == count($steps) - 1) {
238  $tb->addFormButton($lng->txt("skmg_save_self_evaluation"), "updateSelfEvaluation");
239  }
240  } else {
241  if ($cstep < count($steps) - 1) {
242  $tb->addFormButton($lng->txt("skmg_next_step") . " >", "saveSelfEvaluation");
243  } elseif ($cstep == count($steps) - 1) {
244  $tb->addFormButton($lng->txt("skmg_save_self_evaluation"), "saveSelfEvaluation");
245  }
246  }
247  $se_tpl->setVariable("FORM_ACTION", $ilCtrl->getFormAction($this));
248  $se_tpl->setVariable("TOOLBAR", $tb->getHTML());
249  $tpl->setContent($se_tpl->get());
250  }
251 
258  public function saveSelfEvaluation()
259  {
261  $lng = $this->lng;
263 
264  include_once("./Services/Skill/classes/class.ilSkillSelfEvaluation.php");
265 
266  $se = new ilSkillSelfEvaluation();
267  $se->setUserId($ilUser->getId());
268  $se->setTopSkillId($_GET["sn_id"]);
269  if (is_array($_POST["se_sk"])) {
270  $se->setLevels($_POST["se_sk"]);
271  }
272  $se->create();
273 
275  $cstep = (int) $_GET["step"];
276 
277  if (count($steps)) {
278  $ilCtrl->setParameter($this, "step", 1);
279  $ilCtrl->setParameter($this, "se_id", $se->getId());
280  $ilCtrl->redirect($this, "editSelfEvaluation");
281  }
282 
283  ilUtil::sendInfo($lng->txt("msg_obj_modified"), true);
284  $ilCtrl->redirect($this, "");
285  }
286 
293  public function editSelfEvaluation()
294  {
295  $this->startSelfEvaluation("edit");
296  }
297 
304  public function updateBackSelfEvaluation()
305  {
306  $this->updateSelfEvaluation(true);
307  }
308 
309 
310 
317  public function updateSelfEvaluation($a_back = false)
318  {
320  $lng = $this->lng;
322 
323  include_once("./Services/Skill/classes/class.ilSkillSelfEvaluation.php");
324  $se = new ilSkillSelfEvaluation((int) $_GET["se_id"]);
325 
326  if ($se->getUserId() == $ilUser->getId()) {
328  $cstep = (int) $_GET["step"];
329 
330  if (is_array($_POST["se_sk"])) {
331  $se->setLevels($_POST["se_sk"], true);
332  }
333  $se->update();
334 
335  if ($a_back) {
336  $ilCtrl->setParameter($this, "step", (int) $_GET["step"] - 1);
337  $ilCtrl->setParameter($this, "se_id", $se->getId());
338  $ilCtrl->redirect($this, "editSelfEvaluation");
339  } elseif (count($steps) - 1 > $cstep) {
340  $ilCtrl->setParameter($this, "step", (int) $_GET["step"] + 1);
341  $ilCtrl->setParameter($this, "se_id", $se->getId());
342  $ilCtrl->redirect($this, "editSelfEvaluation");
343  }
344 
345  ilUtil::sendInfo($lng->txt("msg_obj_modified"), true);
346  }
347 
348  $ilCtrl->redirect($this, "");
349  }
350 
354 
361  public function getPresentationView($a_user_id)
362  {
363  include_once("./Services/Skill/classes/class.ilSkillSelfEvaluation.php");
365 
366  $html = "";
367  foreach ($ses as $se) {
369  $html.= $this->form->getHTML() . "<br /><br />";
370  }
371 
372  return $html;
373  }
374 
379  {
380  $lng = $this->lng;
382 
383  include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
384  $this->form = new ilPropertyFormGUI();
385 
387  $dates = ", " .
388  $lng->txt("created") . ": " .
390  new ilDateTime($se["created"], IL_CAL_DATETIME)
391  );
392  if ($se["created"] != $se["last_update"]) {
393  $dates.= ", " . $lng->txt("last_update") . ": " .
395  new ilDateTime($se["last_update"], IL_CAL_DATETIME)
396  );
397  }
399 
400  $se = new ilSkillSelfEvaluation($se["id"]);
401  $levels = $se->getLevels();
402 
403  $this->form->setTitle($lng->txt("skmg_self_evaluation") . $dates);
404 
405  include_once("./Services/Skill/classes/class.ilBasicSkill.php");
406  include_once("./Services/Skill/classes/class.ilSkillTree.php");
407  $stree = new ilSkillTree();
408 
409  if ($stree->isInTree($se->getTopSkillId())) {
410  $cnode = $stree->getNodeData($se->getTopSkillId());
411  $childs = $stree->getSubTree($cnode);
412  foreach ($childs as $child) {
413  if ($child["type"] == "skll") {
414  // build title
415  $path = $stree->getPathFull($child["child"]);
416  $title = $sep = "";
417  foreach ($path as $p) {
418  if ($p["type"] != "skrt") {
419  $title.= $sep . $p["title"];
420  $sep = " > ";
421  }
422  }
423 
424  $sk = new ilBasicSkill($child["child"]);
425  $ls = $sk->getLevelData();
426 
427  $ne = new ilNonEditableValueGUI($title, "");
428  foreach ($ls as $ld) {
429  if ($ld["id"] == $levels[$child["child"]]) {
430  $ne->setValue($ld["title"]);
431  }
432  }
433  $this->form->addItem($ne);
434  }
435  }
436  }
437  }
438 }
static sendSuccess($a_info="", $a_keep=false)
Send Success Message to Screen.
static determineSteps($a_sn_id)
Determine steps.
const IL_CAL_DATETIME
This class represents a selection list property in a property form.
This class represents a property form user interface.
global $DIC
Definition: saml.php:7
Skill tree.
$_GET["client_id"]
static getAllSelfEvaluationsOfUser($a_user, $a_one_per_top_skill=false)
Get all self evaluations.
confirmSelfEvaluationDeletion()
Confirm self_evaluation deletion.
static formatDate(ilDateTime $date, $a_skip_day=false, $a_include_wd=false)
Format a date public.
static getAllSelfEvaluationNodes()
Get all self evaluation nodes.
static setUseRelativeDates($a_status)
set use relative dates
Self evaluation overview table.
updateSelfEvaluation($a_back=false)
Update self evaluation.
saveSelfEvaluation()
Save self evaluation.
updateBackSelfEvaluation()
Update self evaluation and go one step back.
getPresentationView($a_user_id)
Get presentation view.
$steps
Definition: latex.php:3
editSelfEvaluation()
Edit self evaluation.
user()
Definition: user.php:4
global $ilCtrl
Definition: ilias.php:18
static sendInfo($a_info="", $a_keep=false)
Send Info Message to Screen.
startSelfEvaluation($a_mode="create")
startSelfEvaluation
Self evaluation application class.
readSelfEvaluation()
Read self_evaluation.
special template class to simplify handling of ITX/PEAR
Date and time handling
listSelfEvaluations()
List all self evaluations.
$ilUser
Definition: imgupload.php:18
Create styles array
The data for the language used.
Self evaluation table for single skill.
static _lookupTitle($a_obj_id, $a_tref_id=0)
Lookup Title.
setSelfEvaluationPresentationForm($se)
Set self evaluation presentation form.
This class represents a non editable value in a property form.
deleteSelfEvaluation()
Delete self_evaluation.
$i
Definition: disco.tpl.php:19
if(empty($password)) $table
Definition: pwgen.php:24
Basic Skill.
$_POST["username"]
$html
Definition: example_001.php:87
if(!isset($_REQUEST['ReturnTo'])) if(!isset($_REQUEST['AuthId'])) $options
Definition: as_login.php:20
Confirmation screen class.