ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
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 function __construct($a_parent_obj, $a_parent_cmd)
19 {
20 global $ilCtrl, $lng;
21
22 $this->setId("ilobjpollusr");
23
24 parent::__construct($a_parent_obj, $a_parent_cmd);
25
26 $this->addColumn($lng->txt("login"), "login");
27 $this->addColumn($lng->txt("lastname"), "lastname");
28 $this->addColumn($lng->txt("firstname"), "firstname");
29
30 foreach($this->getParentObject()->object->getAnswers() as $answer)
31 {
32 $this->answer_ids[] = $answer["id"];
33 $this->addColumn($answer["answer"], "answer".$answer["id"]);
34 }
35
36 $this->getItems($this->answer_ids);
37
38 $this->setTitle($this->lng->txt("poll_question").": \"".
39 $this->getParentObject()->object->getQuestion()."\"");
40
41 $this->setFormAction($ilCtrl->getFormAction($a_parent_obj, $a_parent_cmd));
42 $this->setRowTemplate("tpl.user_row.html", "Modules/Poll");
43 $this->setDefaultOrderField("login");
44 $this->setDefaultOrderDirection("asc");
45
46 $this->setExportFormats(array(self::EXPORT_CSV, self::EXPORT_EXCEL));
47 }
48
49 protected function getItems(array $a_answer_ids)
50 {
51 $data = array();
52
53 foreach($this->getParentObject()->object->getVotesByUsers() as $user_id => $vote)
54 {
55 $answers = $vote["answers"];
56 unset($vote["answers"]);
57
58 foreach($a_answer_ids as $answer_id)
59 {
60 $vote["answer".$answer_id] = in_array($answer_id, $answers);
61 }
62
63 $data[] = $vote;
64 }
65
66 $this->setData($data);
67 }
68
69 protected function fillRow($a_set)
70 {
71 $this->tpl->setCurrentBlock("answer_bl");
72 foreach($this->answer_ids as $answer_id)
73 {
74 if($a_set["answer".$answer_id])
75 {
76 $this->tpl->setVariable("ANSWER", '<img src="'.ilUtil::getImagePath("icon_ok.svg").'" />');
77 }
78 else
79 {
80 $this->tpl->setVariable("ANSWER", "&nbsp;");
81 }
82 $this->tpl->parseCurrentBlock();
83 }
84
85 $this->tpl->setVariable("LOGIN", $a_set["login"]);
86 $this->tpl->setVariable("FIRSTNAME", $a_set["firstname"]);
87 $this->tpl->setVariable("LASTNAME", $a_set["lastname"]);
88 }
89
90 protected function fillRowCSV($a_csv, $a_set)
91 {
92 $a_csv->addColumn($a_set["login"]);
93 $a_csv->addColumn($a_set["lastname"]);
94 $a_csv->addColumn($a_set["firstname"]);
95 foreach($this->answer_ids as $answer_id)
96 {
97 if($a_set["answer".$answer_id])
98 {
99 $a_csv->addColumn(true);
100 }
101 else
102 {
103 $a_csv->addColumn(false);
104 }
105 }
106 $a_csv->addRow();
107 }
108
109 protected function fillRowExcel($a_worksheet, &$a_row, $a_set)
110 {
111 $a_worksheet->write($a_row, 0, $a_set["login"]);
112 $a_worksheet->write($a_row, 1, $a_set["lastname"]);
113 $a_worksheet->write($a_row, 2, $a_set["firstname"]);
114 $col = 2;
115 foreach($this->answer_ids as $answer_id)
116 {
117 if($a_set["answer".$answer_id])
118 {
119 $a_worksheet->write($a_row, ++$col, true);
120 }
121 else
122 {
123 $a_worksheet->write($a_row, ++$col, false);
124 }
125 }
126 }
127}
128
129?>
TableGUI class for poll users.
__construct($a_parent_obj, $a_parent_cmd)
fillRowExcel($a_worksheet, &$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.
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.
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.
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
global $lng
Definition: privfeed.php:40