ILIAS  release_8 Revision v8.23
class.ilTestManScoringParticipantsBySelectedQuestionAndPassTableGUI.php
Go to the documentation of this file.
1 <?php
2 
19 require_once 'Services/Form/classes/class.ilNumberInputGUI.php';
20 require_once 'Services/Table/classes/class.ilTable2GUI.php';
21 
29 {
30  public const PARENT_DEFAULT_CMD = 'showManScoringByQuestionParticipantsTable';
31  public const PARENT_APPLY_FILTER_CMD = 'applyManScoringByQuestionFilter';
32  public const PARENT_RESET_FILTER_CMD = 'resetManScoringByQuestionFilter';
33  public const PARENT_SAVE_SCORING_CMD = 'saveManScoringByQuestion';
34 
35  private ?float $curQuestionMaxPoints = null;
36 
37  protected bool $first_row_rendered = false;
38 
39  protected bool $first_row = true;
40 
41  public function __construct($parentObj)
42  {
43  $this->setFilterCommand(self::PARENT_APPLY_FILTER_CMD);
44  $this->setResetCommand(self::PARENT_RESET_FILTER_CMD);
45  global $DIC;
46 
47  $ilCtrl = $DIC->ctrl();
48  $tpl = $DIC->ui()->mainTemplate();
49  $tpl->addJavaScript('./node_modules/tinymce/tinymce.js');
50  $this->setId('man_scor_by_qst_' . $parentObj->getObject()->getId());
51 
52  parent::__construct($parentObj, self::PARENT_DEFAULT_CMD);
53 
54  $this->setFormAction($ilCtrl->getFormAction($parentObj, self::PARENT_DEFAULT_CMD));
55  $this->setRowTemplate("tpl.il_as_tst_man_scoring_by_question_tblrow.html", "Modules/Test");
56  $this->setShowRowsSelector(true);
57 
58  $this->initOrdering();
59  $this->initColumns();
60  $this->initFilter();
61  }
62 
63  private function initColumns(): void
64  {
65  $this->addColumn($this->lng->txt('name'), 'name');
66  $this->addColumn($this->lng->txt('tst_reached_points'), 'reached_points');
67  $this->addColumn($this->lng->txt('tst_maximum_points'), 'maximum_points');
68  $this->addColumn($this->lng->txt('tst_feedback'), 'feedback', '30%');
69  $this->addColumn($this->lng->txt('finalized_evaluation'), 'finalized_evaluation');
70  $this->addColumn($this->lng->txt('finalized_by'), 'finalized_by_uid');
71  $this->addColumn($this->lng->txt('finalized_on'), 'finalized_tstamp');
72  $this->addColumn($this->lng->txt('actions'), '', '1%');
73  }
74 
75  private function initOrdering(): void
76  {
77  $this->enable('sort');
78 
79  $this->setDefaultOrderField("name");
80  $this->setDefaultOrderDirection("asc");
81  }
82 
83  public function initFilter(): void
84  {
85  $this->setDisableFilterHiding(true);
86 
87  include_once 'Services/Form/classes/class.ilSelectInputGUI.php';
88  $available_questions = new ilSelectInputGUI($this->lng->txt('question'), 'question');
89  $select_questions = array();
90  if (!$this->getParentObject()->getObject()->isRandomTest()) {
91  $questions = $this->getParentObject()->getObject()->getTestQuestions();
92  } else {
93  $questions = $this->getParentObject()->getObject()->getPotentialRandomTestQuestions();
94  }
96  foreach ($questions as $data) {
97  include_once 'Modules/TestQuestionPool/classes/class.assQuestion.php';
98  $info = assQuestion::_getQuestionInfo($data['question_id']);
99  $type = $info["question_type_fi"];
100  if (in_array($type, $scoring)) {
101  $maxpoints = assQuestion::_getMaximumPoints($data["question_id"]);
102  if ($maxpoints == 1) {
103  $maxpoints = ' (' . $maxpoints . ' ' . $this->lng->txt('point') . ')';
104  } else {
105  $maxpoints = ' (' . $maxpoints . ' ' . $this->lng->txt('points') . ')';
106  }
107 
108  $select_questions[$data["question_id"]] = $data['title'] . $maxpoints . ' [' . $this->lng->txt('question_id_short') . ': ' . $data["question_id"] . ']';
109  }
110  }
111  if (!$select_questions) {
112  $select_questions[0] = $this->lng->txt('tst_no_scorable_qst_available');
113  }
114  $available_questions->setOptions(array('' => $this->lng->txt('please_choose')) + $select_questions);
115  $this->addFilterItem($available_questions);
116  $available_questions->readFromSession();
117  $this->filter['question'] = $available_questions->getValue();
118 
119  $pass = new ilSelectInputGUI($this->lng->txt('pass'), 'pass');
120  $passes = array();
121  $max_pass = $this->getParentObject()->getObject()->getMaxPassOfTest();
122  for ($i = 1; $i <= $max_pass; $i++) {
123  $passes[$i] = $i;
124  }
125  $pass->setOptions($passes);
126  $this->addFilterItem($pass);
127  $pass->readFromSession();
128  $this->filter['pass'] = $pass->getValue();
129 
130  $only_answered = new ilCheckboxInputGUI($this->lng->txt('tst_man_scoring_only_answered'), 'only_answered');
131  $this->addFilterItem($only_answered);
132  $only_answered->readFromSession();
133  ;
134  $this->filter['only_answered'] = $only_answered->getChecked();
135 
136  $correction = new ilSelectInputGUI(
137  $this->lng->txt('finalized_evaluation'),
138  'finalize_evaluation'
139  );
140  $evaluated = array(
141  $this->lng->txt('all_users'),
142  $this->lng->txt('evaluated_users'),
143  $this->lng->txt('not_evaluated_users')
144  );
145  $correction->setOptions($evaluated);
146  $this->addFilterItem($correction);
147  $correction->readFromSession();
148  $this->filter['finalize_evaluation'] = $correction->getValue();
149  }
150 
151  public function fillRow(array $a_set): void
152  {
153  global $DIC;
154  $ilCtrl = $DIC->ctrl();
155  $ilAccess = $DIC->access();
156 
157  if (
158  $this->getParentObject()->object->anonymity == 1 ||
159  (
160  $this->getParentObject()->object->getAnonymity() == 2 &&
161  false == $ilAccess->checkAccess('write', '', $this->getParentObject()->object->getRefId())
162  )
163  ) {
164  $this->tpl->setVariable('VAL_NAME', $this->lng->txt("anonymous"));
165  } else {
166  $this->tpl->setVariable('VAL_NAME', $a_set['name']);
167  }
168 
169  if (!$this->first_row_rendered) {
170  $this->first_row_rendered = true;
171  $this->tpl->touchBlock('row_js');
172  }
173 
174  $this->tpl->setVariable('VAL_REACHED_POINTS', $a_set['reached_points']);
175  $this->tpl->setVariable('VAL_MAX_POINTS', $a_set['maximum_points']);
176  $finalized = isset($a_set['finalized_evaluation']) && ((int) $a_set['finalized_evaluation']) === 1;
177  $this->tpl->setVariable(
178  'VAL_EVALUATED',
179  $finalized ? $this->lng->txt('yes') : $this->lng->txt('no')
180  );
181  $fin_usr_id = $a_set['finalized_by_usr_id'] ?? null;
182 
183  $this->tpl->setVariable('VAL_MODAL_CORRECTION', $a_set['feedback'] ?? '');
184  if (is_numeric($fin_usr_id) && $fin_usr_id > 0) {
185  $this->tpl->setVariable('VAL_FINALIZED_BY', ilObjUser::_lookupFullname($fin_usr_id));
186  }
187  $fin_timestamp = $a_set['finalized_tstamp'] ?? 0;
188  if ($fin_timestamp > 0) {
189  $time = new ilDateTime($fin_timestamp, IL_CAL_UNIX);
190  $this->tpl->setVariable('VAL_FINALIZED_ON', \ilDatePresentation::formatDate($time));
191  }
192 
193  $this->tpl->setVariable('VAL_PASS', $a_set['pass_id']);
194  $this->tpl->setVariable('VAL_ACTIVE_ID', $a_set['active_id']);
195  $this->tpl->setVariable('VAL_QUESTION_ID', $a_set['qst_id']);
196 
197  if ($this->first_row) {
198  $this->tpl->touchBlock('scoring_by_question_refresher');
199  $this->tpl->parseCurrentBlock();
200  $this->first_row = false;
201  }
202 
203  $ilCtrl->setParameter($this->getParentObject(), 'qst_id', $a_set['qst_id']);
204  $ilCtrl->setParameter($this->getParentObject(), 'active_id', $a_set['active_id']);
205  $ilCtrl->setParameter($this->getParentObject(), 'pass_id', $a_set['pass_id']);
206  $this->tpl->setVariable('VAL_LINK_ANSWER', $ilCtrl->getLinkTarget($this->getParentObject(), 'getAnswerDetail', '', true, false));
207  $ilCtrl->setParameter($this->getParentObject(), 'qst_id', '');
208  $ilCtrl->setParameter($this->getParentObject(), 'active_id', '');
209  $ilCtrl->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)
setFormAction(string $a_form_action, bool $a_multipart=false)
addFilterItem(ilTableFilterItem $a_input_item, bool $a_optional=false)
$type
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
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)
This class represents a checkbox property in a property form.
const IL_CAL_UNIX
setId(string $a_val)
global $DIC
Definition: feed.php:28
setShowRowsSelector(bool $a_value)
Toggle rows-per-page selector.
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 _getQuestionInfo(int $question_id)
static _getMaximumPoints(int $question_id)
Returns the maximum points, a learner can reach answering the question.
static _getManualScoring()
Retrieve the manual scoring settings.
__construct(Container $dic, ilPlugin $plugin)
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)
$i
Definition: metadata.php:41