ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
class.ilPollUserTableGUI.php
Go to the documentation of this file.
1<?php
2/* Copyright (c) 1998-2009 ILIAS open source, Extended GPL, see docs/LICENSE */
3
4include_once("./Services/Table/classes/class.ilTable2GUI.php");
5
15{
16 protected $answer_ids; // [array]
17
18 public function __construct($a_parent_obj, $a_parent_cmd)
19 {
20 global $DIC;
21
22 $this->ctrl = $DIC->ctrl();
23 $this->lng = $DIC->language();
24 $ilCtrl = $DIC->ctrl();
25 $lng = $DIC->language();
26
27 $this->setId("ilobjpollusr");
28
29 parent::__construct($a_parent_obj, $a_parent_cmd);
30
31 $this->addColumn($lng->txt("login"), "login");
32 $this->addColumn($lng->txt("lastname"), "lastname");
33 $this->addColumn($lng->txt("firstname"), "firstname");
34
35 foreach ($this->getParentObject()->object->getAnswers() as $answer) {
36 $this->answer_ids[] = $answer["id"];
37 $this->addColumn($answer["answer"], "answer" . $answer["id"]);
38 }
39
40 $this->getItems($this->answer_ids);
41
42 $this->setTitle($this->lng->txt("poll_question") . ": \"" .
43 $this->getParentObject()->object->getQuestion() . "\"");
44
45 $this->setFormAction($ilCtrl->getFormAction($a_parent_obj, $a_parent_cmd));
46 $this->setRowTemplate("tpl.user_row.html", "Modules/Poll");
47 $this->setDefaultOrderField("login");
48 $this->setDefaultOrderDirection("asc");
49
50 $this->setExportFormats(array(self::EXPORT_CSV, self::EXPORT_EXCEL));
51 }
52
53 protected function getItems(array $a_answer_ids)
54 {
55 $data = array();
56
57 foreach ($this->getParentObject()->object->getVotesByUsers() as $user_id => $vote) {
58 $answers = $vote["answers"];
59 unset($vote["answers"]);
60
61 foreach ($a_answer_ids as $answer_id) {
62 $vote["answer" . $answer_id] = in_array($answer_id, $answers);
63 }
64
65 $data[] = $vote;
66 }
67
68 $this->setData($data);
69 }
70
71 protected function fillRow($a_set)
72 {
73 $this->tpl->setCurrentBlock("answer_bl");
74 foreach ($this->answer_ids as $answer_id) {
75 if ($a_set["answer" . $answer_id]) {
76 $this->tpl->setVariable("ANSWER", '<img src="' . ilUtil::getImagePath("icon_ok.svg") . '" />');
77 } else {
78 $this->tpl->setVariable("ANSWER", "&nbsp;");
79 }
80 $this->tpl->parseCurrentBlock();
81 }
82
83 $this->tpl->setVariable("LOGIN", $a_set["login"]);
84 $this->tpl->setVariable("FIRSTNAME", $a_set["firstname"]);
85 $this->tpl->setVariable("LASTNAME", $a_set["lastname"]);
86 }
87
88 protected function fillRowCSV($a_csv, $a_set)
89 {
90 $a_csv->addColumn($a_set["login"]);
91 $a_csv->addColumn($a_set["lastname"]);
92 $a_csv->addColumn($a_set["firstname"]);
93 foreach ($this->answer_ids as $answer_id) {
94 if ($a_set["answer" . $answer_id]) {
95 $a_csv->addColumn(true);
96 } else {
97 $a_csv->addColumn(false);
98 }
99 }
100 $a_csv->addRow();
101 }
102
103 protected function fillRowExcel(ilExcel $a_excel, &$a_row, $a_set)
104 {
105 $a_excel->setCell($a_row, 0, $a_set["login"]);
106 $a_excel->setCell($a_row, 1, $a_set["lastname"]);
107 $a_excel->setCell($a_row, 2, $a_set["firstname"]);
108
109 $col = 2;
110 foreach ($this->answer_ids as $answer_id) {
111 if ($a_set["answer" . $answer_id]) {
112 $a_excel->setCell($a_row, ++$col, true);
113 } else {
114 $a_excel->setCell($a_row, ++$col, false);
115 }
116 }
117 }
118}
An exception for terminatinating execution or to throw for unit testing.
setCell($a_row, $a_col, $a_value, $a_datatype=null)
Set cell value.
TableGUI class for poll users.
__construct($a_parent_obj, $a_parent_cmd)
Constructor.
fillRowExcel(ilExcel $a_excel, &$a_row, $a_set)
Excel Version of Fill Row.
getItems(array $a_answer_ids)
fillRow($a_set)
Standard Version of Fill Row.
fillRowCSV($a_csv, $a_set)
CSV Version of Fill Row.
Class ilTable2GUI.
setExportFormats(array $formats)
Set available export formats.
getParentObject()
Get parent object.
setTitle($a_title, $a_icon=0, $a_icon_alt=0)
Set title and title icon.
setData($a_data)
set table data @access public
setRowTemplate($a_template, $a_template_dir="")
Set row template.
setDefaultOrderField($a_defaultorderfield)
Set Default order field.
addColumn( $a_text, $a_sort_field="", $a_width="", $a_is_checkbox_action_column=false, $a_class="", $a_tooltip="", $a_tooltip_with_html=false)
Add a column to the header.
setId($a_val)
Set id.
setFormAction($a_form_action, $a_multipart=false)
Set Form action parameter.
setDefaultOrderDirection($a_defaultorderdirection)
Set Default order direction.
static getImagePath($img, $module_path="", $mode="output", $offline=false)
get image path (for images located in a template directory)
global $ilCtrl
Definition: ilias.php:18
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
$DIC
Definition: xapitoken.php:46