ILIAS  release_8 Revision v8.24
class.ilQuestionCumulatedStatisticsTableGUI.php
Go to the documentation of this file.
1<?php
2
24{
28 protected $question;
29
35 public function __construct($controller, $cmd, $template_context, assQuestion $question)
36 {
37 $this->question = $question;
38 $this->setId('qst_usage_' . $question->getId());
39 parent::__construct($controller, $cmd);
40
41 $this->setRowTemplate('tpl.il_as_qpl_question_cumulated_stats_table_row.html', 'Modules/TestQuestionPool');
42 $this->setLimit(PHP_INT_MAX);
43
44 $this->setDefaultOrderField('result');
45 $this->setDefaultOrderDirection('ASC');
46
47 $this->setTitle($this->lng->txt('question_cumulated_statistics'));
48 $this->setNoEntriesText($this->lng->txt('qpl_assessment_no_assessment_of_questions'));
49
50 $this->disable('sort');
51 $this->disable('hits');
52 $this->disable('numinfo');
53
54 $this->initColumns();
55 $this->initData();
56 }
57
61 protected function initColumns(): void
62 {
63 $this->addColumn($this->lng->txt('result'), 'result');
64 $this->addColumn($this->lng->txt('value'), 'value');
65 }
66
70 protected function initData(): void
71 {
72 $rows = array();
73
74 $total_of_answers = $this->question->getTotalAnswers();
75
76 if ($total_of_answers) {
77 $rows[] = array(
78 'result' => $this->lng->txt('qpl_assessment_total_of_answers'),
79 'value' => $total_of_answers,
80 'is_percent' => false
81 );
82
83 $rows[] = array(
84 'result' => $this->lng->txt('qpl_assessment_total_of_right_answers'),
85 'value' => assQuestion::_getTotalRightAnswers($this->question->getId()) * 100.0,
86 'is_percent' => true
87 );
88 } else {
89 $this->disable('header');
90 }
91
92 $this->setData($rows);
93 }
94
99 public function numericOrdering(string $a_field): bool
100 {
101 if ('value' == $a_field) {
102 return true;
103 }
104
105 return false;
106 }
107
111 public function fillRow(array $a_set): void
112 {
113 $this->tpl->setVariable('VAL_RESULT', $a_set['result']);
114 $this->tpl->setVariable('VAL_VALUE', $a_set['is_percent'] ? sprintf("%2.2f", $a_set['value'])
115 . ' %' : $a_set['value']);
116 }
117}
Abstract basic class which is to be extended by the concrete assessment question type classes.
static _getTotalRightAnswers(int $a_q_id)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
__construct($controller, $cmd, $template_context, assQuestion $question)
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
$rows
Definition: xhr_table.php:10