ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
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;
53
54
55 public function __construct($data, int $id = 0, bool $call_by_reference = true, bool $prepare_output = true)
56 {
57 global $DIC;
58 $this->ilNavigationHistory = $DIC['ilNavigationHistory'];
59 $this->type = 'iass';
60 $this->tpl = $DIC['tpl'];
61 $this->ctrl = $DIC['ilCtrl'];
62 $this->usr = $DIC['ilUser'];
63 $this->error_object = $DIC['ilErr'];
64 $this->lng = $DIC['lng'];
65 $this->lng->loadLanguageModule('iass');
66 $this->tpl->loadStandardTemplate();
67 $this->refinery = $DIC->refinery();
68 $this->request_wrapper = $DIC->http()->wrapper()->query();
69 $this->irss = $DIC['resource_storage'];
70
72 }
73
74 protected function addLocatorItems(): void
75 {
76 if (is_object($this->object)) {
77 $this->locator->addItem(
78 $this->object->getTitle(),
79 $this->ctrl->getLinkTarget($this, "view"),
80 "",
81 $this->object->getRefId()
82 );
83 }
84 }
85
86 protected function recordIndividualAssessmentRead(): void
87 {
89 $this->object->getType(),
90 $this->object->getRefId(),
91 $this->object->getId(),
92 $this->usr->getId()
93 );
94 }
95
96 public function executeCommand(): void
97 {
98 $next_class = $this->ctrl->getNextClass($this);
99 $cmd = $this->ctrl->getCmd();
100 $this->prepareOutput();
101 $this->addToNavigationHistory();
102
103 switch ($next_class) {
104 case 'ilpermissiongui':
105 $this->tabs_gui->activateTab(self::TAB_PERMISSION);
106 $ilPermissionGUI = new ilPermissionGUI($this);
107 $this->ctrl->forwardCommand($ilPermissionGUI);
108 break;
109 case 'ilindividualassessmentsettingsgui':
110 $this->tabs_gui->activateTab(self::TAB_SETTINGS);
111 $gui = $this->object->getSettingsGUI();
112 $this->ctrl->forwardCommand($gui);
113 break;
114 case 'ilindividualassessmentmembersgui':
115 $this->membersObject();
116 break;
117 case 'ilinfoscreengui':
118 $this->tabs_gui->activateTab(self::TAB_INFO);
119 $info = $this->buildInfoScreen();
120 $this->ctrl->forwardCommand($info);
121 break;
122 case 'illearningprogressgui':
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()->mayViewAnyUser() || $this->object->accessHandler()->mayEditMembers()) {
156 $this->ctrl->redirectByClass(ilIndividualAssessmentMembersGUI::class, 'view');
157 }
158 }
159 if ($cmd === 'edit' && $this->object->accessHandler()->simulateMember()) {
160 $cmd = 'view';
161 }
162
163 $cmd .= 'Object';
164 $this->$cmd();
165 }
166
167 $this->addHeaderAction();
168 }
169
170 public function viewObject(): void
171 {
172 $this->tabs_gui->activateTab(self::TAB_INFO);
174 $this->ctrl->redirectByClass(ilInfoScreenGUI::class, 'showSummary');
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
195 if ($this->object->loadMembers()->userAllreadyMember($this->usr)) {
197 }
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, "components/ILIAS/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 if (
227 $member
228 && $member->notify()
229 && $member->finalized()
230 && $member->viewFile()
231 && $member->fileName()
232 && $member->fileName() != ""
233 ) {
234 $identifier = $member->getGrading()->getFile();
235 $resource_id = $this->irss->manage()->find($identifier);
236 if ($resource_id) {
237 $this->irss->consume()->download($resource_id)->run();
238 }
239 }
240 }
241
243 {
244 $content = $this->object->getSettings()->getContent();
245 if ($content !== null && $content !== '') {
246 $info->addSection($this->txt('general'));
247 $info->addProperty($this->txt('content'), $content);
248 }
249 return $info;
250 }
251
253 {
254 $info_settings = $this->object->getInfoSettings();
255 if ($this->shouldShowContactInfo($info_settings)) {
256 $info->addSection($this->txt('iass_contact_info'));
257 $info->addProperty($this->txt('iass_contact'), $info_settings->getContact());
258 $info->addProperty($this->txt('iass_responsibility'), $info_settings->getResponsibility());
259 $info->addProperty($this->txt('iass_phone'), $info_settings->getPhone());
260 $info->addProperty($this->txt('iass_mails'), $info_settings->getMails());
261 $info->addProperty($this->txt('iass_consultation_hours'), $info_settings->getConsultationHours());
262 }
263 return $info;
264 }
265
266 protected function shouldShowContactInfo(ilIndividualAssessmentInfoSettings $info_settings): bool
267 {
268 $val = $info_settings->getContact();
269 if ($val !== null && $val !== '') {
270 return true;
271 }
272 $val = $info_settings->getResponsibility();
273 if ($val !== null && $val !== '') {
274 return true;
275 }
276 $val = $info_settings->getPhone();
277 if ($val !== null && $val !== '') {
278 return true;
279 }
280 $val = $info_settings->getMails();
281 if ($val !== null && $val !== '') {
282 return true;
283 }
284 $val = $info_settings->getConsultationHours();
285 if ($val !== null && $val !== '') {
286 return true;
287 }
288 return false;
289 }
290
291 protected function getTabs(): void
292 {
293 if ($this->object->accessHandler()->mayEditMembers()
294 || $this->object->accessHandler()->mayGradeAnyUser()
295 || $this->object->accessHandler()->mayAmendAllUsers()
296 || $this->object->accessHandler()->mayViewAnyUser()) {
297 $this->tabs_gui->addTab(
298 self::TAB_MEMBERS,
299 $this->txt('il_iass_members'),
300 $this->getLinkTarget('members')
301 );
302 }
303
304 if ($this->object->accessHandler()->mayReadObject()) {
305 $this->tabs_gui->addTab(
306 self::TAB_INFO,
307 $this->txt('info_short'),
308 $this->getLinkTarget('info')
309 );
310 }
311
312 if ($this->object->accessHandler()->mayEditObject()) {
313 $this->tabs_gui->addTab(
314 self::TAB_SETTINGS,
315 $this->txt('settings'),
316 $this->getLinkTarget('settings')
317 );
318 }
319
320 if (($this->object->accessHandler()->mayViewAllUsers()
321 || $this->object->accessHandler()->mayEditLearningProgressSettings()
322 || ($this->object->loadMembers()->userAllreadyMember($this->usr)
323 && $this->object->isActiveLP()))
325 $this->tabs_gui->addTab(
326 self::TAB_LP,
327 $this->txt('learning_progress'),
328 $this->ctrl->getLinkTargetByClass('illearningprogressgui')
329 );
330 }
331
332 if ($this->object->accessHandler()->mayEditObject()) {
333 $mdgui = new ilObjectMetaDataGUI($this->object);
334 $mdtab = $mdgui->getTab();
335 if ($mdtab) {
336 $this->tabs_gui->addTab(
337 self::TAB_META_DATA,
338 $this->txt("meta_data"),
339 $mdtab
340 );
341 }
342 }
343
344 if ($this->object->accessHandler()->mayEditObject()) {
345 $this->tabs_gui->addTarget(
346 self::TAB_EXPORT,
347 $this->ctrl->getLinkTargetByClass('ilexportgui', ''),
348 'export',
349 'ilexportgui'
350 );
351 }
352
353 if ($this->object->accessHandler()->mayEditPermissions()) {
354 $this->tabs_gui->addTarget(
355 self::TAB_PERMISSION,
356 $this->ctrl->getLinkTargetByClass('ilpermissiongui', 'perm'),
357 array(),
358 'ilpermissiongui'
359 );
360 }
361 parent::getTabs();
362 }
363
364 protected function getLinkTarget(string $cmd): string
365 {
366 if ($cmd == 'settings') {
367 return $this->ctrl->getLinkTargetByClass('ilindividualassessmentsettingsgui', 'edit');
368 }
369 if ($cmd == 'info') {
370 return $this->ctrl->getLinkTarget($this, 'view');
371 }
372 if ($cmd == 'members') {
373 return $this->ctrl->getLinkTargetByClass('ilindividualassessmentmembersgui', 'view');
374 }
375 return $this->ctrl->getLinkTarget($this, $cmd);
376 }
377
378 public function editObject(): void
379 {
380 $link = $this->getLinkTarget('settings');
381 $this->ctrl->redirectToURL($link);
382 }
383
385 {
386 return $this->initEditForm();
387 }
388
389 public function handleAccessViolation(): void
390 {
391 $this->error_object->raiseError($this->txt("msg_no_perm_read"), $this->error_object->WARNING);
392 }
393
394 public static function _goto(string $a_target, string $a_add = ''): void
395 {
396 global $DIC;
397 $access = $DIC['ilAccess'];
398 $target = (int) $a_target;
399 if ($access->checkAccess('write', '', $target)) {
400 ilObjectGUI::_gotoRepositoryNode($target, 'edit');
401 }
402 if ($access->checkAccess('read', '', $target) ||
403 $access->checkAccess('visible', '', $target)
404 ) {
406 }
407 $err = $DIC["ilErr"];
408 $lng = $DIC->language();
409 $err->raiseError($lng->txt("msg_no_perm_read"), $err->FATAL);
410 }
411
412 protected function getEntryForStatus(int $status): string
413 {
414 switch ($status) {
416 return $this->txt('iass_status_pending');
418 return $this->txt('iass_status_completed');
420 return $this->txt('iass_status_failed');
421 default:
422 throw new ilIndividualAssessmentException("Status for id $status not found!");
423 }
424 }
425
426 protected function afterSave(ilObject $new_object): void
427 {
428 $this->tpl->setOnScreenMessage("success", $this->txt("iass_added"), true);
429 $this->ctrl->setParameter($this, "ref_id", $new_object->getRefId());
430 $this->ctrl->redirectToUrl($this->ctrl->getLinkTargetByClass(
431 'ilIndividualassessmentsettingsgui',
432 'edit',
433 '',
434 false,
435 false
436 ));
437 }
438
439 public function addToNavigationHistory(): void
440 {
441 if (!$this->getCreationMode()) {
442 if ($this->object->accessHandler()->mayReadObject()) {
443 $ref_id = $this->request_wrapper->retrieve("ref_id", $this->refinery->kindlyTo()->int());
444 $link = ilLink::_getLink($ref_id, "iass");
445 $this->ilNavigationHistory->addItem($ref_id, $link, 'iass');
446 }
447 }
448 }
449
450 protected function txt(string $code): string
451 {
452 return $this->lng->txt($code);
453 }
454}
$learning_progress
Definition: plugin.php:29
Builds data types.
Definition: Factory.php:36
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.
Export User Interface Class.
Class ilInfoScreenGUI.
addProperty(string $a_name, string $a_value, string $a_link="")
add a property to current section
txt(string $a_topic, string $a_default_lang_fallback_mod="")
gets the text for a given topic if the topic is not in the list, the topic itself with "-" will be re...
Class ilObjUserTrackingGUI.
Last visited history for 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(string $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.
ilAccessHandler $access
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)
ilLanguage $lng
Class ilObjectMetaDataGUI.
Class ilObject Basic functions for all objects.
This class represents a property form user interface.
special template class to simplify handling of ITX/PEAR
$info
Definition: entry_point.php:21
Interface RequestWrapper.
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.
Interface ilAccessHandler This interface combines all available interfaces which can be called via gl...
checkAccess(string $a_permission, string $a_cmd, int $a_ref_id, string $a_type="", ?int $a_obj_id=null, ?int $a_tree_id=null)
check access for an object (provide $a_type and $a_obj_id if available for better performance)
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
global $DIC
Definition: shib_login.php:26