3 declare(strict_types=1);
34 public function __construct(
object $a_parent_obj,
string $a_parent_cmd)
38 $this->
ctrl = $DIC->ctrl();
39 $this->
lng = $DIC->language();
40 $ilCtrl = $DIC->ctrl();
41 $lng = $DIC->language();
42 $ui_factory = $DIC->ui()->factory();
43 $ui_renderer = $DIC->ui()->renderer();
47 $this->rendered_checked_icon = $ui_renderer->render(
48 $ui_factory->symbol()->icon()->custom(
50 $lng->
txt(
'poll_answer_selected_alt_text'),
55 $this->
setId(
"ilobjpollusr");
63 foreach ($this->
getParentObject()->getObject()->getAnswers() as $answer) {
64 $this->answer_ids[] = (
int) ($answer[
"id"] ?? 0);
65 $this->
addColumn((
string) ($answer[
"answer"] ??
''),
"answer" . (
int) ($answer[
"id"] ?? 0));
71 $this->
lng->txt(
"poll_question") .
": \"" .
75 $this->
setFormAction($ilCtrl->getFormAction($a_parent_obj, $a_parent_cmd));
83 protected function getItems(array $a_answer_ids): void
87 foreach ($this->
getParentObject()->getObject()->getVotesByUsers() as $user_id => $vote) {
88 $answers = (array) ($vote[
"answers"] ?? []);
89 unset($vote[
"answers"]);
91 foreach ($a_answer_ids as $answer_id) {
92 $vote[
"answer" . $answer_id] = in_array($answer_id, $answers);
101 protected function fillRow(array $a_set): void
103 $this->tpl->setCurrentBlock(
"answer_bl");
104 foreach ($this->answer_ids as $answer_id) {
105 if ($a_set[
"answer" . $answer_id]) {
106 $this->tpl->setVariable(
"ANSWER", $this->rendered_checked_icon);
108 $this->tpl->setVariable(
"ANSWER",
" ");
110 $this->tpl->parseCurrentBlock();
113 $this->tpl->setVariable(
"LOGIN", (
string) ($a_set[
"login"] ??
''));
114 $this->tpl->setVariable(
"FIRSTNAME", (
string) ($a_set[
"firstname"] ??
''));
115 $this->tpl->setVariable(
"LASTNAME", (
string) ($a_set[
"lastname"] ??
''));
120 $a_csv->
addColumn((
string) ($a_set[
"login"] ??
''));
121 $a_csv->
addColumn((
string) ($a_set[
"lastname"] ??
''));
122 $a_csv->
addColumn((
string) ($a_set[
"firstname"] ??
''));
123 foreach ($this->answer_ids as $answer_id) {
124 if ($a_set[
"answer" . $answer_id]) {
135 $a_excel->
setCell($a_row, 0, (
string) ($a_set[
"login"] ??
''));
136 $a_excel->
setCell($a_row, 1, (
string) ($a_set[
"lastname"] ??
''));
137 $a_excel->
setCell($a_row, 2, (
string) ($a_set[
"firstname"] ??
''));
140 foreach ($this->answer_ids as $answer_id) {
141 if ($a_set[
"answer" . $answer_id]) {
142 $a_excel->
setCell($a_row, ++$col,
true);
144 $a_excel->
setCell($a_row, ++$col,
false);
setExportFormats(array $formats)
Set available export formats.
string $rendered_checked_icon
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...
setFormAction(string $a_form_action, bool $a_multipart=false)
fillRowExcel(ilExcel $a_excel, int &$a_row, array $a_set)
static getImagePath(string $img, string $module_path="", string $mode="output", bool $offline=false)
get image path (for images located in a template directory)
loadLanguageModule(string $a_module)
Load language module.
setCell(int $a_row, int $a_col, $a_value, ?string $a_datatype=null)
Set cell value.
__construct(object $a_parent_obj, string $a_parent_cmd)
getItems(array $a_answer_ids)
setDefaultOrderField(string $a_defaultorderfield)
setRowTemplate(string $a_template, string $a_template_dir="")
Set row template.
fillRowCSV(ilCSVWriter $a_csv, array $a_set)
setDefaultOrderDirection(string $a_defaultorderdirection)
setTitle(string $a_title, string $a_icon="", string $a_icon_alt="")
__construct(Container $dic, ilPlugin $plugin)
addColumn(string $a_text, string $a_sort_field="", string $a_width="", bool $a_is_checkbox_action_column=false, string $a_class="", string $a_tooltip="", bool $a_tooltip_with_html=false)
TableGUI class for poll users.