ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables Modules Pages
class.ilTestScoringByQuestionsGUI.php
Go to the documentation of this file.
1 <?php
2 
19 include_once 'Modules/Test/classes/inc.AssessmentConstants.php';
20 
22 {
23  public const EXCEPT_FINALIZED = 1;
24  public const ONLY_FINALIZED = 2;
25 
26  private \ILIAS\HTTP\GlobalHttpState $http;
27 
28  public function __construct(ilObjTest $a_object)
29  {
30  global $DIC;
31  parent::__construct($a_object);
32  $this->http = $DIC->http();
33  }
34 
35  protected function getDefaultCommand(): string
36  {
37  return 'showManScoringByQuestionParticipantsTable';
38  }
39 
40  protected function getActiveSubTabId(): string
41  {
42  return 'man_scoring_by_qst';
43  }
44 
48  protected function showManScoringByQuestionParticipantsTable(array $manPointsPost = []): void
49  {
50  global $DIC;
51 
53 
54  if (!$this->testAccess->checkScoreParticipantsAccess()) {
55  $this->tpl->setOnScreenMessage('info', $this->lng->txt('cannot_edit_test'), true);
56  $this->ctrl->redirectByClass('ilobjtestgui', 'infoScreen');
57  }
58 
62 
63  $mathJaxSetting = new ilSetting('MathJax');
64 
65  if ($mathJaxSetting->get("enable")) {
66  $this->tpl->addJavaScript($mathJaxSetting->get("path_to_mathjax"));
67  }
68 
69  $this->tpl->addJavaScript("./Services/JavaScript/js/Basic.js");
70  $this->tpl->addJavaScript("./Services/Form/js/Form.js");
71  $this->tpl->addJavascript('./Services/UIComponent/Modal/js/Modal.js');
72  $this->lng->toJSMap(['answer' => $this->lng->txt('answer')]);
73 
75 
76  $qst_id = (int) $table->getFilterItemByPostVar('question')->getValue();
77  $passNr = $table->getFilterItemByPostVar('pass')->getValue();
78  $finalized_filter = (int) $table->getFilterItemByPostVar('finalize_evaluation')->getValue();
79  $answered_filter = $table->getFilterItemByPostVar('only_answered')->getChecked();
80  $table_data = [];
81  $selected_questionData = null;
82  $complete_feedback = $this->object->getCompleteManualFeedback($qst_id);
83 
84  if (is_numeric($qst_id)) {
85  $info = assQuestion::_getQuestionInfo($qst_id);
86  $selected_questionData = $info;
87  }
88 
89  if ($selected_questionData && is_numeric($passNr)) {
90  $data = $this->object->getCompleteEvaluationData(false);
91  $participants = $data->getParticipants();
92  $participantData = new ilTestParticipantData($DIC->database(), $this->lng);
93  $participantData->setActiveIdsFilter(array_keys($data->getParticipants()));
94  $participantData->setParticipantAccessFilter(
96  );
97  $participantData->load($this->object->getTestId());
98 
99  foreach ($participantData->getActiveIds() as $active_id) {
100  $participant = $participants[$active_id];
101  $testResultData = $this->object->getTestResult($active_id, $passNr - 1);
102 
103  foreach ($testResultData as $questionData) {
104  $feedback = [];
105  $is_answered = (bool) ($questionData['answered'] ?? false);
106  $finalized_evaluation = (bool) ($questionData['finalized_evaluation'] ?? false);
107 
108  if (isset($complete_feedback[$active_id][$passNr - 1][$qst_id])) {
109  $feedback = $complete_feedback[$active_id][$passNr - 1][$qst_id];
110  }
111 
112  if (!isset($questionData['qid'])
113  || $questionData['qid'] !== $selected_questionData['question_id']
114  || $finalized_filter === self::ONLY_FINALIZED && !$finalized_evaluation
115  || $finalized_filter === self::EXCEPT_FINALIZED && $finalized_evaluation
116  || $answered_filter === true && !$is_answered) {
117  continue;
118  }
119 
120  $table_data[] = [
121  'pass_id' => $passNr - 1,
122  'active_id' => $active_id,
123  'qst_id' => $questionData['qid'],
124  'reached_points' => assQuestion::_getReachedPoints(
125  $active_id,
126  (int) $questionData['qid'],
127  $passNr - 1
128  ),
129  'maximum_points' => assQuestion::_getMaximumPoints((int) $questionData['qid']),
130  'name' => $participant->getName()
131  ] + $feedback;
132  }
133  }
134  } else {
135  $table->disable('header');
136  }
137 
138  $table->setTitle($this->lng->txt('tst_man_scoring_by_qst'));
139 
140  if ($selected_questionData) {
141  $maxpoints = assQuestion::_getMaximumPoints((int) $selected_questionData['question_id']);
142  $table->setCurQuestionMaxPoints($maxpoints);
143  $maxpoints_txt = ' (' . $maxpoints . ' ' . $this->lng->txt('points') . ')';
144  if ($maxpoints == 1) {
145  $maxpoints_txt = ' (' . $maxpoints . ' ' . $this->lng->txt('point') . ')';
146  }
147 
148  $table->setTitle(
149  $this->lng->txt('tst_man_scoring_by_qst') . ': ' . $selected_questionData['title'] . $maxpoints_txt .
150  ' [' . $this->lng->txt('question_id_short') . ': ' . $selected_questionData['question_id'] . ']'
151  );
152  }
153 
154  $table->setData($table_data);
155  $this->tpl->setContent($table->getHTML());
156  }
157 
158  protected function saveManScoringByQuestion(bool $ajax = false): void
159  {
161  global $DIC;
162  $user = $DIC->user();
163 
164  $transform_scoring = $this->refinery->custom()->transformation(function ($value) use (&$transform_scoring) {
165  if (is_array($value)) {
166  foreach ($value as $key => $val) {
167  $value[$key] = $transform_scoring->transform($val);
168  }
169  } elseif (is_string($value)) {
170  $value = $this->refinery->byTrying([
171  $this->refinery->kindlyTo()->float(),
172  $this->refinery->always(0.0)
173  ])->transform($value);
174  } else {
175  throw new \ILIAS\Refinery\ConstraintViolationException(
176  sprintf('The value "%s" is no array or string.', var_export($value, true)),
177  'value_is_no_array_or_string',
178  var_export($value, true)
179  );
180  }
181 
182  return $value;
183  });
184 
185  $transform_finalization = $this->refinery->custom()->transformation(
186  function ($value) use (&$transform_finalization) {
187  if (is_array($value)) {
188  foreach ($value as $key => $val) {
189  $value[$key] = $transform_finalization->transform($val);
190  }
191  } elseif (is_string($value)) {
192  $value = $this->refinery->byTrying([
193  $this->refinery->kindlyTo()->bool(),
194  $this->refinery->always(false)
195  ])->transform($value);
196  } else {
197  throw new \ILIAS\Refinery\ConstraintViolationException(
198  sprintf('The value "%s" is no array or string.', var_export($value, true)),
199  'value_is_no_array_or_string',
200  var_export($value, true)
201  );
202  }
203 
204  return $value;
205  }
206  );
207 
208  $scoring = $this->http->wrapper()->post()->retrieve(
209  'scoring',
210  $this->refinery->byTrying([
211  $transform_scoring,
212  $this->refinery->always([])
213  ])
214  );
215  $finalization = $this->http->wrapper()->post()->retrieve(
216  'evaluated',
217  $this->refinery->byTrying([
218  $transform_finalization,
219  $this->refinery->always([])
220  ])
221  );
222 
223  $pass = key($scoring);
224  $active_data = current($scoring);
225  $active_ids = array_keys($active_data);
226 
227  if (!$this->testAccess->checkScoreParticipantsAccessForActiveId(current($active_ids))) {
228  if ($ajax) {
229  $this->http->saveResponse(
230  $this->http->response()->withBody(
231  \ILIAS\Filesystem\Stream\Streams::ofString($this->lng->txt('cannot_edit_test'))
232  )
233  );
234  $this->http->sendResponse();
235  $this->http->close();
236  }
237 
238  $this->tpl->setOnScreenMessage('info', $this->lng->txt('cannot_edit_test'), true);
239  $this->ctrl->redirectByClass('ilobjtestgui', 'infoScreen');
240  }
241 
242  if ($scoring === []) {
243  $this->tpl->setOnScreenMessage('failure', $this->lng->txt('tst_save_manscoring_failed_unknown'));
245  return;
246  }
247 
248  $participantData = new ilTestParticipantData($this->db, $this->lng);
249  $manPointsPost = [];
250  $skipParticipant = [];
251  $maxPointsByQuestionId = [];
252 
253  $participantData->setActiveIdsFilter($active_ids);
254  $participantData->setParticipantAccessFilter(
256  );
257  $participantData->load($this->object->getTestId());
258 
259  foreach ($participantData->getActiveIds() as $active_id) {
260  $questions = $active_data[$active_id];
261 
262  // check for existing test result data
263  if (!$this->object->getTestResult($active_id, $pass)) {
264  if (!isset($skipParticipant[$pass])) {
265  $skipParticipant[$pass] = [];
266  }
267  $skipParticipant[$pass][$active_id] = true;
268 
269  continue;
270  }
271 
272  foreach ((array) $questions as $qst_id => $reached_points) {
273  if (!isset($manPointsPost[$pass])) {
274  $manPointsPost[$pass] = [];
275  }
276  if (!isset($manPointsPost[$pass][$active_id])) {
277  $manPointsPost[$pass][$active_id] = [];
278  }
279 
280  $feedback_text = $this->retrieveFeedback($active_id, $qst_id, $pass);
281 
288  $current_feedback_info = ilObjTest::getSingleManualFeedback($active_id, $qst_id, $pass);
289  if (isset($current_feedback_info['finalized_evaluation']) && $current_feedback_info['finalized_evaluation'] === 1) {
290  $reached_points = assQuestion::_getReachedPoints($active_id, $qst_id, $pass);
291  $feedback_text = $current_feedback_info['feedback'];
292  }
293 
294  $maxPointsByQuestionId[$qst_id] = assQuestion::_getMaximumPoints($qst_id);
295  $manPointsPost[$pass][$active_id][$qst_id] = $reached_points;
296 
297  if ($reached_points > $maxPointsByQuestionId[$qst_id]) {
298  $this->tpl->setOnScreenMessage(
299  'failure',
300  sprintf($this->lng->txt('tst_save_manscoring_failed'), $pass + 1),
301  false
302  );
303  $this->showManScoringByQuestionParticipantsTable($manPointsPost);
304  return;
305  }
306  }
307  }
308 
309  $changed_one = false;
310  $lastAndHopefullyCurrentQuestionId = null;
311 
312  foreach ($participantData->getActiveIds() as $active_id) {
313  $questions = $active_data[$active_id];
314  $update_participant = false;
315  $qst_id = null;
316 
317  if (!($skipParticipant[$pass][$active_id] ?? false)) {
318  foreach ((array) $questions as $qst_id => $reached_points) {
319  $this->saveFinalization(
320  $finalization,
321  (int) $active_id,
322  (int) $qst_id,
323  (int) $pass,
324  $feedback_text,
325  $ajax
326  );
327  // fix #35543: save manual points only if they differ from the existing points
328  // this prevents a question being set to "answered" if only feedback is entered
329  $old_points = assQuestion::_getReachedPoints($active_id, $qst_id, $pass);
330  if ($reached_points != $old_points) {
331  $update_participant = assQuestion::_setReachedPoints(
332  $active_id,
333  $qst_id,
334  $reached_points,
335  $maxPointsByQuestionId[$qst_id],
336  $pass,
337  true,
338  $this->object->areObligationsEnabled()
339  );
340  }
341  }
342 
343  if ($update_participant) {
345  $this->object->getId(),
347  );
348  }
349 
350  $changed_one = true;
351  $lastAndHopefullyCurrentQuestionId = $qst_id;
352  }
353  }
354 
355  $correction_feedback = [];
356  $correction_points = 0;
357 
358  if ($changed_one) {
359  $qTitle = '';
360 
361  if ($lastAndHopefullyCurrentQuestionId) {
362  $question = assQuestion::_instantiateQuestion($lastAndHopefullyCurrentQuestionId);
363  $qTitle = $question->getTitleForHTMLOutput();
364  }
365 
366  $msg = sprintf(
367  $this->lng->txt('tst_saved_manscoring_by_question_successfully'),
368  $qTitle,
369  $pass + 1
370  );
371 
372  $this->tpl->setOnScreenMessage('success', $msg, true);
373 
374  if (isset($active_id) && $lastAndHopefullyCurrentQuestionId) {
375  $correction_feedback = ilObjTest::getSingleManualFeedback(
376  (int) $active_id,
377  (int) $lastAndHopefullyCurrentQuestionId,
378  (int) $pass
379  );
380  $correction_points = assQuestion::_getReachedPoints(
381  $active_id,
382  $lastAndHopefullyCurrentQuestionId,
383  $pass
384  );
385  }
386  }
387 
388  if ($ajax && is_array($correction_feedback)) {
389  $finalized_by_usr_id = $correction_feedback['finalized_by_usr_id'];
390  if (!$finalized_by_usr_id) {
391  $finalized_by_usr_id = $user->getId();
392  }
393  $correction_feedback['finalized_by'] = ilObjUser::_lookupFullname($finalized_by_usr_id);
394  $correction_feedback['finalized_on_date'] = '';
395 
396  if (strlen($correction_feedback['finalized_tstamp']) > 0) {
397  $time = new ilDateTime($correction_feedback['finalized_tstamp'], IL_CAL_UNIX);
398  $correction_feedback['finalized_on_date'] = $time->get(IL_CAL_DATETIME);
399  }
400 
401  if (!$correction_feedback['feedback']) {
402  $correction_feedback['feedback'] = [];
403  }
404  if ($correction_feedback['finalized_evaluation'] == 1) {
405  $correction_feedback['finalized_evaluation'] = $this->lng->txt('yes');
406  } else {
407  $correction_feedback['finalized_evaluation'] = $this->lng->txt('no');
408  }
409 
410  $this->http->saveResponse(
411  $this->http->response()->withBody(
412  \ILIAS\Filesystem\Stream\Streams::ofString(
413  json_encode(
414  [
415  'feedback' => $correction_feedback,
416  'points' => $correction_points,
417  "translation" => [
418  'yes' => $this->lng->txt('yes'),
419  'no' => $this->lng->txt('no')
420  ]
421  ],
422  JSON_THROW_ON_ERROR
423  )
424  )
425  )
426  );
427  $this->http->sendResponse();
428  $this->http->close();
429  }
430 
432  }
433 
434  protected function applyManScoringByQuestionFilter(): void
435  {
437  $table->resetOffset();
438  $table->writeFilterToSession();
440  }
441 
442  protected function resetManScoringByQuestionFilter(): void
443  {
445  $table->resetOffset();
446  $table->resetFilter();
448  }
449 
450  protected function getAnswerDetail(): void
451  {
452  $active_id = $this->testrequest->getActiveId();
453  $pass = $this->testrequest->getPassId();
454  $question_id = (int) $this->testrequest->raw('qst_id');
455 
456  if (!$this->getTestAccess()->checkScoreParticipantsAccessForActiveId($active_id)) {
457  $this->http->close(); // illegal ajax call
458  }
459 
460  $data = $this->object->getCompleteEvaluationData(false);
461  $participant = $data->getParticipant($active_id);
462  $question_gui = $this->object->createQuestionGUI('', $question_id);
463  $tmp_tpl = new ilTemplate('tpl.il_as_tst_correct_solution_output.html', true, true, 'Modules/Test');
464  if ($question_gui instanceof assTextQuestionGUI && $this->object->getAutosave()) {
465  $aresult_output = $question_gui->getAutoSavedSolutionOutput(
466  $active_id,
467  $pass,
468  false,
469  false,
470  false,
471  $this->object->getShowSolutionFeedback(),
472  false,
473  true,
474  false
475  );
476  $tmp_tpl->setVariable('TEXT_ASOLUTION_OUTPUT', $this->lng->txt('autosavecontent'));
477  $tmp_tpl->setVariable('ASOLUTION_OUTPUT', $aresult_output);
478  }
479  $result_output = $question_gui->getSolutionOutput(
480  $active_id,
481  $pass,
482  false,
483  false,
484  false,
485  $this->object->getShowSolutionFeedback(),
486  false,
487  true
488  );
489  $max_points = $question_gui->object->getMaximumPoints();
490 
491  $this->appendUserNameToModal($tmp_tpl, $participant);
492  $this->appendQuestionTitleToModal($tmp_tpl, $question_id, $max_points, $question_gui->object->getTitleForHTMLOutput());
494  $tmp_tpl,
495  $result_output,
496  $question_gui->object->getReachedPoints($active_id, $pass),
497  $max_points
498  );
499  $this->appendFormToModal($tmp_tpl, $pass, $active_id, $question_id, $max_points);
500  $tmp_tpl->setVariable('TEXT_YOUR_SOLUTION', $this->lng->txt('answers_of') . ' ' . $participant->getName());
501  $suggested_solution = assQuestion::_getSuggestedSolutionOutput($question_id);
502  if ($this->object->getShowSolutionSuggested() && strlen($suggested_solution) > 0) {
503  $tmp_tpl->setVariable('TEXT_SOLUTION_HINT', $this->lng->txt("solution_hint"));
504  $tmp_tpl->setVariable("SOLUTION_HINT", assQuestion::_getSuggestedSolutionOutput($question_id));
505  }
506 
507  $tmp_tpl->setVariable('TEXT_SOLUTION_OUTPUT', $this->lng->txt('question'));
508  $tmp_tpl->setVariable('TEXT_RECEIVED_POINTS', $this->lng->txt('scoring'));
509  $add_title = ' [' . $this->lng->txt('question_id_short') . ': ' . $question_id . ']';
510  $question_title = $this->object->getQuestionTitle($question_gui->object->getTitleForHTMLOutput());
511  $lng = $this->lng->txt('points');
512  if ($max_points == 1) {
513  $lng = $this->lng->txt('point');
514  }
515 
516  $tmp_tpl->setVariable(
517  'QUESTION_TITLE',
518  $question_title . ' (' . $max_points . ' ' . $lng . ')' . $add_title
519  );
520  $tmp_tpl->setVariable('SOLUTION_OUTPUT', $result_output);
521 
522  $tmp_tpl->setVariable(
523  'RECEIVED_POINTS',
524  sprintf(
525  $this->lng->txt('part_received_a_of_b_points'),
526  $question_gui->object->getReachedPoints($active_id, $pass),
527  $max_points
528  )
529  );
530 
531  $this->http->saveResponse(
532  $this->http->response()->withBody(
533  \ILIAS\Filesystem\Stream\Streams::ofString($tmp_tpl->get())
534  )->withHeader(\ILIAS\HTTP\Response\ResponseHeader::CONTENT_TYPE, 'text/html')
535  );
536  $this->http->sendResponse();
537  $this->http->close();
538  }
539 
540  public function checkConstraintsBeforeSaving(): void
541  {
542  $this->saveManScoringByQuestion(true);
543  }
544 
545  private function appendUserNameToModal(ilTemplate $tmp_tpl, ilTestEvaluationUserData $participant): void
546  {
547  global $DIC;
548  $ilAccess = $DIC->access();
549 
550  $tmp_tpl->setVariable(
551  'TEXT_YOUR_SOLUTION',
552  $this->lng->txt('answers_of') . ' ' . $participant->getName()
553  );
554 
555  if (
556  $this->object->getAnonymity() === 1 ||
557  ($this->object->getAnonymity() === 2 && !$ilAccess->checkAccess('write', '', $this->object->getRefId()))
558  ) {
559  $tmp_tpl->setVariable(
560  'TEXT_YOUR_SOLUTION',
561  $this->lng->txt('answers_of') . ' ' . $this->lng->txt('anonymous')
562  );
563  }
564  }
565 
571  private function appendQuestionTitleToModal(ilTemplate $tmp_tpl, $question_id, $max_points, $title): void
572  {
573  $add_title = ' [' . $this->lng->txt('question_id_short') . ': ' . $question_id . ']';
574  $question_title = $this->object->getQuestionTitle($title);
575  $lng = $this->lng->txt('points');
576  if ($max_points == 1) {
577  $lng = $this->lng->txt('point');
578  }
579 
580  $tmp_tpl->setVariable(
581  'QUESTION_TITLE',
582  $question_title . ' (' . $max_points . ' ' . $lng . ')' . $add_title
583  );
584  }
585 
592  private function appendFormToModal(ilTemplate $tmp_tpl, $pass, $active_id, $question_id, $max_points): void
593  {
594  $post_var = '[' . $pass . '][' . $active_id . '][' . $question_id . ']';
595  $scoring_post_var = 'scoring' . $post_var;
596  $reached_points = assQuestion::_getReachedPoints($active_id, $question_id, $pass);
597  $form = new ilPropertyFormGUI();
598  $feedback = ilObjTest::getSingleManualFeedback((int) $active_id, (int) $question_id, (int) $pass);
599  $disable = false;
600  $form->setFormAction($this->ctrl->getFormAction($this, 'showManScoringByQuestionParticipantsTable'));
601  $form->setTitle($this->lng->txt('manscoring'));
602 
603  if (isset($feedback['finalized_evaluation']) && $feedback['finalized_evaluation'] == 1) {
604  $disable = true;
605  $hidden_points = new ilHiddenInputGUI($scoring_post_var);
606  $scoring_post_var = $scoring_post_var . '_disabled';
607  $hidden_points->setValue((string) $reached_points);
608  $form->addItem($hidden_points);
609  }
610 
611  $feedback_text = '';
612  if (array_key_exists('feedback', $feedback)) {
613  $feedback_text = $feedback['feedback'];
614  }
615 
616  if ($disable) {
617  $feedback_input = new ilNonEditableValueGUI(
618  $this->lng->txt('set_manual_feedback'),
619  'm_feedback' . $post_var,
620  true
621  );
622  } else {
623  $tmp_tpl->setVariable('TINYMCE_ACTIVE', ilObjAdvancedEditing::_getRichTextEditor());
624  $feedback_input = new ilTextAreaInputGUI($this->lng->txt('set_manual_feedback'), 'm_feedback' . $post_var);
625  }
626  $feedback_input->setValue($feedback_text);
627  $form->addItem($feedback_input);
628 
629  $reached_points_form = new ilNumberInputGUI(
630  $this->lng->txt('tst_change_points_for_question'),
631  $scoring_post_var
632  );
633  $reached_points_form->allowDecimals(true);
634  $reached_points_form->setSize(5);
635  $reached_points_form->setMaxValue($max_points, true);
636  $reached_points_form->setMinValue(0);
637  $reached_points_form->setDisabled($disable);
638  $reached_points_form->setValue((string) $reached_points);
639  $reached_points_form->setClientSideValidation(true);
640  $form->addItem($reached_points_form);
641 
642  $hidden_points = new ilHiddenInputGUI('qst_max_points');
643  $hidden_points->setValue((string) $max_points);
644  $form->addItem($hidden_points);
645 
646  $hidden_points_name = new ilHiddenInputGUI('qst_hidden_points_name');
647  $hidden_points_name->setValue('scoring' . $post_var);
648  $form->addItem($hidden_points_name);
649 
650  $hidden_feedback_name = new ilHiddenInputGUI('qst_hidden_feedback_name');
651  $hidden_feedback_name->setValue('m_feedback' . $post_var);
652  $form->addItem($hidden_feedback_name);
653 
654  $hidden_feedback_id = new ilHiddenInputGUI('qst_hidden_feedback_id');
655  $post_id = '__' . $pass . '____' . $active_id . '____' . $question_id . '__';
656  $hidden_feedback_id->setValue('m_feedback' . $post_id);
657  $form->addItem($hidden_feedback_id);
658 
659  $evaluated = new ilCheckboxInputGUI($this->lng->txt('finalized_evaluation'), 'evaluated' . $post_var);
660  if (isset($feedback['finalized_evaluation']) && (int) $feedback['finalized_evaluation'] === 1) {
661  $evaluated->setChecked(true);
662  }
663  $form->addItem($evaluated);
664 
665  $form->addCommandButton('checkConstraintsBeforeSaving', $this->lng->txt('save'));
666 
667  $tmp_tpl->setVariable(
668  'MANUAL_FEEDBACK',
669  $form->getHTML()
670  );
671  $tmp_tpl->setVariable(
672  'MODAL_AJAX_URL',
673  $this->ctrl->getLinkTarget($this, 'checkConstraintsBeforeSaving', '', true, false)
674  );
675  $tmp_tpl->setVariable(
676  'INFO_TEXT_MAX_POINTS_EXCEEDS',
677  sprintf($this->lng->txt('tst_manscoring_maxpoints_exceeded_input_alert'), $max_points)
678  );
679  }
680 
687  ilTemplate $tmp_tpl,
688  $result_output,
689  $reached_points,
690  $max_points
691  ): void {
692  $tmp_tpl->setVariable(
693  'SOLUTION_OUTPUT',
694  $result_output
695  );
696  $tmp_tpl->setVariable(
697  'RECEIVED_POINTS',
698  sprintf(
699  $this->lng->txt('part_received_a_of_b_points'),
700  $reached_points,
701  $max_points
702  )
703  );
704  }
705 
706  protected function retrieveFeedback(int $active_id, int $qst_id, int $pass): ?string
707  {
708  $feedback = $this->testrequest->raw('feedback');
709  if ($feedback === null || $feedback === '') {
710  $feedback = $this->testrequest->raw('m_feedback');
711  }
712 
713  if ($feedback === null || $feedback === '') {
714  return null;
715  }
716 
717  return ilUtil::stripSlashes(
718  $feedback[$pass][$active_id][$qst_id],
719  false,
721  );
722  }
723 
727  private function saveFinalization(
728  array $finalization,
729  int $active_id,
730  int $qst_id,
731  int $pass,
732  ?string $feedback,
733  bool $is_single_feedback
734  ): void {
735  $finalized = false;
736  if ($this->doesValueExistsInPostArray($finalization, $active_id, $qst_id, $pass)) {
737  $finalized = $finalization[$pass][$active_id][$qst_id] ?? false;
738  }
739 
740  $this->object->saveManualFeedback(
741  $active_id,
742  $qst_id,
743  $pass,
744  $feedback,
745  $finalized,
746  $is_single_feedback
747  );
748  }
749 
753  private function doesValueExistsInPostArray(array $finalization, int $active_id, int $qst_id, int $pass): bool
754  {
755  return isset($finalization[$pass][$active_id][$qst_id]);
756  }
757 }
const IL_CAL_DATETIME
static _getParticipantId($active_id)
Get user id for active id.
static _getRichTextEditor()
Returns the identifier for the Rich Text Editor.
static _getSuggestedSolutionOutput(int $question_id)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static _lookupFullname(int $a_user_id)
Class ChatMainBarProvider .
static stripSlashes(string $a_str, bool $a_strip_html=true, string $a_allow="")
if(strpos($jquery_path, './')===0) elseif(strpos($jquery_path, '.')===0) $mathJaxSetting
Definition: latex.php:54
This class represents a checkbox property in a property form.
appendQuestionTitleToModal(ilTemplate $tmp_tpl, $question_id, $max_points, $title)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
const IL_CAL_UNIX
appendSolutionAndPointsToModal(ilTemplate $tmp_tpl, $result_output, $reached_points, $max_points)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
global $DIC
Definition: feed.php:28
allowDecimals(bool $a_value)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static getSingleManualFeedback(int $active_id, int $question_id, int $pass)
static http()
Fetches the global http state from ILIAS.
setVariable($variable, $value='')
Sets a variable value.
Definition: IT.php:514
This class represents a number property in a property form.
appendFormToModal(ilTemplate $tmp_tpl, $pass, $active_id, $question_id, $max_points)
static _getReachedPoints(int $active_id, int $question_id, int $pass)
string $key
Consumer key/client ID value.
Definition: System.php:193
static _setReachedPoints(int $active_id, int $question_id, float $points, float $maxpoints, int $pass, bool $manualscoring, bool $obligationsEnabled)
Sets the points, a learner has reached answering the question Additionally objective results are upda...
static _getQuestionInfo(int $question_id)
static _getUsedHTMLTagsAsString(string $a_module="")
Returns a string of all allowed HTML tags for text editing.
appendUserNameToModal(ilTemplate $tmp_tpl, ilTestEvaluationUserData $participant)
doesValueExistsInPostArray(array $finalization, int $active_id, int $qst_id, int $pass)
static _getMaximumPoints(int $question_id)
Returns the maximum points, a learner can reach answering the question.
static _instantiateQuestion(int $question_id)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static initjQuery(ilGlobalTemplateInterface $a_tpl=null)
inits and adds the jQuery JS-File to the global or a passed template
__construct(Container $dic, ilPlugin $plugin)
This class represents a text area property in a property form.
showManScoringByQuestionParticipantsTable(array $manPointsPost=[])
retrieveFeedback(int $active_id, int $qst_id, int $pass)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
saveFinalization(array $finalization, int $active_id, int $qst_id, int $pass, ?string $feedback, bool $is_single_feedback)
Class FlySystemFileAccessTest disabled disabled disabled.
static initPanel(bool $a_resize=false, ?ilGlobalTemplateInterface $a_main_tpl=null)
Init yui panel used in Modules/Test, Services/TermsOfService (Jan 2022)
static _updateStatus(int $a_obj_id, int $a_usr_id, ?object $a_obj=null, bool $a_percentage=false, bool $a_force_raise=false)
static initOverlay(?ilGlobalTemplateInterface $a_main_tpl=null)
Init YUI Overlay module used in Modules/Test, Services/TermsOfService, Services/Tracking, Services/UIComponent.