ILIAS  release_9 Revision v9.13-25-g2c18ec4c24f
class.ilAppointmentPresentationExerciseGUI.php
Go to the documentation of this file.
1 <?php
2 
3 declare(strict_types=1);
4 
12 {
13  public function collectPropertiesAndActions(): void
14  {
15  global $DIC;
16 
17  $this->lng->loadLanguageModule("exc");
18 
19  $f = $DIC->ui()->factory();
20  $r = $DIC->ui()->renderer();
21 
22  $a_app = $this->appointment;
23  $exc_obj = new ilObjExercise($this->getObjIdForAppointment(), false);
24  //is this safe?
25 
26  $refs = $this->getReadableRefIds($this->getObjIdForAppointment());
27  $exc_ref = current($refs);
28 
29  // common section: title, location, parent info
30  $this->addCommonSection($a_app, $this->getObjIdForAppointment(), null, true);
31 
32  //Assignment title information
33  $this->addInfoSection($this->lng->txt("cal_exc_info"));
34 
35  //var_dump($a_app); exit;
36  $ass_id = $a_app["event"]->getContextId() / 10; // see ilExAssignment->handleCalendarEntries $dl parameter
37  $assignment = new ilExAssignment($ass_id);
38  $state = ilExcAssMemberState::getInstanceByIds($assignment->getId(), $this->user->getId());
39  if ($state->areInstructionsVisible()) {
40  $assignment_instructions = trim($assignment->getInstruction());
41  if ($assignment_instructions != "") {
42  #21517
43  $is_html = (strlen($assignment_instructions) != strlen(strip_tags($assignment_instructions)));
44  if (!$is_html) {
45  $assignment_instructions = nl2br($assignment_instructions);
46  }
47  $this->addInfoProperty($this->lng->txt("exc_instruction"), $assignment_instructions);
48  }
49  $files = $assignment->getFiles();
50  if (count($files) > 0) {
51  $this->has_files = true;
52  $str_files = array();
53  foreach ($files as $file) {
54  $this->ctrl->setParameterByClass("ilexsubmissiongui", "ref_id", $exc_ref);
55  $this->ctrl->setParameterByClass("ilexsubmissiongui", "file", urlencode($file["name"]));
56  $this->ctrl->setParameterByClass("ilexsubmissiongui", "ass_id", $ass_id);
57  $url = $this->ctrl->getLinkTargetByClass(array("ilExerciseHandlerGUI",
58  "ilobjexercisegui",
59  ilAssignmentPresentationGUI::class, ilExSubmissionGUI::class
60  ), "downloadFile");
61  $this->ctrl->setParameterByClass("ilexsubmissiongui", "ass_id", "");
62  $this->ctrl->setParameterByClass("ilexsubmissiongui", "file", "");
63  $this->ctrl->setParameterByClass("ilexsubmissiongui", "ref_if", "");
64  $str_files[$file["name"]] = $r->render($f->button()->shy($file["name"], $url));
65  }
66  ksort($str_files, SORT_NATURAL | SORT_FLAG_CASE);
67  $str_files = implode("<br>", $str_files);
68  $this->addInfoProperty($this->lng->txt("exc_instruction_files"), $str_files);
69  $this->addListItemProperty(
70  $this->lng->txt("exc_instruction_files"),
71  str_replace("<br>", ", ", $str_files)
72  );
73  }
74  }
75 
76  //pass mode
77  if ($assignment->getMandatory()) {
78  $this->addInfoProperty($this->lng->txt("exc_mandatory"), $this->lng->txt("yes"));
79  $this->addListItemProperty($this->lng->txt("exc_mandatory"), $this->lng->txt("yes"));
80  } else {
81  $this->addInfoProperty($this->lng->txt("exc_mandatory"), $this->lng->txt("no"));
82  $this->addListItemProperty($this->lng->txt("exc_mandatory"), $this->lng->txt("no"));
83  }
84 
85  // last edited
86  $this->addLastUpdate($a_app);
87 
88  //go to the exercise.
89  $this->addAction(
90  $this->lng->txt("cal_exc_open"),
91  "goto.php?target=exc_" . $exc_ref . "_" . $ass_id . "&client_id=" . CLIENT_ID
92  );
93  }
94 
98  protected function buildDirectLinkForAppointment(int $a_ref_id, ?array $a_appointment = null): string
99  {
100  $ass_id = 0;
101  if (is_array($a_appointment)) {
102  $ass_id = $a_appointment["event"]->getContextId() / 10;
103  }
104  if (!$ass_id) {
105  return parent::buildDirectLinkForAppointment($a_ref_id, $a_appointment);
106  }
107  return ilLink::_getLink(
108  $a_ref_id,
109  'exc',
110  [],
111  '_' . $ass_id
112  );
113  }
114 }
Exercise assignment.
addListItemProperty(string $a_txt, string $a_val)
Add list item property.
buildDirectLinkForAppointment(int $a_ref_id, ?array $a_appointment=null)
addInfoSection(string $a_txt)
Add info section.
addInfoProperty(string $a_txt, string $a_val)
Add info property.
global $DIC
Definition: feed.php:28
addLastUpdate(array $a_app)
Add last update.
Class ilObjExercise.
const CLIENT_ID
Definition: constants.php:41
static getInstanceByIds(int $a_ass_id, int $a_user_id=0)
$url
Definition: ltiregstart.php:35
addCommonSection(array $a_app, int $a_obj_id=0, ?array $cat_info=null, bool $a_container_info=false)
addAction(string $a_txt, string $a_link)
Add action.
$r