ILIAS  trunk Revision v11.0_alpha-2638-g80c1d007f79
class.ilCourseObjectiveListGUI.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=0);
26 {
30  public function init(): void
31  {
32  $this->static_link_enabled = true;
33  $this->delete_enabled = false;
34  $this->cut_enabled = false;
35  $this->subscribe_enabled = false;
36  $this->link_enabled = false;
37  $this->info_screen_enabled = false;
38  $this->progress_enabled = true;
39  $this->type = "lobj";
40  //$this->gui_class_name = "ilobjcoursegui";
41 
42  // general commands array
43  $this->commands = array();
44  }
45 
46  public function getObjectiveListItemHTML(
47  int $a_ref_id,
48  int $a_obj_id,
49  string $a_title,
50  string $a_description,
51  bool $a_manage = false
52  ): string {
53  $this->tpl = new ilTemplate(
54  "tpl.container_list_item.html",
55  true,
56  true,
57  "components/ILIAS/Container"
58  );
59 
60  /*
61  * Previously, ilObjectListGUI::initItem was called here, but changes were made
62  * to that method with the assumption that only repository objects would be referenced,
63  * breaking it here for objectives.
64  * Currently, we have to initialize what we need manually, and cross
65  * our fingers that no changes are made to e.g. ilObjectListGUI::insertDescription
66  * or ilObjectListGUI::insertIconsAndCheckboxes that break things again.
67  */
68  $this->ref_id = $a_ref_id;
69  $this->obj_id = $a_obj_id;
70  $this->setTitle($a_title);
71  $this->setDescription($a_description);
72 
73  $this->insertIconsAndCheckboxes();
74  $this->insertTitle();
75  $this->insertDescription();
76 
77  if (!$a_manage) {
78  $this->insertProgressInfo();
79  }
80  $this->insertPositionField();
81 
82  // subitems
83  $this->insertSubItems();
84 
85  // reset properties and commands
86  $this->cust_prop = array();
87  $this->cust_commands = array();
88  $this->sub_item_html = array();
89  $this->position_enabled = false;
90 
91  return $this->tpl->get();
92  }
93 
97  public function insertTitle(): void
98  {
99  if (
101  $this->user->getId(),
102  $this->getContainerObject()->getObject()->getId()
104  $this->user->getId(),
105  $this->getContainerObject()->getObject()->getId(),
107  )
108  ) {
109  $this->tpl->setVariable('DIV_CLASS', 'ilContainerListItemOuterHighlight');
110  } else {
111  $this->tpl->setVariable('DIV_CLASS', 'ilContainerListItemOuter');
112  }
113 
114  if (!$this->getCommandsStatus()) {
115  $this->tpl->setCurrentBlock("item_title");
116  $this->tpl->setVariable("TXT_TITLE", $this->getTitle());
117  $this->tpl->parseCurrentBlock();
118  return;
119  }
120  $this->tpl->setCurrentBlock("item_title_linked");
121  $this->tpl->setVariable("TXT_TITLE_LINKED", $this->getTitle());
122 
123  $this->ctrl->setParameterByClass("ilrepositorygui", "ref_id", $this->getContainerObject()->getObject()->getRefId());
124  $this->ctrl->setParameterByClass("ilrepositorygui", "objective_details", $this->obj_id);
125  $link = $this->ctrl->getLinkTargetByClass("ilrepositorygui", "");
126  $this->ctrl->setParameterByClass("ilrepositorygui", "ref_id", $this->ref_id);
127 
128  $this->tpl->setVariable("HREF_TITLE_LINKED", $link);
129  $this->tpl->parseCurrentBlock();
130  }
131 
135  public function insertProgressInfo(): void
136  {
137  $this->lng->loadLanguageModule('trac');
138  $this->tpl->setCurrentBlock('item_progress');
139 
141 
143  $this->user->getId(),
144  $this->getContainerObject()->getObject()->getId()
145  )) {
147  $this->tpl->setVariable('TXT_PROGRESS_INFO', $this->lng->txt('crs_objective_status'));
148  $this->tpl->setVariable(
149  'PROGRESS_ICON',
150  $icons->renderIconForStatus(ilLPStatus::LP_STATUS_NOT_ATTEMPTED_NUM)
151  );
152  break;
153 
156  $this->tpl->setVariable('TXT_PROGRESS_INFO', $this->lng->txt('crs_objective_pretest'));
158  $this->user->getId(),
159  $this->getContainerObject()->getObject()->getId(),
161  )) {
162  $this->tpl->setVariable(
163  'PROGRESS_ICON',
164  $icons->renderIconForStatus(ilLPStatus::LP_STATUS_FAILED_NUM)
165  );
166  } else {
167  $this->tpl->setVariable(
168  'PROGRESS_ICON',
169  $icons->renderIconForStatus(ilLPStatus::LP_STATUS_COMPLETED_NUM)
170  );
171  }
172  break;
173 
176  $this->tpl->setVariable('TXT_PROGRESS_INFO', $this->lng->txt('crs_objective_result'));
178  $this->user->getId(),
179  $this->getContainerObject()->getObject()->getId(),
181  )) {
182  $this->tpl->setVariable(
183  'PROGRESS_ICON',
184  $icons->renderIconForStatus(ilLPStatus::LP_STATUS_FAILED_NUM)
185  );
186  } else {
187  $this->tpl->setVariable(
188  'PROGRESS_ICON',
189  $icons->renderIconForStatus(ilLPStatus::LP_STATUS_COMPLETED_NUM)
190  );
191  }
192  break;
193  }
194  $this->tpl->parseCurrentBlock();
195  }
196 }
const LP_STATUS_COMPLETED_NUM
static isSuggested(int $a_usr_id, int $a_crs_id, int $a_objective_id)
setDescription(string $description)
static getInstance(int $variant=ilLPStatusIcons::ICON_VARIANT_DEFAULT, ?\ILIAS\UI\Renderer $renderer=null, ?\ILIAS\UI\Factory $factory=null)
getObjectiveListItemHTML(int $a_ref_id, int $a_obj_id, string $a_title, string $a_description, bool $a_manage=false)
static getStatus(int $a_usr_id, int $a_crs_id)
getTitle()
getTitle overwritten in class.ilObjLinkResourceList.php
const LP_STATUS_NOT_ATTEMPTED_NUM
List gui for course objectives.
const LP_STATUS_FAILED_NUM