ILIAS  release_8 Revision v8.24
class.ilObjIndividualAssessmentGUI.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
37{
38 public const TAB_SETTINGS = 'settings';
39 public const TAB_INFO = 'info_short';
40 public const TAB_PERMISSION = 'perm_settings';
41 public const TAB_MEMBERS = 'members';
42 public const TAB_LP = 'learning_progress';
43 public const TAB_EXPORT = 'export';
44 public const TAB_META_DATA = "meta_data";
45
47 protected ilObjUser $usr;
52
53 public function __construct($data, int $id = 0, bool $call_by_reference = true, bool $prepare_output = true)
54 {
55 global $DIC;
56 $this->ilNavigationHistory = $DIC['ilNavigationHistory'];
57 $this->type = 'iass';
58 $this->tpl = $DIC['tpl'];
59 $this->ctrl = $DIC['ilCtrl'];
60 $this->usr = $DIC['ilUser'];
61 $this->error_object = $DIC['ilErr'];
62 $this->lng = $DIC['lng'];
63 $this->lng->loadLanguageModule('iass');
64 $this->tpl->loadStandardTemplate();
65 $this->refinery = $DIC->refinery();
66 $this->request_wrapper = $DIC->http()->wrapper()->query();
67
69 }
70
71 protected function addLocatorItems(): void
72 {
73 if (is_object($this->object)) {
74 $this->locator->addItem(
75 $this->object->getTitle(),
76 $this->ctrl->getLinkTarget($this, "view"),
77 "",
78 $this->object->getRefId()
79 );
80 }
81 }
82
83 protected function recordIndividualAssessmentRead(): void
84 {
86 $this->object->getType(),
87 $this->object->getRefId(),
88 $this->object->getId(),
89 $this->usr->getId()
90 );
91 }
92
93 public function executeCommand(): void
94 {
95 $next_class = $this->ctrl->getNextClass($this);
96 $cmd = $this->ctrl->getCmd();
97 $this->prepareOutput();
99
100 switch ($next_class) {
101 case 'ilpermissiongui':
102 $this->tabs_gui->activateTab(self::TAB_PERMISSION);
103 $ilPermissionGUI = new ilPermissionGUI($this);
104 $this->ctrl->forwardCommand($ilPermissionGUI);
105 break;
106 case 'ilindividualassessmentsettingsgui':
107 $this->tabs_gui->activateTab(self::TAB_SETTINGS);
108 $gui = $this->object->getSettingsGUI();
109 $this->ctrl->forwardCommand($gui);
110 break;
111 case 'ilindividualassessmentmembersgui':
112 $this->membersObject();
113 break;
114 case 'ilinfoscreengui':
115 $this->tabs_gui->activateTab(self::TAB_INFO);
116 $info = $this->buildInfoScreen();
117 $this->ctrl->forwardCommand($info);
118 break;
119 case 'illearningprogressgui':
120 if (!$this->object->accessHandler()->mayReadObject()) {
121 $this->handleAccessViolation();
122 }
123 $this->tabs_gui->activateTab(self::TAB_LP);
126 $this->object->getRefId(),
127 $this->usr->getId()
128 );
129 $this->ctrl->forwardCommand($learning_progress);
130 break;
131 case "ilcommonactiondispatchergui":
133 $this->ctrl->forwardCommand($gui);
134 break;
135 case "ilexportgui":
136 $this->tabs_gui->activateTab(self::TAB_EXPORT);
137 $exp_gui = new ilExportGUI($this); // $this is the ilObj...GUI class of the resource
138 $exp_gui->addFormat("xml");
139 $this->ctrl->forwardCommand($exp_gui);
140 break;
141 case 'ilobjectmetadatagui':
142 $this->checkPermissionBool("write");
143 $this->tabs_gui->activateTab(self::TAB_META_DATA);
144 $md_gui = new ilObjectMetaDataGUI($this->object);
145 $this->ctrl->forwardCommand($md_gui);
146 break;
147 case 'ilobjectcopygui':
148 $cp = new ilObjectCopyGUI($this);
149 $cp->setType('crs');
150 $this->ctrl->forwardCommand($cp);
151 break;
152 default:
153 if (!$cmd) {
154 $cmd = 'view';
155 if ($this->object->accessHandler()->mayEditMembers()) {
156 $this->ctrl->setCmdClass('ilIndividualassessmentmembersgui');
157 $cmd = 'members';
158 }
159 }
160 $cmd .= 'Object';
161 $this->$cmd();
162 }
163
164 $this->addHeaderAction();
165 }
166
167 public function viewObject(): void
168 {
169 $this->tabs_gui->activateTab(self::TAB_INFO);
170 $this->ctrl->setCmd('showSummary');
171 $this->ctrl->setCmdClass('ilinfoscreengui');
172 $info = $this->buildInfoScreen();
173 $this->ctrl->forwardCommand($info);
175 }
176
177 public function membersObject(): void
178 {
179 $this->tabs_gui->activateTab(self::TAB_MEMBERS);
180 $gui = $this->object->getMembersGUI();
181 $this->ctrl->forwardCommand($gui);
182 }
183
184 protected function buildInfoScreen(): ilInfoScreenGUI
185 {
186 $info = new ilInfoScreenGUI($this);
187 if ($this->object) {
188 $record_gui = new ilAdvancedMDRecordGUI(ilAdvancedMDRecordGUI::MODE_INFO, 'iass', $this->object->getId());
189 $record_gui->setInfoObject($info);
190 $record_gui->parse();
191
192 $info->addMetaDataSections($this->object->getId(), 0, $this->object->getType());
193
194 $info = $this->addGeneralDataToInfo($info);
195 if ($this->object->loadMembers()->userAllreadyMember($this->usr)) {
196 $info = $this->addMemberDataToInfo($info);
197 }
198 $info = $this->addContactDataToInfo($info);
199 }
200 return $info;
201 }
202
204 {
205 $member = $this->object->membersStorage()->loadMember($this->object, $this->usr);
206 $info->addSection($this->txt('grading_info'));
207 if ($member->finalized()) {
208 $info->addProperty($this->txt('grading'), $this->getEntryForStatus($member->LPStatus()));
209 }
210 if ($member->notify() && $member->finalized()) {
211 $info->addProperty($this->txt('grading_record'), nl2br($member->record()));
212 if (($member->viewFile()) && $member->fileName() && $member->fileName() != "") {
213 $tpl = new ilTemplate("tpl.iass_user_file_download.html", true, true, "Modules/IndividualAssessment");
214 $tpl->setVariable("FILE_NAME", $member->fileName());
215 $tpl->setVariable("HREF", $this->ctrl->getLinkTarget($this, "downloadFile"));
216 $info->addProperty($this->txt('iass_upload_file'), $tpl->get());
217 }
218 }
219
220 return $info;
221 }
222
223 protected function downloadFileObject(): void
224 {
225 $member = $this->object->membersStorage()->loadMember($this->object, $this->usr);
226 $file_storage = $this->object->getFileStorage();
227 $file_storage->setUserId($this->usr->getId());
228 $filepath = $file_storage->getAbsolutePath();
229 $filename = $member->fileName();
231 }
232
234 {
235 $content = $this->object->getSettings()->getContent();
236 if ($content !== null && $content !== '') {
237 $info->addSection($this->txt('general'));
238 $info->addProperty($this->txt('content'), $content);
239 }
240 return $info;
241 }
242
244 {
245 $info_settings = $this->object->getInfoSettings();
246 if ($this->shouldShowContactInfo($info_settings)) {
247 $info->addSection($this->txt('iass_contact_info'));
248 $info->addProperty($this->txt('iass_contact'), $info_settings->getContact());
249 $info->addProperty($this->txt('iass_responsibility'), $info_settings->getResponsibility());
250 $info->addProperty($this->txt('iass_phone'), $info_settings->getPhone());
251 $info->addProperty($this->txt('iass_mails'), $info_settings->getMails());
252 $info->addProperty($this->txt('iass_consultation_hours'), $info_settings->getConsultationHours());
253 }
254 return $info;
255 }
256
257 protected function shouldShowContactInfo(ilIndividualAssessmentInfoSettings $info_settings): bool
258 {
259 $val = $info_settings->getContact();
260 if ($val !== null && $val !== '') {
261 return true;
262 }
263 $val = $info_settings->getResponsibility();
264 if ($val !== null && $val !== '') {
265 return true;
266 }
267 $val = $info_settings->getPhone();
268 if ($val !== null && $val !== '') {
269 return true;
270 }
271 $val = $info_settings->getMails();
272 if ($val !== null && $val !== '') {
273 return true;
274 }
275 $val = $info_settings->getConsultationHours();
276 if ($val !== null && $val !== '') {
277 return true;
278 }
279 return false;
280 }
281
282 protected function getTabs(): void
283 {
284 if ($this->object->accessHandler()->mayEditMembers()
285 || $this->object->accessHandler()->mayGradeAnyUser()
286 || $this->object->accessHandler()->mayAmendAllUsers()
287 || $this->object->accessHandler()->mayViewAnyUser()) {
288 $this->tabs_gui->addTab(
289 self::TAB_MEMBERS,
290 $this->txt('il_iass_members'),
291 $this->getLinkTarget('members')
292 );
293 }
294
295 if ($this->object->accessHandler()->mayReadObject()) {
296 $this->tabs_gui->addTab(
297 self::TAB_INFO,
298 $this->txt('info_short'),
299 $this->getLinkTarget('info')
300 );
301 }
302
303 if ($this->object->accessHandler()->mayEditObject()) {
304 $this->tabs_gui->addTab(
305 self::TAB_SETTINGS,
306 $this->txt('settings'),
307 $this->getLinkTarget('settings')
308 );
309 }
310
311 if (($this->object->accessHandler()->mayViewAllUsers()
312 || $this->object->accessHandler()->mayGradeAllUsers()
313 || ($this->object->loadMembers()->userAllreadyMember($this->usr)
314 && $this->object->isActiveLP()))
316 $this->tabs_gui->addTab(
317 self::TAB_LP,
318 $this->txt('learning_progress'),
319 $this->ctrl->getLinkTargetByClass('illearningprogressgui')
320 );
321 }
322
323 if ($this->object->accessHandler()->mayEditObject()) {
324 $mdgui = new ilObjectMetaDataGUI($this->object);
325 $mdtab = $mdgui->getTab();
326 if ($mdtab) {
327 $this->tabs_gui->addTab(
328 self::TAB_META_DATA,
329 $this->txt("meta_data"),
330 $mdtab
331 );
332 }
333 }
334
335 if ($this->object->accessHandler()->mayEditObject()) {
336 $this->tabs_gui->addTarget(
337 self::TAB_EXPORT,
338 $this->ctrl->getLinkTargetByClass('ilexportgui', ''),
339 'export',
340 'ilexportgui'
341 );
342 }
343
344 if ($this->object->accessHandler()->mayEditPermissions()) {
345 $this->tabs_gui->addTarget(
346 self::TAB_PERMISSION,
347 $this->ctrl->getLinkTargetByClass('ilpermissiongui', 'perm'),
348 array(),
349 'ilpermissiongui'
350 );
351 }
352 parent::getTabs();
353 }
354
355 protected function getLinkTarget(string $cmd): string
356 {
357 if ($cmd == 'settings') {
358 return $this->ctrl->getLinkTargetByClass('ilindividualassessmentsettingsgui', 'edit');
359 }
360 if ($cmd == 'info') {
361 return $this->ctrl->getLinkTarget($this, 'view');
362 }
363 if ($cmd == 'members') {
364 return $this->ctrl->getLinkTargetByClass('ilindividualassessmentmembersgui', 'view');
365 }
366 return $this->ctrl->getLinkTarget($this, $cmd);
367 }
368
369 public function editObject(): void
370 {
371 $link = $this->getLinkTarget('settings');
372 $this->ctrl->redirectToURL($link);
373 }
374
376 {
377 return $this->initEditForm();
378 }
379
380 public function handleAccessViolation(): void
381 {
382 $this->error_object->raiseError($this->txt("msg_no_perm_read"), $this->error_object->WARNING);
383 }
384
385 public static function _goto(int $a_target, string $a_add = ''): void
386 {
387 global $DIC;
388 if ($DIC['ilAccess']->checkAccess('write', '', $a_target)) {
389 ilObjectGUI::_gotoRepositoryNode($a_target, 'edit');
390 }
391 if ($DIC['ilAccess']->checkAccess('read', '', $a_target)) {
393 }
394 }
395
396 protected function getEntryForStatus(int $status): string
397 {
398 switch ($status) {
400 return $this->txt('iass_status_pending');
402 return $this->txt('iass_status_completed');
404 return $this->txt('iass_status_failed');
405 default:
406 throw new ilIndividualAssessmentException("Status for id $status not found!");
407 }
408 }
409
410 protected function afterSave(ilObject $new_object): void
411 {
412 $this->tpl->setOnScreenMessage("success", $this->txt("iass_added"), true);
413 $this->ctrl->setParameter($this, "ref_id", $new_object->getRefId());
414 $this->ctrl->redirectToUrl($this->ctrl->getLinkTargetByClass(
415 'ilIndividualassessmentsettingsgui',
416 'edit',
417 '',
418 false,
419 false
420 ));
421 }
422
423 public function addToNavigationHistory(): void
424 {
425 if (!$this->getCreationMode()) {
426 if ($this->object->accessHandler()->mayReadObject()) {
427 $ref_id = $this->request_wrapper->retrieve("ref_id", $this->refinery->kindlyTo()->int());
428 $link = ilLink::_getLink($ref_id, "iass");
429 $this->ilNavigationHistory->addItem($ref_id, $link, 'iass');
430 }
431 }
432 }
433
434 protected function txt(string $code): string
435 {
436 return $this->lng->txt($code);
437 }
438}
$learning_progress
Definition: plugin.php:29
$filename
Definition: buildRTE.php:78
Builds data types.
Definition: Factory.php:21
static _recordReadEvent(string $a_type, int $a_ref_id, int $obj_id, int $usr_id, bool $isCatchupWriteEvents=true, $a_ext_rc=null, $a_ext_time=null)
static getInstanceFromAjaxCall()
(Re-)Build instance from ajax call
Error Handling & global info handling uses PEAR error class.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static deliverFileLegacy(string $a_file, ?string $a_filename=null, ?string $a_mime=null, ?bool $isInline=false, ?bool $removeAfterDelivery=false, ?bool $a_exit_after=true)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Class ilInfoScreenGUI.
addSection(string $a_title)
addProperty(string $a_name, string $a_value, string $a_link="")
add a property to current section
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Navigation History of Repository Items.
addItem(int $a_ref_id, string $a_link, string $a_type, string $a_title="", ?int $a_sub_obj_id=null, string $a_goto_link="")
Add an item to the stack.
For the purpose of streamlining the grading and learning-process status definition outside of tests,...
afterSave(ilObject $new_object)
Post (successful) object creation hook.
getTabs()
@abstract overwrite in derived GUI class of your object type
ILIAS HTTP Wrapper RequestWrapper $request_wrapper
__construct($data, int $id=0, bool $call_by_reference=true, bool $prepare_output=true)
static _goto(int $a_target, string $a_add='')
viewObject()
viewObject container presentation for "administration -> repository, trash, permissions"
addLocatorItems()
should be overwritten to add object specific items (repository items are preloaded)
shouldShowContactInfo(ilIndividualAssessmentInfoSettings $info_settings)
User class.
GUI class for the workflow of copying objects.
Class ilObjectGUI Basic methods of all Output classes.
ilGlobalTemplateInterface $tpl
checkPermissionBool(string $perm, string $cmd="", string $type="", ?int $ref_id=null)
addHeaderAction()
Add header action menu.
static _gotoRepositoryNode(int $ref_id, string $cmd="")
prepareOutput(bool $show_sub_objects=true)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
New PermissionGUI (extends from old ilPermission2GUI) RBAC related output.
This class represents a property form user interface.
special template class to simplify handling of ITX/PEAR
global $DIC
Definition: feed.php:28
Interface RequestWrapper.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
setVariable(string $variable, $value='')
Sets the given variable to the given value.
get(string $part=self::DEFAULT_BLOCK)
Renders the given block and returns the html string.
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc