ILIAS  release_9 Revision v9.13-25-g2c18ec4c24f
class.ilTestManScoringParticipantsBySelectedQuestionAndPassTableGUI.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
28 {
29  public const PARENT_DEFAULT_CMD = 'showManScoringByQuestionParticipantsTable';
30  public const PARENT_APPLY_FILTER_CMD = 'applyManScoringByQuestionFilter';
31  public const PARENT_RESET_FILTER_CMD = 'resetManScoringByQuestionFilter';
32  public const PARENT_SAVE_SCORING_CMD = 'saveManScoringByQuestion';
33 
34  private ?float $curQuestionMaxPoints = null;
35  protected \ILIAS\TestQuestionPool\QuestionInfoService $questioninfo;
36 
37  protected bool $first_row_rendered = false;
38 
39  protected bool $first_row = true;
40  protected array $filter = [];
41 
42  public function __construct(ilTestScoringByQuestionsGUI $parent_obj, private ilAccess $access)
43  {
44  global $DIC;
45  $this->questioninfo = $DIC->testQuestionPool()->questionInfo();
46 
47  $this->setId('man_scor_by_qst_' . $parent_obj->getObject()->getId());
48 
49  parent::__construct($parent_obj, self::PARENT_DEFAULT_CMD);
50 
51  $this->setFilterCommand(self::PARENT_APPLY_FILTER_CMD);
52  $this->setResetCommand(self::PARENT_RESET_FILTER_CMD);
53 
54  $this->main_tpl->addJavaScript('./node_modules/tinymce/tinymce.js');
55 
56 
57  $this->setFormAction($this->ctrl->getFormAction($parent_obj, self::PARENT_DEFAULT_CMD));
58  $this->setRowTemplate("tpl.il_as_tst_man_scoring_by_question_tblrow.html", "Modules/Test");
59  $this->setShowRowsSelector(true);
60 
61  $this->initOrdering();
62  $this->initColumns();
63  $this->initFilter();
64  }
65 
66  private function initColumns(): void
67  {
68  $this->addColumn($this->lng->txt('name'), 'name');
69  $this->addColumn($this->lng->txt('tst_reached_points'), 'reached_points');
70  $this->addColumn($this->lng->txt('tst_maximum_points'), 'maximum_points');
71  $this->addColumn($this->lng->txt('tst_feedback'), 'feedback', '30%');
72  $this->addColumn($this->lng->txt('finalized_evaluation'), 'finalized_evaluation');
73  $this->addColumn($this->lng->txt('finalized_by'), 'finalized_by_uid');
74  $this->addColumn($this->lng->txt('finalized_on'), 'finalized_tstamp');
75  $this->addColumn($this->lng->txt('actions'), '', '1%');
76  }
77 
78  private function initOrdering(): void
79  {
80  $this->enable('sort');
81 
82  $this->setDefaultOrderField("name");
83  $this->setDefaultOrderDirection("asc");
84  }
85 
86  public function initFilter(): void
87  {
88  $this->setDisableFilterHiding(true);
89 
90  $available_questions = new ilSelectInputGUI($this->lng->txt('question'), 'question');
91  $select_questions = array();
92  if (!$this->getParentObject()->getObject()->isRandomTest()) {
93  $questions = $this->getParentObject()->getObject()->getTestQuestions();
94  } else {
95  $questions = $this->getParentObject()->getObject()->getPotentialRandomTestQuestions();
96  }
98  foreach ($questions as $data) {
99  $info = $this->questioninfo->getQuestionInfo($data['question_id']);
100  $type = $info["question_type_fi"];
101  if (in_array($type, $scoring)) {
102  $maxpoints = $this->questioninfo->getMaximumPoints($data["question_id"]);
103  if ($maxpoints == 1) {
104  $maxpoints = ' (' . $maxpoints . ' ' . $this->lng->txt('point') . ')';
105  } else {
106  $maxpoints = ' (' . $maxpoints . ' ' . $this->lng->txt('points') . ')';
107  }
108 
109  $select_questions[$data["question_id"]] = $data['title'] . $maxpoints . ' [' . $this->lng->txt('question_id_short') . ': ' . $data["question_id"] . ']';
110  }
111  }
112  if (!$select_questions) {
113  $select_questions[0] = $this->lng->txt('tst_no_scorable_qst_available');
114  }
115  $available_questions->setOptions(array('' => $this->lng->txt('please_choose')) + $select_questions);
116  $this->addFilterItem($available_questions);
117  $available_questions->readFromSession();
118  $this->filter['question'] = $available_questions->getValue();
119 
120  $pass = new ilSelectInputGUI($this->lng->txt('pass'), 'pass');
121  $passes = array();
122  $max_pass = $this->getParentObject()->getObject()->getMaxPassOfTest();
123  for ($i = 1; $i <= $max_pass; $i++) {
124  $passes[$i] = $i;
125  }
126  $pass->setOptions($passes);
127  $this->addFilterItem($pass);
128  $pass->readFromSession();
129  $this->filter['pass'] = $pass->getValue();
130 
131  $only_answered = new ilCheckboxInputGUI($this->lng->txt('tst_man_scoring_only_answered'), 'only_answered');
132  $this->addFilterItem($only_answered);
133  $only_answered->readFromSession();
134  ;
135  $this->filter['only_answered'] = $only_answered->getChecked();
136 
137  $correction = new ilSelectInputGUI(
138  $this->lng->txt('finalized_evaluation'),
139  'finalize_evaluation'
140  );
141  $evaluated = [
142  '' => $this->lng->txt('all_users'),
143  ilTestScoringByQuestionsGUI::ONLY_FINALIZED => $this->lng->txt('evaluated_users'),
144  ilTestScoringByQuestionsGUI::EXCEPT_FINALIZED => $this->lng->txt('not_evaluated_users')
145  ];
146  $correction->setOptions($evaluated);
147  $this->addFilterItem($correction);
148  $correction->readFromSession();
149  $this->filter['finalize_evaluation'] = $correction->getValue();
150  }
151 
152  public function fillRow(array $a_set): void
153  {
154  if (
155  $this->getParentObject()->getObject()->getAnonymity() == 1 ||
156  (
157  $this->getParentObject()->getObject()->getAnonymity() == 2 &&
158  false == $this->access->checkAccess('write', '', $this->getParentObject()->getObject()->getRefId())
159  )
160  ) {
161  $this->tpl->setVariable('VAL_NAME', $this->lng->txt("anonymous"));
162  } else {
163  $this->tpl->setVariable('VAL_NAME', $a_set['name']);
164  }
165 
166  if (!$this->first_row_rendered) {
167  $this->first_row_rendered = true;
168  $this->tpl->touchBlock('row_js');
169  }
170 
171  $this->tpl->setVariable('VAL_REACHED_POINTS', $a_set['reached_points']);
172  $this->tpl->setVariable('VAL_MAX_POINTS', $a_set['maximum_points']);
173  $finalized = isset($a_set['finalized_evaluation']) && ((int) $a_set['finalized_evaluation']) === 1;
174  $this->tpl->setVariable(
175  'VAL_EVALUATED',
176  $finalized ? $this->lng->txt('yes') : $this->lng->txt('no')
177  );
178  $fin_usr_id = $a_set['finalized_by_usr_id'] ?? null;
179 
180  $this->tpl->setVariable('VAL_MODAL_CORRECTION', $a_set['feedback'] ?? '');
181  if (is_numeric($fin_usr_id) && $fin_usr_id > 0) {
182  $this->tpl->setVariable('VAL_FINALIZED_BY', ilObjUser::_lookupFullname($fin_usr_id));
183  }
184  $fin_timestamp = $a_set['finalized_tstamp'] ?? 0;
185  if ($fin_timestamp > 0) {
186  $time = new ilDateTime($fin_timestamp, IL_CAL_UNIX);
187  $this->tpl->setVariable('VAL_FINALIZED_ON', \ilDatePresentation::formatDate($time));
188  }
189 
190  $this->tpl->setVariable('VAL_PASS', $a_set['pass_id']);
191  $this->tpl->setVariable('VAL_ACTIVE_ID', $a_set['active_id']);
192  $this->tpl->setVariable('VAL_QUESTION_ID', $a_set['qst_id']);
193 
194  if ($this->first_row) {
195  $this->tpl->touchBlock('scoring_by_question_refresher');
196  $this->tpl->parseCurrentBlock();
197  $this->first_row = false;
198  }
199 
200  $this->ctrl->setParameter($this->getParentObject(), 'qst_id', $a_set['qst_id']);
201  $this->ctrl->setParameter($this->getParentObject(), 'active_id', $a_set['active_id']);
202  $this->ctrl->setParameter($this->getParentObject(), 'pass_id', $a_set['pass_id']);
203  $this->tpl->setVariable(
204  'VAL_LINK_ANSWER',
205  $this->ctrl->getLinkTarget($this->getParentObject(), 'getAnswerDetail', '', true, false)
206  );
207  $this->ctrl->setParameter($this->getParentObject(), 'qst_id', '');
208  $this->ctrl->setParameter($this->getParentObject(), 'active_id', '');
209  $this->ctrl->setParameter($this->getParentObject(), 'pass_id', '');
210  $this->tpl->setVariable('VAL_TXT_ANSWER', $this->lng->txt('tst_eval_show_answer'));
211  $this->tpl->setVariable('ANSWER_TITLE', $this->lng->txt('answer_of') . ': ' . $a_set['name']);
212  }
213 
214  public function getCurQuestionMaxPoints(): ?float
215  {
217  }
218 
219  public function setCurQuestionMaxPoints(float $curQuestionMaxPoints): void
220  {
221  $this->curQuestionMaxPoints = $curQuestionMaxPoints;
222  }
223 }
enable(string $a_module_name)
This class represents a selection list property in a property form.
setFormAction(string $a_form_action, bool $a_multipart=false)
addFilterItem(ilTableFilterItem $a_input_item, bool $a_optional=false)
static _lookupFullname(int $a_user_id)
setResetCommand(string $a_val, string $a_caption="")
static formatDate(ilDateTime $date, bool $a_skip_day=false, bool $a_include_wd=false, bool $include_seconds=false)
setDisableFilterHiding(bool $a_val=true)
setOptions(array $a_options)
const IL_CAL_UNIX
setId(string $a_val)
global $DIC
Definition: feed.php:28
setShowRowsSelector(bool $a_value)
Toggle rows-per-page selector.
__construct(VocabulariesInterface $vocabularies)
setDefaultOrderField(string $a_defaultorderfield)
setRowTemplate(string $a_template, string $a_template_dir="")
Set row template.
setFilterCommand(string $a_val, string $a_caption="")
setDefaultOrderDirection(string $a_defaultorderdirection)
static _getManualScoring()
Retrieve the manual scoring settings.
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)
filter(string $filter_id, $class_path, string $cmd, bool $activated=true, bool $expanded=true)