ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilQuestionCumulatedStatisticsTableGUI.php
Go to the documentation of this file.
1<?php
2
20
26{
30 protected $question;
31
37 public function __construct(
38 $controller,
39 $cmd,
40 $template_context,
42 protected GeneralQuestionPropertiesRepository $questionrepository
43 ) {
44 $this->question = $question;
45 $this->setId('qst_usage_' . $question->getId());
46
47 parent::__construct($controller, $cmd);
48
49 $this->setRowTemplate('tpl.il_as_qpl_question_cumulated_stats_table_row.html', 'components/ILIAS/TestQuestionPool');
50 $this->setLimit(PHP_INT_MAX);
51
52 $this->setDefaultOrderField('result');
53 $this->setDefaultOrderDirection('ASC');
54
55 $this->setTitle($this->lng->txt('question_cumulated_statistics'));
56 $this->setNoEntriesText($this->lng->txt('qpl_assessment_no_assessment_of_questions'));
57
58 $this->disable('sort');
59 $this->disable('hits');
60 $this->disable('numinfo');
61
62 $this->initColumns();
63 $this->initData();
64 }
65
69 protected function initColumns(): void
70 {
71 $this->addColumn($this->lng->txt('result'), 'result');
72 $this->addColumn($this->lng->txt('value'), 'value');
73 }
74
78 protected function initData(): void
79 {
80 $rows = [];
81
82 $total_of_answers = $this->question->getTotalAnswers();
83
84 if ($total_of_answers) {
85 $rows[] = [
86 'result' => $this->lng->txt('qpl_assessment_total_of_answers'),
87 'value' => $total_of_answers,
88 'is_percent' => false
89 ];
90
91 $rows[] = [
92 'result' => $this->lng->txt('qpl_assessment_total_of_right_answers'),
93 'value' => $this->questionrepository->getFractionOfReachedToReachablePointsTotal($this->question->getId()) * 100.0,
94 'is_percent' => true
95 ];
96 } else {
97 $this->disable('header');
98 }
99
100 $this->setData($rows);
101 }
102
107 public function numericOrdering(string $a_field): bool
108 {
109 if ('value' == $a_field) {
110 return true;
111 }
112
113 return false;
114 }
115
119 public function fillRow(array $a_set): void
120 {
121 $this->tpl->setVariable('VAL_RESULT', $a_set['result']);
122 $this->tpl->setVariable('VAL_VALUE', $a_set['is_percent'] ? sprintf("%2.2f", $a_set['value'])
123 . ' %' : $a_set['value']);
124 }
125}
return true
__construct( $controller, $cmd, $template_context, assQuestion $question, protected GeneralQuestionPropertiesRepository $questionrepository)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
setLimit(int $a_limit=0, int $a_default_limit=0)
set max.
setTitle(string $a_title, string $a_icon="", string $a_icon_alt="")
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)
setDefaultOrderField(string $a_defaultorderfield)
setNoEntriesText(string $a_text)
setRowTemplate(string $a_template, string $a_template_dir="")
Set row template.
setId(string $a_val)
setDefaultOrderDirection(string $a_defaultorderdirection)
setData(array $a_data)
Set table data.
disable(string $a_module_name)
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc