ILIAS  release_7 Revision v7.30-3-g800a261c036
All Data Structures Namespaces Files Functions Variables Modules 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 {
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  {
74  $ilCtrl = $this->ctrl;
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;
98  $ilCtrl = $this->ctrl;
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
111  foreach ($se_nodes as $n_id => $title) {
112  $options[$n_id] = $title;
113  }
114  $si = new ilSelectInputGUI($lng->txt("skmg_please_select_self_skill"), "sn_id");
115  $si->setOptions($options);
116 
117  //$si->setInfo($lng->txt(""));
118  $ilToolbar->addInputItem($si, true);
119 
120  $ilToolbar->addFormButton($lng->txt("skmg_execute_self_evaluation"), "startSelfEvaluation");
121 
122  $table = new ilSelfEvaluationTableGUI($this, "listSelfEvaluations");
123 
124  $tpl->setContent($table->getHTML());
125  }
126 
127 
132  {
133  $ilCtrl = $this->ctrl;
134  $tpl = $this->tpl;
135  $lng = $this->lng;
136 
137  if (!is_array($_POST["id"]) || count($_POST["id"]) == 0) {
138  ilUtil::sendInfo($lng->txt("no_checkbox"), true);
139  $ilCtrl->redirect($this, "listSelfEvaluations");
140  } else {
141  $cgui = new ilConfirmationGUI();
142  $cgui->setFormAction($ilCtrl->getFormAction($this));
143  $cgui->setHeaderText($lng->txt("skmg_sure_delete_self_evaluation"));
144  $cgui->setCancel($lng->txt("cancel"), "listSelfEvaluations");
145  $cgui->setConfirm($lng->txt("delete"), "deleteSelfEvaluation");
146 
147  foreach ($_POST["id"] as $i) {
148  $se = new ilSkillSelfEvaluation((int) $i);
149  $se_title =
150  ilSkillTreeNode::_lookupTitle($se->getTopSkillId());
151  $cgui->addItem("id[]", $i, $se_title . ", " . $lng->txt("created") . ": " .
152  $se->getCreated() . ", " . $lng->txt("last_update") . ": " . $se->getLastUpdate());
153  }
154 
155  $tpl->setContent($cgui->getHTML());
156  }
157  }
158 
165  public function deleteSelfEvaluation()
166  {
167  $ilCtrl = $this->ctrl;
169 
170  if (is_array($_POST["id"])) {
171  foreach ($_POST["id"] as $i) {
172  $se = new ilSkillSelfEvaluation((int) $i);
173  if ($se->getUserId() == $ilUser->getId()) {
174  $se->delete();
175  }
176  }
177  }
178  ilUtil::sendSuccess("msg_obj_modified");
179  $ilCtrl->redirect($this, "listSelfEvaluations");
180  }
181 
182 
189  public function startSelfEvaluation($a_mode = "create")
190  {
191  $tpl = $this->tpl;
192  $ilCtrl = $this->ctrl;
193  $lng = $this->lng;
194 
195  $se = null;
196  if ($a_mode == "edit") {
197  $se = new ilSkillSelfEvaluation((int) $_GET["se_id"]);
198  $this->sn_id = $se->getTopSkillId();
199  }
200  ilUtil::sendInfo($lng->txt("skmg_please_select_your_skill_levels"));
201 
202  $se_tpl = new ilTemplate("tpl.self_evaluation.html", true, true, "Services/Skill");
203 
205  $cstep = (int) $_GET["step"];
206  $ilCtrl->setParameter($this, "step", $cstep);
207  $table = new ilSkillSelfEvalSkillTableGUI(
208  $this,
209  "startSelfEvaluation",
210  $steps[$cstep],
211  $se
212  );
213 
214  $se_tpl->setCurrentBlock("se_table");
215  $se_tpl->setVariable("SE_TABLE", $table->getHTML());
216  $se_tpl->parseCurrentBlock();
217 
218  $tb = new ilToolbarGUI();
219  if ($a_mode == "edit") {
220  if ($cstep > 0) {
221  $tb->addFormButton("< " . $lng->txt("skmg_previous_step"), "updateBackSelfEvaluation");
222  }
223  if ($cstep < count($steps) - 1) {
224  $tb->addFormButton($lng->txt("skmg_next_step") . " >", "updateSelfEvaluation");
225  } elseif ($cstep == count($steps) - 1) {
226  $tb->addFormButton($lng->txt("skmg_save_self_evaluation"), "updateSelfEvaluation");
227  }
228  } else {
229  if ($cstep < count($steps) - 1) {
230  $tb->addFormButton($lng->txt("skmg_next_step") . " >", "saveSelfEvaluation");
231  } elseif ($cstep == count($steps) - 1) {
232  $tb->addFormButton($lng->txt("skmg_save_self_evaluation"), "saveSelfEvaluation");
233  }
234  }
235  $se_tpl->setVariable("FORM_ACTION", $ilCtrl->getFormAction($this));
236  $se_tpl->setVariable("TOOLBAR", $tb->getHTML());
237  $tpl->setContent($se_tpl->get());
238  }
239 
246  public function saveSelfEvaluation()
247  {
249  $lng = $this->lng;
250  $ilCtrl = $this->ctrl;
251 
252  $se = new ilSkillSelfEvaluation();
253  $se->setUserId($ilUser->getId());
254  $se->setTopSkillId($_GET["sn_id"]);
255  if (is_array($_POST["se_sk"])) {
256  $se->setLevels($_POST["se_sk"]);
257  }
258  $se->create();
259 
261  $cstep = (int) $_GET["step"];
262 
263  if (count($steps)) {
264  $ilCtrl->setParameter($this, "step", 1);
265  $ilCtrl->setParameter($this, "se_id", $se->getId());
266  $ilCtrl->redirect($this, "editSelfEvaluation");
267  }
268 
269  ilUtil::sendInfo($lng->txt("msg_obj_modified"), true);
270  $ilCtrl->redirect($this, "");
271  }
272 
279  public function editSelfEvaluation()
280  {
281  $this->startSelfEvaluation("edit");
282  }
283 
290  public function updateBackSelfEvaluation()
291  {
292  $this->updateSelfEvaluation(true);
293  }
294 
295 
296 
303  public function updateSelfEvaluation($a_back = false)
304  {
306  $lng = $this->lng;
307  $ilCtrl = $this->ctrl;
308 
309  $se = new ilSkillSelfEvaluation((int) $_GET["se_id"]);
310 
311  if ($se->getUserId() == $ilUser->getId()) {
313  $cstep = (int) $_GET["step"];
314 
315  if (is_array($_POST["se_sk"])) {
316  $se->setLevels($_POST["se_sk"], true);
317  }
318  $se->update();
319 
320  if ($a_back) {
321  $ilCtrl->setParameter($this, "step", (int) $_GET["step"] - 1);
322  $ilCtrl->setParameter($this, "se_id", $se->getId());
323  $ilCtrl->redirect($this, "editSelfEvaluation");
324  } elseif (count($steps) - 1 > $cstep) {
325  $ilCtrl->setParameter($this, "step", (int) $_GET["step"] + 1);
326  $ilCtrl->setParameter($this, "se_id", $se->getId());
327  $ilCtrl->redirect($this, "editSelfEvaluation");
328  }
329 
330  ilUtil::sendInfo($lng->txt("msg_obj_modified"), true);
331  }
332 
333  $ilCtrl->redirect($this, "");
334  }
335 
339 
346  public function getPresentationView($a_user_id)
347  {
349 
350  $html = "";
351  foreach ($ses as $se) {
353  $html .= $this->form->getHTML() . "<br /><br />";
354  }
355 
356  return $html;
357  }
358 
363  {
364  $lng = $this->lng;
365 
366  $this->form = new ilPropertyFormGUI();
367 
369  $dates = ", " .
370  $lng->txt("created") . ": " .
372  new ilDateTime($se["created"], IL_CAL_DATETIME)
373  );
374  if ($se["created"] != $se["last_update"]) {
375  $dates .= ", " . $lng->txt("last_update") . ": " .
377  new ilDateTime($se["last_update"], IL_CAL_DATETIME)
378  );
379  }
381 
382  $se = new ilSkillSelfEvaluation($se["id"]);
383  $levels = $se->getLevels();
384 
385  $this->form->setTitle($lng->txt("skmg_self_evaluation") . $dates);
386 
387  $stree = new ilSkillTree();
388 
389  if ($stree->isInTree($se->getTopSkillId())) {
390  $cnode = $stree->getNodeData($se->getTopSkillId());
391  $childs = $stree->getSubTree($cnode);
392  foreach ($childs as $child) {
393  if ($child["type"] == "skll") {
394  // build title
395  $path = $stree->getPathFull($child["child"]);
396  $title = $sep = "";
397  foreach ($path as $p) {
398  if ($p["type"] != "skrt") {
399  $title .= $sep . $p["title"];
400  $sep = " > ";
401  }
402  }
403 
404  $sk = new ilBasicSkill($child["child"]);
405  $ls = $sk->getLevelData();
406 
407  $ne = new ilNonEditableValueGUI($title, "");
408  foreach ($ls as $ld) {
409  if ($ld["id"] == $levels[$child["child"]]) {
410  $ne->setValue($ld["title"]);
411  }
412  }
413  $this->form->addItem($ne);
414  }
415  }
416  }
417  }
418 }
static determineSteps($a_sn_id)
Determine steps.
const IL_CAL_DATETIME
This class represents a property form user interface.
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 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.
static formatDate(ilDateTime $date, $a_skip_day=false, $a_include_wd=false, $include_seconds=false)
Format a date public.
editSelfEvaluation()
Edit self evaluation.
user()
Definition: user.php:4
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.
global $DIC
Definition: goto.php:24
listSelfEvaluations()
List all self evaluations.
$steps
Definition: latex.php:3
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.
$ilUser
Definition: imgupload.php:18
Basic Skill.
$_POST["username"]
$i
Definition: metadata.php:24
Confirmation screen class.