19 include_once
'Modules/Test/classes/inc.AssessmentConstants.php';
26 private \ILIAS\HTTP\GlobalHttpState
$http;
32 $this->
http = $DIC->http();
37 return 'showManScoringByQuestionParticipantsTable';
42 return 'man_scoring_by_qst';
54 if (!$this->testAccess->checkScoreParticipantsAccess()) {
55 $this->tpl->setOnScreenMessage(
'info', $this->
lng->txt(
'cannot_edit_test'),
true);
56 $this->
ctrl->redirectByClass(
'ilobjtestgui',
'infoScreen');
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')]);
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();
81 $selected_questionData = null;
82 $complete_feedback = $this->
object->getCompleteManualFeedback($qst_id);
84 if (is_numeric($qst_id)) {
86 $selected_questionData = $info;
89 if ($selected_questionData && is_numeric($passNr)) {
90 $data = $this->
object->getCompleteEvaluationData(
false);
91 $participants =
$data->getParticipants();
100 $participant = $participants[$active_id];
101 $testResultData = $this->
object->getTestResult($active_id, $passNr - 1);
103 foreach ($testResultData as $questionData) {
105 $is_answered = (bool) ($questionData[
'answered'] ??
false);
106 $finalized_evaluation = (bool) ($questionData[
'finalized_evaluation'] ??
false);
108 if (isset($complete_feedback[$active_id][$passNr - 1][$qst_id])) {
109 $feedback = $complete_feedback[$active_id][$passNr - 1][$qst_id];
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) {
121 'pass_id' => $passNr - 1,
122 'active_id' => $active_id,
123 'qst_id' => $questionData[
'qid'],
126 (
int) $questionData[
'qid'],
130 'name' => $participant->getName()
135 $table->disable(
'header');
138 $table->setTitle($this->
lng->txt(
'tst_man_scoring_by_qst'));
140 if ($selected_questionData) {
142 $table->setCurQuestionMaxPoints($maxpoints);
143 $maxpoints_txt =
' (' . $maxpoints .
' ' . $this->
lng->txt(
'points') .
')';
144 if ($maxpoints == 1) {
145 $maxpoints_txt =
' (' . $maxpoints .
' ' . $this->
lng->txt(
'point') .
')';
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'] .
']' 154 $table->setData($table_data);
155 $this->tpl->setContent($table->getHTML());
158 protected function saveManScoringByQuestion(
bool $ajax =
false):
void 162 $user = $DIC->user();
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);
169 } elseif (is_string($value)) {
170 $value = $this->
refinery->byTrying([
171 $this->
refinery->kindlyTo()->float(),
173 ])->transform($value);
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)
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);
191 } elseif (is_string($value)) {
192 $value = $this->
refinery->byTrying([
193 $this->
refinery->kindlyTo()->bool(),
195 ])->transform($value);
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)
208 $scoring = $this->
http->wrapper()->post()->retrieve(
212 $this->refinery->always([])
215 $finalization = $this->
http->wrapper()->post()->retrieve(
218 $transform_finalization,
219 $this->refinery->always([])
223 $pass = key($scoring);
224 $active_data = current($scoring);
225 $active_ids = array_keys($active_data);
227 if (!$this->testAccess->checkScoreParticipantsAccessForActiveId(current($active_ids))) {
229 $this->
http->saveResponse(
230 $this->
http->response()->withBody(
234 $this->
http->sendResponse();
235 $this->
http->close();
238 $this->tpl->setOnScreenMessage(
'info', $this->
lng->txt(
'cannot_edit_test'),
true);
239 $this->
ctrl->redirectByClass(
'ilobjtestgui',
'infoScreen');
242 if ($scoring === []) {
243 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
'tst_save_manscoring_failed_unknown'));
250 $skipParticipant = [];
251 $maxPointsByQuestionId = [];
260 $questions = $active_data[$active_id];
263 if (!$this->
object->getTestResult($active_id, $pass)) {
264 if (!isset($skipParticipant[$pass])) {
265 $skipParticipant[$pass] = [];
267 $skipParticipant[$pass][$active_id] =
true;
272 foreach ((array) $questions as $qst_id => $reached_points) {
273 if (!isset($manPointsPost[$pass])) {
274 $manPointsPost[$pass] = [];
276 if (!isset($manPointsPost[$pass][$active_id])) {
277 $manPointsPost[$pass][$active_id] = [];
289 if (isset($current_feedback_info[
'finalized_evaluation']) && $current_feedback_info[
'finalized_evaluation'] === 1) {
291 $feedback_text = $current_feedback_info[
'feedback'];
295 $manPointsPost[$pass][$active_id][$qst_id] = $reached_points;
297 if ($reached_points > $maxPointsByQuestionId[$qst_id]) {
298 $this->tpl->setOnScreenMessage(
300 sprintf($this->
lng->txt(
'tst_save_manscoring_failed'), $pass + 1),
309 $changed_one =
false;
310 $lastAndHopefullyCurrentQuestionId = null;
313 $questions = $active_data[$active_id];
314 $update_participant =
false;
317 if (!($skipParticipant[$pass][$active_id] ??
false)) {
318 foreach ((array) $questions as $qst_id => $reached_points) {
330 if ($reached_points != $old_points) {
335 $maxPointsByQuestionId[$qst_id],
338 $this->
object->areObligationsEnabled()
343 if ($update_participant) {
351 $lastAndHopefullyCurrentQuestionId = $qst_id;
355 $correction_feedback = [];
356 $correction_points = 0;
361 if ($lastAndHopefullyCurrentQuestionId) {
363 $qTitle = $question->getTitleForHTMLOutput();
367 $this->
lng->txt(
'tst_saved_manscoring_by_question_successfully'),
372 $this->tpl->setOnScreenMessage(
'success', $msg,
true);
374 if (isset($active_id) && $lastAndHopefullyCurrentQuestionId) {
377 (
int) $lastAndHopefullyCurrentQuestionId,
382 $lastAndHopefullyCurrentQuestionId,
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();
394 $correction_feedback[
'finalized_on_date'] =
'';
396 if (strlen($correction_feedback[
'finalized_tstamp']) > 0) {
398 $correction_feedback[
'finalized_on_date'] = $time->get(
IL_CAL_DATETIME);
401 if (!$correction_feedback[
'feedback']) {
402 $correction_feedback[
'feedback'] = [];
404 if ($correction_feedback[
'finalized_evaluation'] == 1) {
405 $correction_feedback[
'finalized_evaluation'] = $this->
lng->txt(
'yes');
407 $correction_feedback[
'finalized_evaluation'] = $this->
lng->txt(
'no');
410 $this->
http->saveResponse(
411 $this->
http->response()->withBody(
415 'feedback' => $correction_feedback,
416 'points' => $correction_points,
418 'yes' => $this->
lng->txt(
'yes'),
419 'no' => $this->
lng->txt(
'no')
427 $this->
http->sendResponse();
428 $this->
http->close();
437 $table->resetOffset();
438 $table->writeFilterToSession();
445 $table->resetOffset();
446 $table->resetFilter();
452 $active_id = $this->testrequest->getActiveId();
453 $pass = $this->testrequest->getPassId();
454 $question_id = (
int) $this->testrequest->raw(
'qst_id');
456 if (!$this->
getTestAccess()->checkScoreParticipantsAccessForActiveId($active_id)) {
457 $this->
http->close();
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');
465 $aresult_output = $question_gui->getAutoSavedSolutionOutput(
471 $this->
object->getShowSolutionFeedback(),
476 $tmp_tpl->setVariable(
'TEXT_ASOLUTION_OUTPUT', $this->
lng->txt(
'autosavecontent'));
477 $tmp_tpl->setVariable(
'ASOLUTION_OUTPUT', $aresult_output);
479 $result_output = $question_gui->getSolutionOutput(
485 $this->
object->getShowSolutionFeedback(),
489 $max_points = $question_gui->object->getMaximumPoints();
496 $question_gui->object->getReachedPoints($active_id, $pass),
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());
502 if ($this->
object->getShowSolutionSuggested() && strlen($suggested_solution) > 0) {
503 $tmp_tpl->setVariable(
'TEXT_SOLUTION_HINT', $this->
lng->txt(
"solution_hint"));
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');
516 $tmp_tpl->setVariable(
518 $question_title .
' (' . $max_points .
' ' .
$lng .
')' . $add_title
520 $tmp_tpl->setVariable(
'SOLUTION_OUTPUT', $result_output);
522 $tmp_tpl->setVariable(
525 $this->
lng->txt(
'part_received_a_of_b_points'),
526 $question_gui->object->getReachedPoints($active_id, $pass),
531 $this->
http->saveResponse(
532 $this->
http->response()->withBody(
534 )->withHeader(\
ILIAS\
HTTP\Response\ResponseHeader::CONTENT_TYPE,
'text/html')
536 $this->
http->sendResponse();
537 $this->
http->close();
542 $this->saveManScoringByQuestion(
true);
548 $ilAccess = $DIC->access();
551 'TEXT_YOUR_SOLUTION',
552 $this->
lng->txt(
'answers_of') .
' ' . $participant->
getName()
556 $this->
object->getAnonymity() === 1 ||
557 ($this->
object->getAnonymity() === 2 && !$ilAccess->checkAccess(
'write',
'', $this->
object->getRefId()))
560 'TEXT_YOUR_SOLUTION',
561 $this->
lng->txt(
'answers_of') .
' ' . $this->
lng->txt(
'anonymous')
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');
582 $question_title .
' (' . $max_points .
' ' .
$lng .
')' . $add_title
594 $post_var =
'[' . $pass .
'][' . $active_id .
'][' . $question_id .
']';
595 $scoring_post_var =
'scoring' . $post_var;
600 $form->setFormAction($this->
ctrl->getFormAction($this,
'showManScoringByQuestionParticipantsTable'));
601 $form->setTitle($this->
lng->txt(
'manscoring'));
603 if (isset($feedback[
'finalized_evaluation']) && $feedback[
'finalized_evaluation'] == 1) {
606 $scoring_post_var = $scoring_post_var .
'_disabled';
607 $hidden_points->setValue((
string) $reached_points);
608 $form->addItem($hidden_points);
612 if (array_key_exists(
'feedback', $feedback)) {
613 $feedback_text = $feedback[
'feedback'];
618 $this->
lng->txt(
'set_manual_feedback'),
619 'm_feedback' . $post_var,
624 $feedback_input =
new ilTextAreaInputGUI($this->
lng->txt(
'set_manual_feedback'),
'm_feedback' . $post_var);
626 $feedback_input->
setValue($feedback_text);
627 $form->addItem($feedback_input);
630 $this->
lng->txt(
'tst_change_points_for_question'),
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);
643 $hidden_points->setValue((
string) $max_points);
644 $form->addItem($hidden_points);
647 $hidden_points_name->setValue(
'scoring' . $post_var);
648 $form->addItem($hidden_points_name);
651 $hidden_feedback_name->setValue(
'm_feedback' . $post_var);
652 $form->addItem($hidden_feedback_name);
655 $post_id =
'__' . $pass .
'____' . $active_id .
'____' . $question_id .
'__';
656 $hidden_feedback_id->setValue(
'm_feedback' . $post_id);
657 $form->addItem($hidden_feedback_id);
659 $evaluated =
new ilCheckboxInputGUI($this->
lng->txt(
'finalized_evaluation'),
'evaluated' . $post_var);
660 if (isset($feedback[
'finalized_evaluation']) && (
int) $feedback[
'finalized_evaluation'] === 1) {
663 $form->addItem($evaluated);
665 $form->addCommandButton(
'checkConstraintsBeforeSaving', $this->
lng->txt(
'save'));
673 $this->
ctrl->getLinkTarget($this,
'checkConstraintsBeforeSaving',
'',
true,
false)
676 'INFO_TEXT_MAX_POINTS_EXCEEDS',
677 sprintf($this->
lng->txt(
'tst_manscoring_maxpoints_exceeded_input_alert'), $max_points)
699 $this->
lng->txt(
'part_received_a_of_b_points'),
708 $feedback = $this->testrequest->raw(
'feedback');
709 if ($feedback === null || $feedback ===
'') {
710 $feedback = $this->testrequest->raw(
'm_feedback');
713 if ($feedback === null || $feedback ===
'') {
718 $feedback[$pass][$active_id][$qst_id],
733 bool $is_single_feedback
737 $finalized = $finalization[$pass][$active_id][$qst_id] ??
false;
740 $this->
object->saveManualFeedback(
755 return isset($finalization[$pass][$active_id][$qst_id]);
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
const TAB_ID_MANUAL_SCORING
ILIAS HTTP GlobalHttpState $http
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...
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...
applyManScoringByQuestionFilter()
setValue(string $a_value)
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.
appendFormToModal(ilTemplate $tmp_tpl, $pass, $active_id, $question_id, $max_points)
static _getReachedPoints(int $active_id, int $question_id, int $pass)
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)
checkConstraintsBeforeSaving()
resetManScoringByQuestionFilter()
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
static getScoreParticipantsUserFilter($refId)
__construct(Container $dic, ilPlugin $plugin)
This class represents a text area property in a property form.
showManScoringByQuestionParticipantsTable(array $manPointsPost=[])
__construct(ilObjTest $a_object)
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.