ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
class.ilAppointmentPresentationExerciseGUI.php
Go to the documentation of this file.
1 <?php
2 include_once './Services/Calendar/interfaces/interface.ilCalendarAppointmentPresentation.php';
3 include_once './Services/Calendar/classes/AppointmentPresentation/class.ilAppointmentPresentationGUI.php';
4 
15 {
16  public function collectPropertiesAndActions()
17  {
18  global $DIC;
19 
20  $user_id = $DIC->user()->getId();
21 
22  $this->lng->loadLanguageModule("exc");
23 
24  include_once "./Modules/Exercise/classes/class.ilObjExercise.php";
25  include_once('./Services/Link/classes/class.ilLink.php');
26  include_once("./Modules/Exercise/classes/class.ilExAssignment.php");
27 
28  $f = $DIC->ui()->factory();
29  $r = $DIC->ui()->renderer();
30  $ctrl = $DIC->ctrl();
31 
32  $a_app = $this->appointment;
33  $exc_obj = new ilObjExercise($this->getObjIdForAppointment(), false);
34  //is this safe?
35 
36  $refs = $this->getReadableRefIds($this->getObjIdForAppointment());
37  $exc_ref = current($refs);
38 
39  // common section: title, location, parent info
40  $this->addCommonSection($a_app, $this->getObjIdForAppointment(), null, true);
41 
42  //Assignment title information
43  $this->addInfoSection($this->lng->txt("cal_exc_info"));
44 
45  //var_dump($a_app); exit;
46  $ass_id = $a_app["event"]->getContextId() / 10; // see ilExAssignment->handleCalendarEntries $dl parameter
47 
48  $assignment = new ilExAssignment($ass_id);
49  $state = ilExcAssMemberState::getInstanceByIds($assignment->getId(), $user_id);
50  if ($state->areInstructionsVisible()) {
51  $assignment_instructions = trim($assignment->getInstruction());
52  if ($assignment_instructions != "") {
53  #21517
54  $is_html = (strlen($assignment_instructions) != strlen(strip_tags($assignment_instructions)));
55  if (!$is_html) {
56  $assignment_instructions = nl2br($assignment_instructions);
57  }
58  $this->addInfoProperty($this->lng->txt("exc_instruction"), $assignment_instructions);
59  }
60  $files = $assignment->getFiles();
61  if (count($files) > 0) {
62  $this->has_files = true;
63  $str_files = array();
64  foreach ($files as $file) {
65  $ctrl->setParameterByClass("ilexsubmissiongui", "ref_id", $exc_ref);
66  $ctrl->setParameterByClass("ilexsubmissiongui", "file", urlencode($file["name"]));
67  $ctrl->setParameterByClass("ilexsubmissiongui", "ass_id", $ass_id);
68  $url = $ctrl->getLinkTargetByClass(array("ilExerciseHandlerGUI",
69  "ilobjexercisegui",
70  "ilexsubmissiongui"
71  ), "downloadFile");
72  $ctrl->setParameterByClass("ilexsubmissiongui", "ass_id", "");
73  $ctrl->setParameterByClass("ilexsubmissiongui", "file", "");
74  $ctrl->setParameterByClass("ilexsubmissiongui", "ref_if", "");
75  $str_files[$file["name"]] = $r->render($f->button()->shy($file["name"], $url));
76  }
77  ksort($str_files, SORT_NATURAL|SORT_FLAG_CASE);
78  $str_files = implode("<br>", $str_files);
79  $this->addInfoProperty($this->lng->txt("exc_instruction_files"), $str_files);
80  $this->addListItemProperty($this->lng->txt("exc_instruction_files"),
81  str_replace("<br>", ", ", $str_files));
82  }
83  }
84 
85  //pass mode
86  if ($assignment->getMandatory()) {
87  $this->addInfoProperty($this->lng->txt("exc_mandatory"), $this->lng->txt("yes"));
88  $this->addListItemProperty($this->lng->txt("exc_mandatory"), $this->lng->txt("yes"));
89  } else {
90  $this->addInfoProperty($this->lng->txt("exc_mandatory"), $this->lng->txt("no"));
91  $this->addListItemProperty($this->lng->txt("exc_mandatory"), $this->lng->txt("no"));
92  }
93 
94  // last edited
95  $this->addLastUpdate($a_app);
96 
97  //go to the exercise.
98  $this->addAction(
99  $this->lng->txt("cal_exc_open"),
100  "goto.php?target=exc_" . $exc_ref . "_" . $ass_id . "&client_id=" . CLIENT_ID
101  );
102  }
103 
107  protected function buildDirectLinkForAppointment($a_ref_id, $a_appointment = null)
108  {
109  $ass_id = 0;
110  if (is_array($a_appointment)) {
111  $ass_id = $a_appointment["event"]->getContextId() / 10;
112  }
113  if (!$ass_id) {
114  return parent::buildDirectLinkForAppointment($a_ref_id, $a_appointment);
115  }
116  return ilLink::_getLink(
117  $a_ref_id,
118  'exc',
119  [],
120  '_' . $ass_id
121  );
122  }
123 }
addInfoProperty($a_txt, $a_val)
Add info property.
Exercise assignment.
$files
Definition: metarefresh.php:49
getReadableRefIds($a_obj_id)
Get readable ref ids.
global $DIC
Definition: saml.php:7
static getInstanceByIds($a_ass_id, $a_user_id=0)
Get instance by IDs (recommended for consumer code)
if(!array_key_exists('stateid', $_REQUEST)) $state
Handle linkback() response from LinkedIn.
Definition: linkback.php:10
$r
Definition: example_031.php:79
Class ilObjExercise.
addCommonSection($a_app, $a_obj_id=0, $cat_info=null, $a_container_info=false)
Add common section.
addListItemProperty($a_txt, $a_val)
Add list item property.
$url