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'));
117 $show_result_as =
new ilRadioGroupInputGUI($lng->txt(
"poll_show_results_as"),
"show_results_as");
121 $show_result_as->addOption($result_bar);
122 $show_result_as->addOption(
new ilRadioOption($lng->txt(
"poll_piechart"),
124 $a_form->
addItem($show_result_as);
128 $sort->addOption(
new ilRadioOption($lng->txt(
"poll_result_sorting_answers"), 0));
129 $sort->addOption(
new ilRadioOption($lng->txt(
"poll_result_sorting_votes"), 1));
133 $section->setTitle($this->lng->txt(
'poll_comments'));
143 include_once
"Services/Object/classes/class.ilObjectActivation.php";
145 $a_values[
"online"] = $this->
object->IsOnline();
146 $a_values[
"results"] = $this->
object->getViewResults();
148 $a_values[
"period"] = $this->
object->getVotingPeriod();
149 $a_values[
"sort"] = $this->
object->getSortResultByVotes();
150 $a_values[
"comment"] = $this->
object->getShowComments();
151 $a_values[
"show_results_as"] = $this->
object->getShowResultsAs();
161 $a_form->
getItemByPostVar(
"results")->setAlert($this->lng->txt(
"poll_view_results_after_period_impossible"));
169 $this->
object->setViewResults($a_form->
getInput(
"results"));
170 $this->
object->setOnline($a_form->
getInput(
"online"));
171 $this->
object->setSortResultByVotes($a_form->
getInput(
"sort"));
172 $this->
object->setShowComments($a_form->
getInput(
"comment"));
173 $this->
object->setShowResultsAs($a_form->
getInput(
"show_results_as"));
175 include_once
"Services/Object/classes/class.ilObjectActivation.php";
176 if($a_form->
getInput(
"access_type"))
181 $this->
object->setAccessBegin($period->getStart()->get(
IL_CAL_UNIX));
182 $this->
object->setAccessEnd($period->getEnd()->get(
IL_CAL_UNIX));
191 $this->
object->setVotingPeriod(1);
194 $this->
object->setVotingPeriodBegin($period->getStart()->get(
IL_CAL_UNIX));
195 $this->
object->setVotingPeriodEnd($period->getEnd()->get(
IL_CAL_UNIX));
199 $this->
object->setVotingPeriod(0);
205 global
$lng, $ilHelp;
207 $ilHelp->setScreenIdComponent(
"poll");
211 $this->tabs_gui->addTab(
"content",
212 $lng->txt(
"content"),
213 $this->ctrl->getLinkTarget($this,
""));
218 $this->tabs_gui->addTab(
"settings",
219 $lng->txt(
"settings"),
220 $this->ctrl->getLinkTarget($this,
"edit"));
222 $this->tabs_gui->addTab(
"participants",
223 $lng->txt(
"poll_result"),
224 $this->ctrl->getLinkTarget($this,
"showParticipants"));
226 $this->tabs_gui->addTab(
"export",
228 $this->ctrl->getLinkTargetByClass(
"ilexportgui",
""));
237 global
$ilCtrl,
$tpl, $ilTabs, $ilNavigationHistory;
239 $next_class = $ilCtrl->getNextClass($this);
240 $cmd = $ilCtrl->getCmd();
242 $tpl->getStandardTemplate();
248 $link = $ilCtrl->getLinkTargetByClass(
"ilrepositorygui",
"frameset");
249 $ilNavigationHistory->addItem($this->node_id, $link,
"poll");
254 case "ilinfoscreengui":
256 $this->infoScreenForward();
259 case "ilcommonactiondispatchergui":
260 include_once(
"Services/Object/classes/class.ilCommonActionDispatcherGUI.php");
262 $this->ctrl->forwardCommand($gui);
265 case "ilpermissiongui":
267 $ilTabs->activateTab(
"id_permissions");
268 include_once(
"Services/AccessControl/classes/class.ilPermissionGUI.php");
270 $this->ctrl->forwardCommand($perm_gui);
273 case "ilobjectcopygui":
274 include_once
"./Services/Object/classes/class.ilObjectCopyGUI.php";
276 $cp->setType(
"poll");
277 $this->ctrl->forwardCommand($cp);
282 $ilTabs->activateTab(
"export");
283 include_once(
"./Services/Export/classes/class.ilExportGUI.php");
285 $exp_gui->addFormat(
"xml");
286 $ilCtrl->forwardCommand($exp_gui);
313 $ilTabs->activateTab(
"content");
317 if($this->object->countVotes())
319 $url = $ilCtrl->getLinkTarget($this,
"showParticipants");
321 " <a href=\"".$url.
"\">»".$lng->txt(
"poll_result").
"</a>");
327 $tpl->setPermanentLink(
'poll', $this->node_id);
329 $tpl->setContent($a_form->getHTML());
336 include_once(
"Services/Form/classes/class.ilPropertyFormGUI.php");
338 $form->setFormAction($ilCtrl->getFormAction($this,
"saveQuestion"));
339 $form->setTitle($lng->txt(
"obj_poll"));
343 $question->setCols(40);
344 $question->setRows(2);
345 $question->setValue($this->object->getQuestion());
346 $question->setDisabled($a_read_only);
347 $form->addItem($question);
349 $dimensions =
" (".ilObjPoll::getImageSize().
"px)";
351 $img->setDisabled($a_read_only);
352 $form->addItem(
$img);
355 $file = $this->
object->getImageFullPath(
true);
363 $option =
new ilRadioOption($lng->txt(
"poll_mode_anonymous"), 0);
364 $option->
setInfo($lng->txt(
"poll_mode_anonymous_info"));
365 $anonymous->addOption($option);
366 $option =
new ilRadioOption($lng->txt(
"poll_mode_personal"), 1);
367 $option->
setInfo($lng->txt(
"poll_mode_personal_info"));
368 $anonymous->addOption($option);
369 $anonymous->setValue($this->object->getNonAnonymous());
370 $anonymous->setDisabled($a_read_only);
371 $form->addItem($anonymous);
373 $nanswers =
new ilNumberInputGUI($lng->txt(
"poll_max_number_of_answers"),
"nanswers");
375 $nanswers->setMinValue(1);
376 $nanswers->setSize(3);
377 $nanswers->setValue($this->object->getMaxNumberOfAnswers());
378 $nanswers->setDisabled($a_read_only);
379 $form->addItem($nanswers);
381 $answers =
new ilTextInputGUI($lng->txt(
"poll_answers"),
"answers");
383 $answers->setMulti(
true,
true);
384 $answers->setDisabled($a_read_only);
385 $form->addItem($answers);
387 $multi_answers = array();
388 foreach($this->object->getAnswers() as $idx => $item)
392 $answers->setValue($item[
"answer"]);
394 $multi_answers[] = $item[
"answer"];
396 $answers->setMultiValues($multi_answers);
400 $form->addCommandButton(
"saveQuestion", $lng->txt(
"save"));
409 if($form->checkInput())
411 $this->
object->setQuestion($form->getInput(
"question"));
412 $this->
object->setNonAnonymous($form->getInput(
"mode"));
414 $image = $form->getItemByPostVar(
"image");
415 if($_FILES[
"image"][
"tmp_name"])
417 $this->
object->uploadImage($_FILES[
"image"]);
419 else if($image->getDeletionFlag())
421 $this->
object->deleteImage();
424 $nr_of_anwers = $this->
object->saveAnswers($form->getInput(
"answers"));
427 $this->
object->setMaxNumberOfAnswers(min($form->getInput(
"nanswers"), $nr_of_anwers));
429 if($this->object->update())
432 $this->ctrl->redirect($this,
"render");
436 $form->setValuesByPost();
444 if(!$this->object->getNonAnonymous())
449 $ilTabs->addSubTab(
"result_answers", $lng->txt(
"poll_result_answers"),
450 $ilCtrl->getLinkTarget($this,
"showParticipants"));
451 $ilTabs->addSubTab(
"result_users", $lng->txt(
"poll_result_users"),
452 $ilCtrl->getLinkTarget($this,
"showParticipantVotes"));
454 $ilTabs->activateSubTab($a_active);
467 $ilTabs->activateTab(
"participants");
470 include_once
"Modules/Poll/classes/class.ilPollAnswerTableGUI.php";
472 $tpl->setContent($tbl->getHTML());
480 !$this->object->getNonAnonymous())
486 $ilTabs->activateTab(
"participants");
489 include_once
"Modules/Poll/classes/class.ilPollUserTableGUI.php";
491 $tpl->setContent($tbl->getHTML());
504 $ilTabs->activateTab(
"participants");
506 include_once(
"./Services/Utilities/classes/class.ilConfirmationGUI.php");
508 $cgui->setHeaderText($lng->txt(
"poll_delete_votes_sure"));
510 $cgui->setFormAction($this->ctrl->getFormAction($this));
511 $cgui->setCancel($lng->txt(
"cancel"),
"showParticipants");
512 $cgui->setConfirm($lng->txt(
"confirm"),
"deleteAllVotes");
514 $tpl->setContent($cgui->getHTML());
527 $this->
object->deleteAllVotes();
529 $ilCtrl->redirect($this,
"showParticipants");
537 if($this->object->getMaxNumberOfAnswers() > 1)
539 if(
sizeof(
$_POST[
"aw"]) > $this->
object->getMaxNumberOfAnswers())
558 unset(
$_SESSION[
"last_poll_vote"][$this->object->getId()]);
559 $this->
object->saveVote($ilUser->getId(),
$_POST[
"aw"]);
568 include_once
"Services/Link/classes/class.ilLink.php";
576 include_once
"./Services/Notification/classes/class.ilNotification.php";
580 include_once
"Services/Link/classes/class.ilLink.php";
588 include_once
"./Services/Notification/classes/class.ilNotification.php";
592 include_once
"Services/Link/classes/class.ilLink.php";
601 include_once
"./Services/Notification/classes/class.ilNotification.php";
603 $this->object->getId(), null,
true);
609 include_once
"./Services/Notification/classes/class.ilSystemNotification.php";
611 $ntf->setLangModules(array(
"poll"));
612 $ntf->setRefId($this->ref_id);
614 if($this->object->getNonAnonymous())
616 $ntf->setChangedByUserId($ilUser->getId());
619 $ntf->setSubjectLangId(
'poll_vote_notification_subject');
620 $ntf->setIntroductionLangId(
'poll_vote_notification_body');
621 $ntf->setGotoLangId(
'poll_vote_notification_link');
622 $ntf->setReasonLangId(
'poll_vote_notification_reason');
624 $notified = $ntf->sendMail($users, null,
"read");
643 if (is_object($this->
object))
645 $ilLocator->addItem($this->object->getTitle(), $this->ctrl->getLinkTarget($this,
""),
"",
$this->node_id);
654 public static function _goto($a_target)
656 global
$tree, $ilAccess;
658 $id = explode(
"_", $a_target);
662 if ($ilAccess->checkAccess(
"write",
"",
$ref_id))
664 $_GET[
"baseClass"] =
"ilRepositoryGUI";
666 $_GET[
"cmd"] =
"showParticipants";
667 include(
"ilias.php");
673 $container_id = $tree->getParentId(
$ref_id);
676 include_once
"Services/Link/classes/class.ilLink.php";