ILIAS  release_9 Revision v9.13-25-g2c18ec4c24f
ilPollResultsRenderer Class Reference

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V. More...

+ Collaboration diagram for ilPollResultsRenderer:

Public Member Functions

 __construct (int $ref_id)
 
 render (ilTemplate $tpl, ilPollResultsHandler $results, int $presentation_mode)
 

Protected Member Functions

 renderPieChart (ilTemplate $tpl, ilPollResultsHandler $results)
 
 renderBarChart (ilTemplate $tpl, ilPollResultsHandler $results)
 
 getLegend ()
 
 getPieChart ()
 
 getProgressBar ()
 
 specialCharsAsEntities (string $string)
 

Protected Attributes

int $ref_id
 

Detailed Description

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V.

ILIAS is licensed with the GPL-3.0, see https://www.gnu.org/licenses/gpl-3.0.en.html You should have received a copy of said license along with the source code, too.

If this is not the case or you just want to try ILIAS, you'll find us at: https://www.ilias.de https://github.com/ILIAS-eLearning

Definition at line 22 of file class.ilPollResultsRenderer.php.

Constructor & Destructor Documentation

◆ __construct()

ilPollResultsRenderer::__construct ( int  $ref_id)

Definition at line 26 of file class.ilPollResultsRenderer.php.

References $ref_id.

28  {
29  $this->ref_id = $ref_id;
30  }

Member Function Documentation

◆ getLegend()

ilPollResultsRenderer::getLegend ( )
protected

Definition at line 90 of file class.ilPollResultsRenderer.php.

Referenced by renderPieChart().

91  {
92  return new ilChartLegend();
93  }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
+ Here is the caller graph for this function:

◆ getPieChart()

ilPollResultsRenderer::getPieChart ( )
protected

Definition at line 95 of file class.ilPollResultsRenderer.php.

References ilChart\getInstanceByType(), and ilChart\TYPE_PIE.

Referenced by renderPieChart().

95  : ilChart
96  {
99  "poll_results_pie_" . $this->ref_id
100  );
101  }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
const TYPE_PIE
static getInstanceByType(int $a_type, string $a_id)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getProgressBar()

ilPollResultsRenderer::getProgressBar ( )
protected

Definition at line 103 of file class.ilPollResultsRenderer.php.

References ilProgressBar\getInstance().

Referenced by renderBarChart().

103  : ilProgressBar
104  {
106  }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ render()

ilPollResultsRenderer::render ( ilTemplate  $tpl,
ilPollResultsHandler  $results,
int  $presentation_mode 
)

Definition at line 32 of file class.ilPollResultsRenderer.php.

References renderBarChart(), renderPieChart(), and ilObjPoll\SHOW_RESULTS_AS_PIECHART.

36  : void {
37  if ($presentation_mode === ilObjPoll::SHOW_RESULTS_AS_PIECHART) {
38  $this->renderPieChart($tpl, $results);
39  } else {
40  $this->renderBarChart($tpl, $results);
41  }
42  }
const SHOW_RESULTS_AS_PIECHART
renderPieChart(ilTemplate $tpl, ilPollResultsHandler $results)
renderBarChart(ilTemplate $tpl, ilPollResultsHandler $results)
+ Here is the call graph for this function:

◆ renderBarChart()

ilPollResultsRenderer::renderBarChart ( ilTemplate  $tpl,
ilPollResultsHandler  $results 
)
protected

Definition at line 72 of file class.ilPollResultsRenderer.php.

References $id, ilPollResultsHandler\getAnswerPercentage(), ilPollResultsHandler\getAnswerText(), ilPollResultsHandler\getAnswerTotal(), ilPollResultsHandler\getOrderedAnswerIds(), getProgressBar(), ilTemplate\parseCurrentBlock(), ilTemplate\setCurrentBlock(), HTML_Template_IT\setVariable(), and specialCharsAsEntities().

Referenced by render().

75  : void {
76  $tpl->setCurrentBlock("answer_result");
77  foreach ($results->getOrderedAnswerIds() as $id) {
78  $pbar = $this->getProgressBar();
79  $pbar->setCurrent(round($results->getAnswerPercentage($id)));
80  $pbar->setCaption('(' . $results->getAnswerTotal($id) . ')');
81  $tpl->setVariable("PERC_ANSWER_RESULT", $pbar->render());
82  $tpl->setVariable(
83  "TXT_ANSWER_RESULT",
84  $this->specialCharsAsEntities(nl2br($results->getAnswerText($id)))
85  );
86  $tpl->parseCurrentBlock();
87  }
88  }
parseCurrentBlock(string $part=ilGlobalTemplateInterface::DEFAULT_BLOCK)
setVariable($variable, $value='')
Sets a variable value.
Definition: IT.php:546
setCurrentBlock(string $part=ilGlobalTemplateInterface::DEFAULT_BLOCK)
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ renderPieChart()

ilPollResultsRenderer::renderPieChart ( ilTemplate  $tpl,
ilPollResultsHandler  $results 
)
protected

Definition at line 44 of file class.ilPollResultsRenderer.php.

References $id, $ref_id, ilPollResultsHandler\getAnswerPercentage(), ilPollResultsHandler\getAnswerText(), getLegend(), ilPollResultsHandler\getOrderedAnswerIds(), getPieChart(), HTML_Template_IT\setVariable(), and specialCharsAsEntities().

Referenced by render().

47  : void {
48  $chart = $this->getPieChart();
49  $chart->setSize("400", "200");
50  $chart->setAutoResize(true);
51 
52  $chart_data = $chart->getDataInstance();
53 
54  foreach ($results->getOrderedAnswerIds() as $id) {
55  $chart_data->addPiePoint(
56  (int) round($results->getAnswerPercentage($id)),
57  $this->specialCharsAsEntities(nl2br($results->getAnswerText($id)))
58  );
59  }
60 
61  $chart->addData($chart_data);
62 
63  $pie_legend_id = "poll_legend_" . $this->ref_id;
64  $legend = $this->getLegend();
65  $legend->setContainer($pie_legend_id);
66  $chart->setLegend($legend);
67 
68  $tpl->setVariable("PIE_LEGEND_ID", $pie_legend_id);
69  $tpl->setVariable("PIE_CHART", $chart->getHTML());
70  }
setVariable($variable, $value='')
Sets a variable value.
Definition: IT.php:546
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ specialCharsAsEntities()

ilPollResultsRenderer::specialCharsAsEntities ( string  $string)
protected

Definition at line 108 of file class.ilPollResultsRenderer.php.

Referenced by renderBarChart(), and renderPieChart().

108  : string
109  {
110  // Should be replaced by a proper refinery transformation once https://github.com/ILIAS-eLearning/ILIAS/pull/6314 is merged
111  return htmlspecialchars(
112  $string,
113  ENT_QUOTES | ENT_SUBSTITUTE,
114  'utf-8'
115  );
116  }
+ Here is the caller graph for this function:

Field Documentation

◆ $ref_id

int ilPollResultsRenderer::$ref_id
protected

Definition at line 24 of file class.ilPollResultsRenderer.php.

Referenced by __construct(), and renderPieChart().


The documentation for this class was generated from the following file: