5 require_once
"./Services/Object/classes/class.ilObject2GUI.php";
20 function __construct($a_id = 0, $a_id_type = self::REPOSITORY_NODE_ID, $a_parent_node_id = 0)
26 $lng->loadLanguageModule(
"poll");
39 $ilCtrl->redirect($this,
"render");
48 include_once
"Services/Object/classes/class.ilObjectActivation.php";
49 $this->lng->loadLanguageModule(
'rep');
52 $section->setTitle($this->lng->txt(
'rep_activation_availability'));
56 $act_obj_info = $act_ref_info =
"";
59 $act_obj_info =
' '.$this->lng->txt(
'rep_activation_online_object_info');
60 $act_ref_info = $this->lng->txt(
'rep_activation_access_ref_info');
64 $online->
setInfo($this->lng->txt(
'poll_activation_online_info').$act_obj_info);
67 $act_type =
new ilCheckboxInputGUI($this->lng->txt(
'rep_visibility_until'),
'access_type');
70 $this->tpl->addJavaScript(
'./Services/Form/js/date_duration.js');
71 include_once
"Services/Form/classes/class.ilDateDurationInputGUI.php";
74 $date = $this->
object->getAccessBegin();
76 $dur->setStartText($this->lng->txt(
'rep_activation_limited_start'));
77 $date = $this->
object->getAccessEnd();
79 $dur->setEndText($this->lng->txt(
'rep_activation_limited_end'));
80 $act_type->addSubItem($dur);
88 $section->setTitle($this->lng->txt(
'poll_voting_period_and_results'));
94 $vdur->setShowTime(
true);
95 $date = $this->
object->getVotingPeriodBegin();
97 $vdur->setStartText($this->lng->txt(
'poll_voting_period_start'));
98 $date = $this->
object->getVotingPeriodEnd();
100 $vdur->setEndText($this->lng->txt(
'poll_voting_period_end'));
120 include_once
"Services/Object/classes/class.ilObjectActivation.php";
122 $a_values[
"online"] = $this->
object->IsOnline();
123 $a_values[
"results"] = $this->
object->getViewResults();
125 $a_values[
"period"] = $this->
object->getVotingPeriod();
130 $this->
object->setViewResults($a_form->
getInput(
"results"));
131 $this->
object->setOnline($a_form->
getInput(
"online"));
133 include_once
"Services/Object/classes/class.ilObjectActivation.php";
134 if($a_form->
getInput(
"access_type"))
139 $this->
object->setAccessBegin($period->getStart()->get(
IL_CAL_UNIX));
140 $this->
object->setAccessEnd($period->getEnd()->get(
IL_CAL_UNIX));
149 $this->
object->setVotingPeriod(1);
152 $this->
object->setVotingPeriodBegin($period->getStart()->get(
IL_CAL_UNIX));
153 $this->
object->setVotingPeriodEnd($period->getEnd()->get(
IL_CAL_UNIX));
157 $this->
object->setVotingPeriod(0);
163 global
$lng, $ilHelp;
165 $ilHelp->setScreenIdComponent(
"poll");
169 $this->tabs_gui->addTab(
"content",
170 $lng->txt(
"content"),
171 $this->ctrl->getLinkTarget($this,
""));
176 $this->tabs_gui->addTab(
"settings",
177 $lng->txt(
"settings"),
178 $this->ctrl->getLinkTarget($this,
"edit"));
180 $this->tabs_gui->addTab(
"participants",
181 $lng->txt(
"poll_result"),
182 $this->ctrl->getLinkTarget($this,
"showParticipants"));
184 $this->tabs_gui->addTab(
"export",
186 $this->ctrl->getLinkTargetByClass(
"ilexportgui",
""));
195 global
$ilCtrl,
$tpl, $ilTabs, $ilNavigationHistory;
197 $next_class = $ilCtrl->getNextClass($this);
198 $cmd = $ilCtrl->getCmd();
200 $tpl->getStandardTemplate();
206 $link = $ilCtrl->getLinkTargetByClass(
"ilrepositorygui",
"frameset");
207 $ilNavigationHistory->addItem($this->node_id, $link,
"poll");
212 case "ilinfoscreengui":
214 $this->infoScreenForward();
217 case "ilcommonactiondispatchergui":
218 include_once(
"Services/Object/classes/class.ilCommonActionDispatcherGUI.php");
220 $this->ctrl->forwardCommand($gui);
223 case "ilpermissiongui":
225 $ilTabs->activateTab(
"id_permissions");
226 include_once(
"Services/AccessControl/classes/class.ilPermissionGUI.php");
228 $this->ctrl->forwardCommand($perm_gui);
231 case "ilobjectcopygui":
232 include_once
"./Services/Object/classes/class.ilObjectCopyGUI.php";
234 $cp->setType(
"poll");
235 $this->ctrl->forwardCommand($cp);
240 $ilTabs->activateTab(
"export");
241 include_once(
"./Services/Export/classes/class.ilExportGUI.php");
243 $exp_gui->addFormat(
"xml");
244 $ilCtrl->forwardCommand($exp_gui);
271 $ilTabs->activateTab(
"content");
275 if($this->object->countVotes())
277 $url = $ilCtrl->getLinkTarget($this,
"showParticipants");
279 " <a href=\"".$url.
"\">»".$lng->txt(
"poll_result").
"</a>");
285 include_once(
'Services/PermanentLink/classes/class.ilPermanentLinkGUI.php');
288 $tpl->setContent($a_form->getHTML().$plink->getHTML());
295 include_once(
"Services/Form/classes/class.ilPropertyFormGUI.php");
297 $form->setFormAction($ilCtrl->getFormAction($this,
"saveQuestion"));
298 $form->setTitle($lng->txt(
"obj_poll"));
302 $question->setCols(40);
303 $question->setRows(2);
304 $question->setValue($this->object->getQuestion());
305 $question->setDisabled($a_read_only);
306 $form->addItem($question);
308 $dimensions =
" (".ilObjPoll::getImageSize().
"px)";
310 $img->setDisabled($a_read_only);
311 $form->addItem(
$img);
314 $file = $this->
object->getImageFullPath(
true);
320 $answers =
new ilTextInputGUI($lng->txt(
"poll_answers"),
"answers");
322 $answers->setMulti(
true,
true);
323 $answers->setDisabled($a_read_only);
324 $form->addItem($answers);
326 $multi_answers = array();
327 foreach($this->object->getAnswers() as $idx => $item)
331 $answers->setValue($item[
"answer"]);
333 $multi_answers[] = $item[
"answer"];
335 $answers->setMultiValues($multi_answers);
339 $form->addCommandButton(
"saveQuestion", $lng->txt(
"save"));
348 if($form->checkInput())
350 $this->
object->setQuestion($form->getInput(
"question"));
352 $image = $form->getItemByPostVar(
"image");
353 if($_FILES[
"image"][
"tmp_name"])
355 $this->
object->uploadImage($_FILES[
"image"]);
357 else if($image->getDeletionFlag())
359 $this->
object->deleteImage();
362 $this->
object->saveAnswers($form->getInput(
"answers"));
364 if($this->object->update())
367 $this->ctrl->redirect($this,
"render");
371 $form->setValuesByPost();
385 $ilTabs->activateTab(
"participants");
387 include_once
"Modules/Poll/classes/class.ilPollAnswerTableGUI.php";
389 $tpl->setContent($tbl->getHTML());
402 $ilTabs->activateTab(
"participants");
404 include_once(
"./Services/Utilities/classes/class.ilConfirmationGUI.php");
406 $cgui->setHeaderText($lng->txt(
"poll_delete_votes_sure"));
408 $cgui->setFormAction($this->ctrl->getFormAction($this));
409 $cgui->setCancel($lng->txt(
"cancel"),
"showParticipants");
410 $cgui->setConfirm($lng->txt(
"confirm"),
"deleteAllVotes");
412 $tpl->setContent($cgui->getHTML());
425 $this->
object->deleteAllVotes();
427 $ilCtrl->redirect($this,
"showParticipants");
436 $this->
object->saveVote($ilUser->getId(),
$_POST[
"aw"]);
439 include_once
"Services/Link/classes/class.ilLink.php";
457 if (is_object($this->
object))
459 $ilLocator->addItem($this->object->getTitle(), $this->ctrl->getLinkTarget($this,
""),
"",
$this->node_id);
472 $id = explode(
"_", $a_target);
475 $container_id = $tree->getParentId($id[0]);
478 include_once
"Services/Link/classes/class.ilLink.php";