ILIAS  release_9 Revision v9.13-25-g2c18ec4c24f
class.ilQuestionCumulatedStatisticsTableGUI.php
Go to the documentation of this file.
1 <?php
2 
24 {
25  protected \ILIAS\TestQuestionPool\QuestionInfoService $questioninfo;
29  protected $question;
30 
36  public function __construct($controller, $cmd, $template_context, assQuestion $question, \ILIAS\TestQuestionPool\QuestionInfoService $questioninfo)
37  {
38  $this->question = $question;
39  $this->setId('qst_usage_' . $question->getId());
40  $this->questioninfo = $questioninfo;
41  parent::__construct($controller, $cmd);
42 
43  $this->setRowTemplate('tpl.il_as_qpl_question_cumulated_stats_table_row.html', 'Modules/TestQuestionPool');
44  $this->setLimit(PHP_INT_MAX);
45 
46  $this->setDefaultOrderField('result');
47  $this->setDefaultOrderDirection('ASC');
48 
49  $this->setTitle($this->lng->txt('question_cumulated_statistics'));
50  $this->setNoEntriesText($this->lng->txt('qpl_assessment_no_assessment_of_questions'));
51 
52  $this->disable('sort');
53  $this->disable('hits');
54  $this->disable('numinfo');
55 
56  $this->initColumns();
57  $this->initData();
58  }
59 
63  protected function initColumns(): void
64  {
65  $this->addColumn($this->lng->txt('result'), 'result');
66  $this->addColumn($this->lng->txt('value'), 'value');
67  }
68 
72  protected function initData(): void
73  {
74  $rows = array();
75 
76  $total_of_answers = $this->question->getTotalAnswers();
77 
78  if ($total_of_answers) {
79  $rows[] = array(
80  'result' => $this->lng->txt('qpl_assessment_total_of_answers'),
81  'value' => $total_of_answers,
82  'is_percent' => false
83  );
84 
85  $rows[] = array(
86  'result' => $this->lng->txt('qpl_assessment_total_of_right_answers'),
87  'value' => $this->questioninfo->getFractionOfReachedToReachablePointsTotal($this->question->getId()) * 100.0,
88  'is_percent' => true
89  );
90  } else {
91  $this->disable('header');
92  }
93 
94  $this->setData($rows);
95  }
96 
101  public function numericOrdering(string $a_field): bool
102  {
103  if ('value' == $a_field) {
104  return true;
105  }
106 
107  return false;
108  }
109 
113  public function fillRow(array $a_set): void
114  {
115  $this->tpl->setVariable('VAL_RESULT', $a_set['result']);
116  $this->tpl->setVariable('VAL_VALUE', $a_set['is_percent'] ? sprintf("%2.2f", $a_set['value'])
117  . ' %' : $a_set['value']);
118  }
119 }
setNoEntriesText(string $a_text)
setData(array $a_data)
Abstract basic class which is to be extended by the concrete assessment question type classes...
Class ChatMainBarProvider .
__construct($controller, $cmd, $template_context, assQuestion $question, \ILIAS\TestQuestionPool\QuestionInfoService $questioninfo)
setId(string $a_val)
__construct(VocabulariesInterface $vocabularies)
setDefaultOrderField(string $a_defaultorderfield)
setRowTemplate(string $a_template, string $a_template_dir="")
Set row template.
setDefaultOrderDirection(string $a_defaultorderdirection)
setTitle(string $a_title, string $a_icon="", string $a_icon_alt="")
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)
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)
disable(string $a_module_name)
ILIAS TestQuestionPool QuestionInfoService $questioninfo