ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
class.ilPortfolioPageGUI.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (c) 1998-2010 ILIAS open source, Extended GPL, see docs/LICENSE */
3 
4 include_once("./Services/COPage/classes/class.ilPageObjectGUI.php");
5 
19 {
20  const EMBEDDED_NO_OUTPUT = -99;
21 
22  protected $js_onload_code = array();
23  protected $additional = array();
24  protected $export_material = array("js"=>array(), "images"=>array(), "files"=>array());
25 
26  protected static $initialized = 0;
27 
31  function __construct($a_portfolio_id, $a_id = 0, $a_old_nr = 0, $a_enable_comments = true)
32  {
33  global $tpl;
34 
35  $this->portfolio_id = (int)$a_portfolio_id;
36  $this->enable_comments = (bool)$a_enable_comments;
37 
38  parent::__construct($this->getParentType(), $a_id, $a_old_nr);
39  $this->getPageObject()->setPortfolioId($this->portfolio_id);
40 
41  // content style
42  include_once("./Services/Style/Content/classes/class.ilObjStyleSheet.php");
43 
44  $tpl->setCurrentBlock("SyntaxStyle");
45  $tpl->setVariable("LOCATION_SYNTAX_STYLESHEET",
47  $tpl->parseCurrentBlock();
48 
49  $tpl->setCurrentBlock("ContentStyle");
50  $tpl->setVariable("LOCATION_CONTENT_STYLESHEET",
52  $tpl->parseCurrentBlock();
53  }
54 
55  function getParentType()
56  {
57  return "prtf";
58  }
59 
60  protected function getPageContentUserId($a_user_id)
61  {
62  // user id from content-xml
63  return $a_user_id;
64  }
65 
69  function executeCommand()
70  {
71  global $ilCtrl, $ilUser;
72 
73  $next_class = $this->ctrl->getNextClass($this);
74  $cmd = $this->ctrl->getCmd();
75 
76  switch($next_class)
77  {
78  case "ilobjbloggui":
79  // #12879 - we need the wsp-id for the keywords
80  include_once "Services/PersonalWorkspace/classes/class.ilWorkspaceTree.php";
81  $wsp_tree = new ilWorkspaceTree($ilUser->getId());
82  $blog_obj_id = (int)$this->getPageObject()->getTitle();
83  $blog_node_id = $wsp_tree->lookupNodeId($blog_obj_id);
84 
85  include_once "Modules/Blog/classes/class.ilObjBlogGUI.php";
86  $blog_gui = new ilObjBlogGUI($blog_node_id, ilObjBlogGUI::WORKSPACE_NODE_ID);
87  $blog_gui->disableNotes(!$this->enable_comments);
88  $blog_gui->prtf_embed = true; // disables prepareOutput()/getStandardTemplate() in blog
89  return $ilCtrl->forwardCommand($blog_gui);
90 
91  case "ilcalendarmonthgui":
92  // booking action
93  if($cmd && $cmd != "preview")
94  {
95  include_once('./Services/Calendar/classes/class.ilCalendarMonthGUI.php');
96  $month_gui = new ilCalendarMonthGUI(new ilDate());
97  return $ilCtrl->forwardCommand($month_gui);
98  }
99  // calendar month navigation
100  else
101  {
102  $ilCtrl->setParameter($this, "cmd", "preview");
103  return self::EMBEDDED_NO_OUTPUT;
104  }
105 
106  case "ilpageobjectgui":
107  die("Deprecated. ilPortfolioPage gui forwarding to ilpageobject");
108  return;
109 
110  default:
111  $this->setPresentationTitle($this->getPageObject()->getTitle());
112  return parent::executeCommand();
113  }
114  }
115 
121  function showPage()
122  {
123  global $ilUser;
124 
125  if(!$this->getPageObject())
126  {
127  return;
128  }
129 
130  switch($this->getPageObject()->getType())
131  {
133  return $this->renderBlog($ilUser->getId(), (int)$this->getPageObject()->getTitle());
134 
135  default:
136  $this->setTemplateOutput(false);
137  // $this->setPresentationTitle($this->getPageObject()->getTitle());
138  $output = parent::showPage();
139 
140  return $output;
141  }
142  }
143 
150  function getTabs($a_activate = "")
151  {
152  if(!$this->embedded)
153  {
154  parent::getTabs($a_activate);
155  }
156  }
157 
163  function setEmbedded($a_value)
164  {
165  $this->embedded = (bool)$a_value;
166  }
167 
173  function setAdditional($a_additional)
174  {
175  $this->additional = $a_additional;
176  }
177 
183  function getAdditional()
184  {
185  return $this->additional;
186  }
187 
188  function getJsOnloadCode()
189  {
190  return $this->js_onload_code;
191  }
192 
193  function postOutputProcessing($a_output)
194  {
195  $parts = array(
196  "Profile" => array("0-9", "a-z", "0-9a-z_;\W"), // user, mode, fields
197  "Verification" => array("0-9", "a-z", "0-9"), // user, type, id
198  "Blog" => array("0-9", "0-9", "0-9;\W"), // user, blog id, posting ids
199  "BlogTeaser" => array("0-9", "0-9", "0-9;\W"), // user, blog id, posting ids
200  "Skills" => array("0-9", "0-9"), // user, skill id
201  "SkillsTeaser" => array("0-9", "0-9"), // user, skill id
202  "ConsultationHours" => array("0-9", "a-z", "0-9;\W"), // user, mode, group ids
203  "ConsultationHoursTeaser" => array("0-9", "a-z", "0-9;\W"), // user, mode, group ids
204  "MyCourses" => array("0-9", "a-z*"), // user, sort
205  "MyCoursesTeaser" => array("0-9", "a-z*") // user, sort
206  );
207 
208  foreach($parts as $type => $def)
209  {
210  // #15732 - allow optional parts
211  $def_parts = array();
212  foreach($def as $part)
213  {
214  $is_opt = (substr($part, -1) == "*");
215  if(!$is_opt)
216  {
217  $def_parts[] = "#";
218  $end_marker = "+";
219  }
220  else
221  {
222  $def_parts[] = "#*";
223  $end_marker = "*";
224  $part = substr($part, 0, -1);
225  }
226  $def_parts[] = "([".$part."]".$end_marker.")";
227  }
228  $def = implode("", $def_parts);
229 
230  if(preg_match_all(
231  "/".$this->pl_start.$type.$def.$this->pl_end."/",
232  $a_output, $blocks))
233  {
234  foreach($blocks[0] as $idx => $block)
235  {
236  switch($type)
237  {
238  case "Profile":
239  case "Blog":
240  case "BlogTeaser":
241  case "Skills":
242  case "SkillsTeaser":
243  case "ConsultationHours":
244  case "ConsultationHoursTeaser":
245  case "MyCourses":
246  case "MyCoursesTeaser":
247  $subs = null;
248  if(trim($blocks[3][$idx]))
249  {
250  foreach(explode(";", $blocks[3][$idx]) as $sub)
251  {
252  if(trim($sub))
253  {
254  $subs[] = trim($sub);
255  }
256  }
257  }
258  $snippet = $this->{"render".$type}($blocks[1][$idx],
259  $blocks[2][$idx], $subs);
260  break;
261 
262  default:
263  $snippet = $this->{"render".$type}($blocks[1][$idx],
264  $blocks[2][$idx], $blocks[3][$idx]);
265  break;
266  }
267 
268  $snippet = $this->renderPageElement($type, $snippet);
269  $a_output = str_replace($block, $snippet, $a_output);
270  }
271  }
272  }
273 
274  return $a_output;
275  }
276 
277  protected function renderPageElement($a_type, $a_html)
278  {
279  return trim($a_html);
280  }
281 
282  protected function renderTeaser($a_type, $a_title, $a_options = null)
283  {
284  $options = "";
285  if($a_options)
286  {
287  $options = '<div class="il_Footer">'.$this->lng->txt("prtf_page_element_teaser_settings").
288  ": ".$a_options.'</div>';
289  }
290 
291  return '<div style="margin:5px" class="ilBox"><h3>'.$a_title.'</h3>'.
292  '<div class="il_Description_no_margin">'.$this->lng->txt("prtf_page_element_teaser_".$a_type).'</div>'.
293  $options.'</div>';
294  }
295 
296  protected function renderProfile($a_user_id, $a_type, array $a_fields = null)
297  {
298  global $ilCtrl;
299 
300  $user_id = $this->getPageContentUserId($a_user_id);
301 
302  if($this->getOutputMode() == "offline")
303  {
304  // profile picture is done in ilPortfolioHTMLExport
305 
306  $this->export_material["js"][] = "http://maps.google.com/maps/api/js?sensor=false";
307  $this->export_material["js"][] = "./Services/Maps/js/ServiceGoogleMaps.js";
308  $this->export_material["js"][] = "./Services/Maps/js/OpenLayers.js";
309  $this->export_material["js"][] = "./Services/Maps/js/ServiceOpenLayers.js";
310  }
311 
312  include_once("./Services/User/classes/class.ilPublicUserProfileGUI.php");
313  $pub_profile = new ilPublicUserProfileGUI($user_id);
314  $pub_profile->setEmbedded(true, ($this->getOutputMode() == "offline"));
315 
316  // full circle: additional was set in the original public user profile call
317  $pub_profile->setAdditional($this->getAdditional());
318 
319  if($a_type == "manual" && sizeof($a_fields))
320  {
321  $prefs = array();
322  foreach($a_fields as $field)
323  {
324  $field = trim($field);
325  if($field)
326  {
327  $prefs["public_".$field] = "y";
328  }
329  }
330 
331  $pub_profile->setCustomPrefs($prefs);
332  }
333 
334  if($this->getOutputMode() != "offline")
335  {
336  return $ilCtrl->getHTML($pub_profile);
337  }
338  else
339  {
340  return $pub_profile->getEmbeddable();
341  }
342  }
343 
344  protected function renderVerification($a_user_id, $a_type, $a_id)
345  {
346  global $objDefinition;
347 
348  // not used
349  // $user_id = $this->getPageContentUserId($a_user_id);
350 
351  $class = "ilObj".$objDefinition->getClassName($a_type)."GUI";
352  include_once $objDefinition->getLocation($a_type)."/class.".$class.".php";
353  $verification = new $class($a_id, ilObject2GUI::WORKSPACE_OBJECT_ID);
354 
355  if($this->getOutputMode() != "offline")
356  {
357  // direct download link
358  $this->ctrl->setParameter($this, "dlid", $a_id);
359  $url = $this->ctrl->getLinkTarget($this, "dl".$a_type);
360  $this->ctrl->setParameter($this, "dlid", "");
361  }
362  else
363  {
364  $file = $verification->object->getFilePath();
365  $url = "files/".basename($file);
366 
367  $this->export_material["files"][] = $file;
368  }
369 
370  return $verification->render(true, $url);
371  }
372 
373  protected function dltstv()
374  {
375  $id = $_GET["dlid"];
376  if($id)
377  {
378  include_once "Modules/Test/classes/class.ilObjTestVerificationGUI.php";
380  $verification->downloadFromPortfolioPage($this->getPageObject());
381  }
382  }
383 
384  protected function dlexcv()
385  {
386  $id = $_GET["dlid"];
387  if($id)
388  {
389  include_once "Modules/Exercise/classes/class.ilObjExerciseVerificationGUI.php";
391  $verification->downloadFromPortfolioPage($this->getPageObject());
392  }
393  }
394 
395  protected function dlcrsv()
396  {
397  $id = $_GET["dlid"];
398  if($id)
399  {
400  include_once "Modules/Course/classes/Verification/class.ilObjCourseVerificationGUI.php";
402  $verification->downloadFromPortfolioPage($this->getPageObject());
403  }
404  }
405 
406  protected function dlscov()
407  {
408  $id = $_GET["dlid"];
409  if($id)
410  {
411  include_once "Modules/ScormAicc/classes/Verification/class.ilObjSCORMVerificationGUI.php";
413  $verification->downloadFromPortfolioPage($this->getPageObject());
414  }
415  }
416 
417  protected function renderBlog($a_user_id, $a_blog_id, array $a_posting_ids = null)
418  {
419  global $ilCtrl;
420 
421  // not used
422  // $user_id = $this->getPageContentUserId($a_user_id);
423 
424  // full blog (separate tab/page)
425  if(!$a_posting_ids)
426  {
427  include_once "Modules/Blog/classes/class.ilObjBlogGUI.php";
428  $blog = new ilObjBlogGUI($a_blog_id, ilObject2GUI::WORKSPACE_OBJECT_ID);
429  $blog->disableNotes(!$this->enable_comments);
430  $blog->setContentStyleSheet();
431 
432  if($this->getOutputMode() != "offline")
433  {
434  return $ilCtrl->getHTML($blog);
435  }
436  else
437  {
438 
439  }
440  }
441  // embedded postings
442  else
443  {
444  $html = array();
445 
446  include_once "Modules/Blog/classes/class.ilObjBlog.php";
447  $html[] = ilObjBlog::_lookupTitle($a_blog_id);
448 
449  include_once "Modules/Blog/classes/class.ilBlogPostingGUI.php";
450  foreach($a_posting_ids as $post)
451  {
452  $page = new ilBlogPostingGUI(0, null, $post);
453  if($this->getOutputMode() != "offline")
454  {
455  $page->setOutputMode(IL_PAGE_PREVIEW);
456  }
457  else
458  {
459  $page->setOutputMode("offline");
460  }
461  $html[] = $page->showPage();
462  }
463 
464  return implode("\n", $html);
465  }
466  }
467 
468  protected function renderBlogTeaser($a_user_id, $a_blog_id, array $a_posting_ids = null)
469  {
470  // not used
471  // $user_id = $this->getPageContentUserId($a_user_id);
472 
473  $postings = "";
474  if($a_posting_ids)
475  {
476  $postings = array("<ul>");
477  include_once "Modules/Blog/classes/class.ilBlogPosting.php";
478  foreach($a_posting_ids as $post)
479  {
480  $post = new ilBlogPosting($post);
481  $postings[] = "<li>".$post->getTitle()." - ".
482  ilDatePresentation::formatDate($post->getCreated())."</li>";
483  }
484  $postings[] = "</ul>";
485  $postings = implode("\n", $postings);
486  }
487 
488  return $this->renderTeaser("blog", $this->lng->txt("obj_blog").' "'.
489  ilObject::_lookupTitle($a_blog_id).'"', $postings);
490  }
491 
492  protected function renderSkills($a_user_id, $a_skills_id)
493  {
494  if($this->getOutputMode() == "preview")
495  {
496  return $this->renderSkillsTeaser($a_user_id, $a_skills_id);
497  }
498 
499  $user_id = $this->getPageContentUserId($a_user_id);
500 
501  include_once "Services/Skill/classes/class.ilPersonalSkillsGUI.php";
502  $gui = new ilPersonalSkillsGUI();
503  if($this->getOutputMode() == "offline")
504  {
505  $gui->setOfflineMode("./files/");
506  }
507  $html = $gui->getSkillHTML($a_skills_id, $user_id);
508 
509  if($this->getOutputMode() == "offline")
510  {
511  $js = $gui->getTooltipsJs();
512  if(sizeof($js))
513  {
514  $this->js_onload_code = array_merge($this->js_onload_code, $js);
515  }
516  }
517 
518  return $html;
519  }
520 
521  protected function renderSkillsTeaser($a_user_id, $a_skills_id)
522  {
523  // not used
524  // $user_id = $this->getPageContentUserId($a_user_id);
525 
526  include_once "Services/Skill/classes/class.ilSkillTreeNode.php";
527 
528  return $this->renderTeaser("skills", $this->lng->txt("skills").' "'.
529  ilSkillTreeNode::_lookupTitle($a_skills_id).'"');
530  }
531 
532  protected function renderConsultationHoursTeaser($a_user_id, $a_mode, $a_group_ids)
533  {
534  // not used
535  // $user_id = $this->getPageContentUserId($a_user_id);
536 
537  if($a_mode == "auto")
538  {
539  $mode = $this->lng->txt("cont_cach_mode_automatic");
540  $groups = null;
541  }
542  else
543  {
544  $mode = $this->lng->txt("cont_cach_mode_manual");
545 
546  include_once "Services/Calendar/classes/ConsultationHours/class.ilConsultationHourGroups.php";
547  $groups = array();
548  foreach($a_group_ids as $grp_id)
549  {
550  $groups[] = ilConsultationHourGroups::lookupTitle($grp_id);
551  }
552  $groups = " (".implode(", ", $groups).")";
553  }
554 
555  $this->lng->loadLanguageModule("dateplaner");
556  return $this->renderTeaser("consultation_hours",
557  $this->lng->txt("app_consultation_hours"), $mode.$groups);
558  }
559 
560  protected function renderConsultationHours($a_user_id, $a_mode, $a_group_ids)
561  {
562  global $ilUser;
563 
564  if($this->getOutputMode() == "preview")
565  {
566  return $this->renderConsultationHoursTeaser($a_user_id, $a_mode, $a_group_ids);
567  }
568 
569  if($this->getOutputMode() == "offline")
570  {
571  return;
572  }
573 
574  $user_id = $this->getPageContentUserId($a_user_id);
575 
576  // only if not owner
577  if($ilUser->getId() != $user_id)
578  {
579  $_GET["bkid"] = $user_id;
580  }
581 
582  if($a_mode != "manual")
583  {
584  $a_group_ids = null;
585  }
586 
587  include_once('./Services/Calendar/classes/class.ilCalendarCategories.php');
588  ilCalendarCategories::_getInstance()->setCHUserId($user_id);
590 
591  if(!$_REQUEST["seed"])
592  {
593  $seed = new ilDate(time(), IL_CAL_UNIX);
594  }
595  else
596  {
597  $seed = new ilDate($_REQUEST["seed"], IL_CAL_DATE);
598  }
599 
600  include_once('./Services/Calendar/classes/class.ilCalendarMonthGUI.php');
601  $month_gui = new ilCalendarMonthGUI($seed);
602 
603  // custom schedule filter: handle booking group ids
604  include_once('./Services/Calendar/classes/class.ilCalendarScheduleFilterBookings.php');
605  $filter = new ilCalendarScheduleFilterBookings($user_id, $a_group_ids);
606  $month_gui->addScheduleFilter($filter);
607 
608  $this->tpl->addCss(ilUtil::getStyleSheetLocation('filesystem','delos.css','Services/Calendar'));
609 
610  $this->lng->loadLanguageModule("dateplaner");
611  return '<h3>'.$this->lng->txt("app_consultation_hours").'</h3>'.
612  $this->ctrl->getHTML($month_gui);
613  }
614 
615  protected function isMyCoursesActive()
616  {
617  $prfa_set = new ilSetting("prfa");
618  return (bool)$prfa_set->get("mycrs", true);
619  }
620 
621  protected function renderMyCoursesTeaser($a_user_id, $a_default_sorting)
622  {
623  // not used
624  // $user_id = $this->getPageContentUserId($a_user_id);
625 
626  $title = $this->isMyCoursesActive()
627  ? "my_courses"
628  : "my_courses_inactive";
629 
630  return $this->renderTeaser($title,
631  $this->lng->txt("prtf_page_element_my_courses_title"));
632  }
633 
634  protected function renderMyCourses($a_user_id, $a_default_sorting)
635  {
636  global $ilAccess, $ilUser, $ilCtrl;
637 
638  if($this->getOutputMode() == "preview")
639  {
640  return $this->renderMyCoursesTeaser($a_user_id, $a_default_sorting);
641  }
642 
643  if(!$this->isMyCoursesActive())
644  {
645  return;
646  }
647 
648  $img_path = null;
649  if($this->getOutputMode() == "offline")
650  {
651  $this->export_material["images"][] = "./templates/default/images/icon_crs.svg";
652  $this->export_material["images"][] = "./templates/default/images/icon_lobj.svg";
653  $this->export_material["images"][] = "./templates/default/images/scorm/complete.svg";
654  $this->export_material["images"][] = "./templates/default/images/scorm/not_attempted.svg";
655  $this->export_material["images"][] = "./templates/default/images/scorm/failed.svg";
656  $this->export_material["images"][] = "./templates/default/images/scorm/incomplete.svg";
657 
658  $img_path = "images/";
659  }
660 
661  $user_id = $this->getPageContentUserId($a_user_id);
662 
663  // sorting pref
664  if($_POST["srt"] &&
665  in_array($_POST["srt"], array("alpha", "loc")))
666  {
667  $ilUser->writePref("prtf_mcrs_sort", $_POST["srt"]);
668  }
669  $sorting = $ilUser->getPref("prtf_mcrs_sort");
670  if(!$sorting)
671  {
672  $sorting = $a_default_sorting;
673  }
674 
675  $data = $this->getCoursesOfUser($user_id, ($sorting == "loc"));
676  if(sizeof($data))
677  {
678  if($sorting != "loc")
679  {
680  $data = ilUtil::sortArray($data, "title", "ASC");
681  }
682  else
683  {
684  $data = ilUtil::sortArray($data, "path_sort", "ASC");
685  }
686 
687  $tpl = new ilTemplate("tpl.pc_my_courses.html", true, true, "Modules/Portfolio");
688  $tpl->setVariable("TITLE", $this->lng->txt("prtf_page_element_my_courses_title"));
689  $tpl->setVariable("INFO", $this->lng->txt("prtf_page_element_my_courses_info")); // #14464
690 
691  include_once("./Services/Tracking/classes/class.ilLearningProgressBaseGUI.php");
692  $this->lng->loadLanguageModule("trac");
693  $this->lng->loadLanguageModule("crs");
694 
695  include_once("./Services/Container/classes/class.ilContainerObjectiveGUI.php");
696  include_once("./Services/Link/classes/class.ilLink.php");
697 
698  // sorting
699  $options = array(
700  "alpha" => $this->lng->txt("cont_mycourses_sortorder_alphabetical"),
701  "loc" => $this->lng->txt("cont_mycourses_sortorder_location")
702  );
703  $tpl->setVariable("SORT_SELECT", ilUtil::formSelect($sorting, "srt", $options, false, true, 0, "",
704  array("onchange"=>"form.submit()")));
705 
706  $tpl->setVariable("SORT_FORM", $this->getCourseSortAction($ilCtrl));
707 
708  $old_path = null;
709 
710  foreach($data as $course)
711  {
712  if($sorting == "loc")
713  {
714  if($course["path"] != $old_path)
715  {
716  $tpl->setCurrentBlock("path_bl");
717  $tpl->setVariable("PATH", $course["path"]);
718  $tpl->parseCurrentBlock();
719 
720  $old_path = $course["path"];
721  }
722  }
723 
724  if(isset($course["lp_status"]))
725  {
726  $lp_icon = ilLearningProgressBaseGUI::_getImagePathForStatus($course["lp_status"]);
727  $lp_alt = ilLearningProgressBaseGUI::_getStatusText($course["lp_status"]);
728 
729  if($img_path)
730  {
731  $lp_icon = $img_path.basename($lp_icon);
732  }
733 
734  $tpl->setCurrentBlock("lp_bl");
735  $tpl->setVariable("LP_ICON_URL", $lp_icon);
736  $tpl->setVariable("LP_ICON_ALT", $lp_alt);
737  $tpl->parseCurrentBlock();
738  }
739 
740  $do_links = false;
741  if($ilUser->getId() != ANONYMOUS_USER_ID)
742  {
743  $do_links = $ilAccess->checkAccessOfUser($ilUser->getId(), "read", "", $course["ref_id"], "crs") ||
744  ($ilAccess->checkAccessOfUser($ilUser->getId(), "visible", "", $course["ref_id"], "crs") &&
745  $ilAccess->checkAccessOfUser($ilUser->getId(), "join", "", $course["ref_id"], "crs"));
746  }
747 
748  if(isset($course["objectives"]))
749  {
750  include_once './Modules/Course/classes/Objectives/class.ilLOSettings.php';
751  $loc_settings = ilLOSettings::getInstanceByObjId($course["obj_id"]);
752  $has_initial_test = (bool)$loc_settings->getInitialTest();
753 
754  foreach($course["objectives"] as $objtv)
755  {
756  if($do_links)
757  {
758  $params = array("oobj"=>$objtv["id"]);
759  $url = ilLink::_getLink($course["ref_id"], "crs", $params);
760 
761  // #15510
762  $url .= "#objtv_acc_".$objtv["id"];
763 
764  $tpl->setCurrentBlock("objective_link_bl");
765 
766  if(trim($objtv["desc"]))
767  {
768  $desc = nl2br($objtv["desc"]);
769  $tt_id = "objtvtt_".$objtv["id"]."_".((int)self::$initialized);
770 
771  include_once "Services/UIComponent/Tooltip/classes/class.ilTooltipGUI.php";
772  ilToolTipGUI::addTooltip($tt_id, $desc, "", "bottom center", "top center", false);
773 
774  $tpl->setVariable("OBJECTIVE_LINK_ID", $tt_id);
775  }
776 
777  $tpl->setVariable("OBJECTIVE_LINK_URL", $url);
778  $tpl->setVariable("OBJECTIVE_LINK_TITLE", $objtv["title"]);
779  $tpl->parseCurrentBlock();
780  }
781  else
782  {
783  $tpl->setCurrentBlock("objective_nolink_bl");
784  $tpl->setVariable("OBJECTIVE_NOLINK_TITLE", $objtv["title"]);
785  $tpl->parseCurrentBlock();
786  }
787 
788  $objtv_icon = ilUtil::getTypeIconPath("lobj", $objtv["id"]);
789  if($img_path)
790  {
791  $objtv_icon = $img_path.basename($objtv_icon);
792  }
793 
794  $tpl->setCurrentBlock("objective_bl");
795  $tpl->setVariable("OBJTV_ICON_URL", $objtv_icon);
796  $tpl->setVariable("OBJTV_ICON_ALT", $this->lng->txt("crs_objectives"));
797 
798  if($objtv["type"])
799  {
800  $tpl->setVariable("LP_OBJTV_PROGRESS",
801  ilContainerObjectiveGUI::buildObjectiveProgressBar($has_initial_test, $objtv["id"], $objtv, true, false, (int)self::$initialized));
802  }
803 
804  $tpl->parseCurrentBlock();
805  }
806 
807  $tpl->setCurrentBlock("objectives_bl");
808  $tpl->setVariable("OBJTV_LIST_CRS_ID", $course["obj_id"]);
809  $tpl->parseCurrentBlock();
810  }
811 
812  // always check against current user
813  if($do_links)
814  {
815  $tpl->setCurrentBlock("course_link_bl");
816  $tpl->setVariable("COURSE_LINK_TITLE", $course["title"]);
817  $tpl->setVariable("COURSE_LINK_URL", ilLink::_getLink($course["ref_id"]));
818  $tpl->parseCurrentBlock();
819  }
820  else
821  {
822  $tpl->setCurrentBlock("course_nolink_bl");
823  $tpl->setVariable("COURSE_NOLINK_TITLE", $course["title"]);
824  $tpl->parseCurrentBlock();
825  }
826 
827  $crs_icon = ilUtil::getTypeIconPath("crs", $course["obj_id"]);
828  if($img_path)
829  {
830  $crs_icon = $img_path.basename($crs_icon);
831  }
832 
833  $tpl->setCurrentBlock("course_bl");
834 
835  if(isset($course["objectives"]))
836  {
837  $tpl->setVariable("TOGGLE_CLASS", "ilPCMyCoursesToggle");
838  }
839  else
840  {
841  $tpl->setVariable("NO_TOGGLE", ' style="visibility:hidden;"');
842  }
843 
844  $tpl->setVariable("CRS_ICON_URL", $crs_icon);
845  $tpl->setVariable("CRS_ICON_ALT", $this->lng->txt("obj_crs"));
846  $tpl->parseCurrentBlock();
847  }
848 
849  // #15508
850  if(!self::$initialized)
851  {
852  $GLOBALS["tpl"]->addJavaScript("Modules/Portfolio/js/ilPortfolio.js");
853  $GLOBALS["tpl"]->addOnLoadCode("ilPortfolio.init()");
854  }
855  self::$initialized++;
856 
857  return $tpl->get();
858  }
859  }
860 
867  protected function getCourseSortAction($ctrl)
868  {
869  return $ctrl->getFormActionByClass("ilobjportfoliogui", "preview");
870  }
871 
872 
873  protected function getCoursesOfUser($a_user_id, $a_add_path = false)
874  {
875  global $tree;
876 
877  // see ilPDSelectedItemsBlockGUI
878 
879  include_once 'Modules/Course/classes/class.ilObjCourseAccess.php';
880  include_once 'Services/Membership/classes/class.ilParticipants.php';
881  $items = ilParticipants::_getMembershipByType($a_user_id, 'crs');
882 
883  $repo_title = $tree->getNodeData(ROOT_FOLDER_ID);
884  $repo_title = $repo_title["title"];
885  if($repo_title == "ILIAS")
886  {
887  $repo_title = $this->lng->txt("repository");
888  }
889 
890  $references = $lp_obj_refs = array();
891  foreach($items as $obj_id)
892  {
894  if(is_array($ref_id) && count($ref_id))
895  {
896  $ref_id = array_pop($ref_id);
897  if(!$tree->isDeleted($ref_id))
898  {
899  $visible = false;
900  $active = ilObjCourseAccess::_isActivated($obj_id, $visible, false);
901  if($active && $visible)
902  {
903  $references[$ref_id] = array(
904  'ref_id' => $ref_id,
905  'obj_id' => $obj_id,
906  'title' => ilObject::_lookupTitle($obj_id)
907  );
908 
909  if($a_add_path)
910  {
911  $path = array();
912  foreach($tree->getPathFull($ref_id) as $item)
913  {
914  $path[] = $item["title"];
915  }
916  // top level comes first
917  if(sizeof($path) == 2)
918  {
919  $path[0] = 0;
920  }
921  else
922  {
923  $path[0] = 1;
924  }
925  $references[$ref_id]["path_sort"] = implode("__", $path);
926  array_shift($path);
927  array_pop($path);
928  if(!sizeof($path))
929  {
930  array_unshift($path, $repo_title);
931  }
932  $references[$ref_id]["path"] = implode(" &rsaquo; ", $path);
933  }
934 
935  $lp_obj_refs[$obj_id] = $ref_id;
936  }
937  }
938  }
939  }
940 
941  // get lp data for valid courses
942 
943  if(sizeof($lp_obj_refs))
944  {
945  // listing the objectives should NOT depend on any LP status / setting
946  include_once 'Modules/Course/classes/class.ilObjCourse.php';
947  foreach($lp_obj_refs as $obj_id => $ref_id)
948  {
949  // only if set in DB (default mode is not relevant
951  {
952  $references[$ref_id]["objectives"] = $this->parseObjectives($obj_id, $a_user_id);
953  }
954  }
955 
956  // LP must be active, personal and not anonymized
957  include_once "Services/Tracking/classes/class.ilObjUserTracking.php";
961  {
962  // see ilLPProgressTableGUI
963  include_once "Services/Tracking/classes/class.ilTrQuery.php";
964  include_once "Services/Tracking/classes/class.ilLPStatusFactory.php";
965  $lp_data = ilTrQuery::getObjectsStatusForUser($a_user_id, $lp_obj_refs);
966  foreach($lp_data as $item)
967  {
968  $ref_id = $item["ref_ids"];
969  $references[$ref_id]["lp_status"] = $item["status"];
970  }
971  }
972  }
973 
974  return $references;
975  }
976 
977  protected function parseObjectives($a_obj_id, $a_user_id)
978  {
979  $res = array();
980 
981  // we need the collection for the correct order
982  include_once "Services/Tracking/classes/class.ilLPObjSettings.php";
983  include_once "Services/Tracking/classes/collection/class.ilLPCollectionOfObjectives.php";
985  $coll_objtv = $coll_objtv->getItems();
986  if($coll_objtv)
987  {
988  // #13373
989  $lo_results = $this->parseLOUserResults($a_obj_id, $a_user_id);
990 
991  include_once "Modules/Course/classes/Objectives/class.ilLOTestAssignments.php";
992  $lo_ass = ilLOTestAssignments::getInstance($a_obj_id);
993 
994  $tmp = array();
995 
996  include_once "Modules/Course/classes/class.ilCourseObjective.php";
997  foreach($coll_objtv as $objective_id)
998  {
999  $title = ilCourseObjective::lookupObjectiveTitle($objective_id, true);
1000 
1001  $tmp[$objective_id] = array(
1002  "id" => $objective_id,
1003  "title" => $title["title"],
1004  "desc" => $title["description"],
1005  "itest" => $lo_ass->getTestByObjective($objective_id, ilLOSettings::TYPE_TEST_INITIAL),
1006  "qtest" => $lo_ass->getTestByObjective($objective_id, ilLOSettings::TYPE_TEST_QUALIFIED)
1007  );
1008 
1009  if(array_key_exists($objective_id, $lo_results))
1010  {
1011  $lo_result = $lo_results[$objective_id];
1012  $tmp[$objective_id]["user_id"] = $lo_result["user_id"];
1013  $tmp[$objective_id]["result_perc"] = $lo_result["result_perc"];
1014  $tmp[$objective_id]["limit_perc"] = $lo_result["limit_perc"];
1015  $tmp[$objective_id]["status"] = $lo_result["status"];
1016  $tmp[$objective_id]["type"] = $lo_result["type"];
1017  $tmp[$objective_id]["initial"] = $lo_result["initial"];
1018  }
1019  }
1020 
1021  // order
1022  foreach($coll_objtv as $objtv_id)
1023  {
1024  $res[] = $tmp[$objtv_id];
1025  }
1026  }
1027 
1028  return $res;
1029  }
1030 
1031  // see ilContainerObjectiveGUI::parseLOUserResults()
1032  protected function parseLOUserResults($a_course_obj_id, $a_user_id)
1033  {
1034  $res = array();
1035 
1036  include_once "Modules/Course/classes/Objectives/class.ilLOUserResults.php";
1037  $lur = new ilLOUserResults($a_course_obj_id, $a_user_id);
1038  foreach($lur->getCourseResultsForUserPresentation() as $objective_id => $types)
1039  {
1040  // show either initial or qualified for objective
1041  if(isset($types[ilLOUserResults::TYPE_INITIAL]))
1042  {
1043  $initial_status = $types[ilLOUserResults::TYPE_INITIAL]["status"];
1044  }
1045 
1046  // qualified test has priority
1047  if(isset($types[ilLOUserResults::TYPE_QUALIFIED]))
1048  {
1051  $result["initial"] = $types[ilLOUserResults::TYPE_INITIAL];
1052  }
1053  else
1054  {
1057  }
1058 
1059  $result["initial_status"] = $initial_status;
1060 
1061  $res[$objective_id] = $result;
1062  }
1063 
1064  return $res;
1065  }
1066 
1067  public function getExportMaterial()
1068  {
1069  return $this->export_material;
1070  }
1071 }
1072 
1073 ?>
getCoursesOfUser($a_user_id, $a_add_path=false)
static getInstanceByObjId($a_obj_id)
get singleton instance
ILIAS Setting Class.
$path
Definition: aliased.php:25
static getInstance($a_container_id)
Get instance by container id.
renderBlog($a_user_id, $a_blog_id, array $a_posting_ids=null)
static lookupObjectiveTitle($a_objective_id, $a_add_description=false)
const IL_PAGE_PREVIEW
const IL_CRS_VIEW_OBJECTIVE
__construct($a_portfolio_id, $a_id=0, $a_old_nr=0, $a_enable_comments=true)
Constructor.
getPageObject()
Get Page Object.
Class ilBlogPosting.
Calendar schedule filter for consultation hour bookings.
static _lookupTitle($a_id)
$js
$result
setTemplateOutput($a_output=true)
static _getImagePathForStatus($a_status)
Get image path for status.
executeCommand()
execute command
static lookupTitle($a_group_id)
Lookup group title.
static getStyleSheetLocation($mode="output", $a_css_name="", $a_css_location="")
get full style sheet file name (path inclusive) of current user
$_GET["client_id"]
renderMyCourses($a_user_id, $a_default_sorting)
getAdditional()
Get Additonal Information.
Class ilBlogPosting GUI class.
static _getStatusText($a_status, $a_lng=null)
Get status alt text.
Class ilPageObjectGUI.
static _getMembershipByType($a_usr_id, $a_type, $a_only_member_role=false)
get membership by type Get course or group membership
$GLOBALS['loaded']
Global hash that tracks already loaded includes.
$cmd
Definition: sahs_server.php:35
setEmbedded($a_value)
Set embedded mode: will suppress tabs.
static _lookupTitle($a_id)
lookup object title
Portfolio page gui class.
$url
Definition: shib_logout.php:72
static _lookupViewMode($a_id)
lookup view mode of container
static getObjectsStatusForUser($a_user_id, array $obj_refs)
const IL_CAL_UNIX
static getTypeIconPath($a_type, $a_obj_id, $a_size='small')
Get type icon path path Return image path for icon_xxx.pngs Or (if enabled) path to custom icon Depre...
static sortArray($array, $a_array_sortby, $a_array_sortorder=0, $a_numeric=false, $a_keep_keys=false)
sortArray
static _getAllReferences($a_id)
get all reference ids of object
Tree handler for personal workspace.
global $ilCtrl
Definition: ilias.php:18
$a_type
Definition: workflow.php:93
Personal skills GUI class.
static _enabledUserRelatedData()
check wether user related tracking is enabled or not
if(!is_dir( $entity_dir)) exit("Fatal Error ([A-Za-z0-9]+)\+" &#(? foreach( $entity_files as $file) $output
GUI class for course verification.
GUI class for public user profile presentation.
static _enabledLearningProgress()
check wether learing progress is enabled or not
Class for single dates.
if(!is_array($argv)) $options
Class ilObjBlogGUI.
getTabs($a_activate="")
Set all tabs.
static formSelect($selected, $varname, $options, $multiple=false, $direct_text=false, $size="0", $style_class="", $attribs="", $disabled=false)
Builds a select form field with options and shows the selected option first.
GUI class for exercise verification.
renderSkills($a_user_id, $a_skills_id)
renderBlogTeaser($a_user_id, $a_blog_id, array $a_posting_ids=null)
special template class to simplify handling of ITX/PEAR
static formatDate(ilDateTime $date)
Format a date public.
renderSkillsTeaser($a_user_id, $a_skills_id)
setPresentationTitle($a_title="")
$ilUser
Definition: imgupload.php:18
static getSyntaxStylePath()
get syntax style path
static _getInstance($a_usr_id=0)
get singleton instance
Create styles array
The data for the language used.
static buildObjectiveProgressBar($a_has_initial_test, $a_objective_id, array $a_lo_result, $a_list_mode=false, $a_sub=false, $a_tt_suffix=null)
Render progressbar(s) for given objective and result data.
static _lookupTitle($a_obj_id, $a_tref_id=0)
Lookup Title.
static getContentStylePath($a_style_id)
get content style path
const IL_CAL_DATE
GUI class for test verification.
renderMyCoursesTeaser($a_user_id, $a_default_sorting)
$ref_id
Definition: sahs_server.php:39
setAdditional($a_additional)
Set Additonal Information.
renderTeaser($a_type, $a_title, $a_options=null)
renderVerification($a_user_id, $a_type, $a_id)
parseObjectives($a_obj_id, $a_user_id)
Add data(end) time
Method that wraps PHPs time in order to allow simulations with the workflow.
if(!file_exists("$old.txt")) if($old===$new) if(file_exists("$new.txt")) $file
renderPageElement($a_type, $a_html)
getCourseSortAction($ctrl)
Get course sort action.
static _isActivated($a_obj_id, &$a_visible_flag=null, $a_mind_member_view=true)
Is activated?
renderProfile($a_user_id, $a_type, array $a_fields=null)
GUI class for scorm verification.
$_POST["username"]
$html
Definition: example_001.php:87
$params
Definition: example_049.php:96
parseLOUserResults($a_course_obj_id, $a_user_id)
renderConsultationHoursTeaser($a_user_id, $a_mode, $a_group_ids)
renderConsultationHours($a_user_id, $a_mode, $a_group_ids)