ILIAS  release_9 Revision v9.13-25-g2c18ec4c24f
ilTestScoringByQuestionsGUI Class Reference
+ Inheritance diagram for ilTestScoringByQuestionsGUI:
+ Collaboration diagram for ilTestScoringByQuestionsGUI:

Public Member Functions

 __construct (ilObjTest $a_object)
 
 checkConstraintsBeforeSaving ()
 
- Public Member Functions inherited from ilTestScoringGUI
 __construct (ilObjTest $a_object)
 ilTestScoringGUI constructor More...
 
 getTestAccess ()
 
 setTestAccess ($testAccess)
 
 executeCommand ()
 execute command More...
 
- Public Member Functions inherited from ilTestServiceGUI
 isContextResultPresentation ()
 
 setContextResultPresentation (bool $contextResultPresentation)
 
 setParticipantData (ilTestParticipantData $participantData)
 
 getParticipantData ()
 
 getPassOverviewTableData (ilTestSession $testSession, $passes, $withResults)
 This method uses the data of a given test pass to create an evaluation for displaying into a table used in the ilTestEvaluationGUI. More...
 
 setObjectiveOrientedContainer (ilTestObjectiveOrientedContainer $objective_oriented_container)
 
 getObjectiveOrientedContainer ()
 
 executeCommand ()
 execute command More...
 
 getCommand ($cmd)
 Retrieves the ilCtrl command. More...
 
 buildPassOverviewTableGUI (ilTestEvaluationGUI $target_gui)
 
 getPassListOfAnswers (&$result_array, $active_id, $pass, $show_solutions=false, $only_answered_questions=false, $show_question_only=false, $show_reached_points=false, $anchorNav=false, ilTestQuestionRelatedObjectivesList $objectives_list=null, ilTestResultHeaderLabelBuilder $testResultHeaderLabelBuilder=null)
 Returns the list of answers of a users test pass. More...
 
 getPassListOfAnswersWithScoring (&$result_array, $active_id, $pass, $show_solutions=false)
 Returns the list of answers of a users test pass and offers a scoring option. More...
 
 getResultsSignature ()
 Returns HTML code for a signature field. More...
 
 getAdditionalUsrDataHtmlAndPopulateWindowTitle ($testSession, $active_id, $overwrite_anonymity=false)
 Returns the user data for a test results output. More...
 
 getCorrectSolutionOutput ($question_id, $active_id, $pass, ilTestQuestionRelatedObjectivesList $objectives_list=null)
 Returns an output of the solution to an answer compared to the correct solution. More...
 
 getResultsOfUserOutput (ilTestSession $testSession, int $active_id, int $pass, ilParticipantsTestResultsGUI $target_gui, bool $show_pass_details=true, bool $show_answers=true, bool $show_question_only=false, bool $show_reached_points=false)
 Output of the pass overview for a test called by a test participant. More...
 
 getResultsHeadUserAndPass ($active_id, $pass)
 Returns the user and pass data for a test results output. More...
 
 getQuestionResultForTestUsers (int $question_id, int $test_id)
 
 getObject ()
 

Data Fields

const EXCEPT_FINALIZED = '1'
 
const ONLY_FINALIZED = '2'
 
- Data Fields inherited from ilTestScoringGUI
const PART_FILTER_ALL_USERS = 3
 
const PART_FILTER_MANSCORING_DONE = 4
 
const PART_FILTER_MANSCORING_NONE = 5
 

Protected Member Functions

 getDefaultCommand ()
 
 getActiveSubTabId ()
 
 showManScoringByQuestionParticipantsTable (array $manPointsPost=[])
 
 saveManScoringByQuestion (bool $ajax=false)
 
 applyManScoringByQuestionFilter ()
 
 resetManScoringByQuestionFilter ()
 
 getAnswerDetail ()
 
 retrieveFeedback (int $active_id, int $qst_id, int $pass)
 
- Protected Member Functions inherited from ilTestScoringGUI
 buildSubTabs ($active_sub_tab='man_scoring_by_qst')
 
 getDefaultCommand ()
 
 getActiveSubTabId ()
 
- Protected Member Functions inherited from ilTestServiceGUI
 getPassDetailsOverviewTableGUI (array $result_array, int $active_id, int $pass, ilTestServiceGUI|ilParticipantsTestResultsGUI $target_gui, string $target_cmd, ilTestQuestionRelatedObjectivesList $objectives_list=null, bool $multiple_objectives_involved=true)
 
 buildPassDetailsOverviewTableGUI (ilTestServiceGUI|ilParticipantsTestResultsGUI $target_gui, string $target_cmd)
 
 isGradingMessageRequired ()
 
 getGradingMessageBuilder (int $active_id)
 
 buildQuestionRelatedObjectivesList (ilLOTestQuestionAdapter $objectives_adapter, ilTestQuestionSequence $test_sequence)
 
 getFilteredTestResult (int $active_id, int $pass, bool $considerHiddenQuestions, bool $considerOptionalQuestions)
 
 populateContent ($content)
 
 buildUserTestResultsToolbarGUI ()
 
 outCorrectSolutionCmd ()
 
 outCorrectSolution ()
 Creates an output of the solution of an answer compared to the correct solution. More...
 
 populatePassFinishDate (ilTemplate $tpl, ?int $pass_finish_date)
 
 populateExamId (ilTemplate $tpl, int $active_id, int $pass)
 

Private Member Functions

 appendUserNameToModal (ilTemplate $tmp_tpl, ilTestEvaluationUserData $participant_data)
 
 appendQuestionTitleToModal (ilTemplate $tmp_tpl, int $question_id, float $max_points, string $title)
 
 appendFormToModal (ilTemplate $tmp_tpl, int $pass, int $active_id, int $question_id, float $max_points)
 
 appendSolutionAndPointsToModal (ilTemplate $tmp_tpl, $result_output, $reached_points, $max_points)
 
 saveFinalization (array $finalization, int $active_id, int $qst_id, int $pass, ?string $feedback, bool $is_single_feedback)
 
 doesValueExistsInPostArray (array $finalization, int $active_id, int $qst_id, int $pass)
 

Additional Inherited Members

- Protected Attributes inherited from ilTestScoringGUI
 $testAccess
 
- Protected Attributes inherited from ilTestServiceGUI
InternalRequestService $testrequest
 
ILIAS TestQuestionPool QuestionInfoService $questioninfo
 
ilTestService $service = null
 
ilDBInterface $db
 
ilLanguage $lng
 
LoggingServices $logging_services
 
ilHelpGUI $help
 
ilRbacSystem $rbac_system
 
ilGlobalTemplateInterface ilTemplate $tpl
 sk 2023-08-01: We need this union type, even if it is wrong! To change this More...
 
ContentStyle $content_style
 
ilErrorHandling $error
 
ilAccess $access
 
HTTPServices $http
 
ilCtrl $ctrl
 
ilToolbarGUI $toolbar
 
ilTabsGUI $tabs
 
ilObjectDataCache $obj_cache
 
ilComponentRepository $component_repository
 
ilObjUser $user
 
ArrayBasedRequestWrapper $post_wrapper
 
ilNavigationHistory $navigation_history
 
Refinery $refinery
 
UIFactory $ui_factory
 
UIRenderer $ui_renderer
 
SkillService $skills_service
 
ilTestShuffler $shuffler
 
ilTestResultsFactory $results_factory
 
ilTestResultsPresentationFactory $results_presentation_factory
 
ILIAS $ilias
 
ilSetting $settings
 
GlobalScreenServices $global_screen
 
ilTree $tree
 
int $ref_id
 
ilTestSessionFactory $testSessionFactory = null
 
ilTestSequenceFactory $testSequenceFactory = null
 
ilTestParticipantData $participantData = null
 
ilTestParticipantAccessFilterFactory $participant_access_filter
 

Detailed Description

Definition at line 23 of file class.ilTestScoringByQuestionsGUI.php.

Constructor & Destructor Documentation

◆ __construct()

ilTestScoringByQuestionsGUI::__construct ( ilObjTest  $a_object)

Definition at line 28 of file class.ilTestScoringByQuestionsGUI.php.

References ILIAS\MetaData\Repository\Validation\Data\__construct().

29  {
30  parent::__construct($a_object);
31  }
__construct(VocabulariesInterface $vocabularies)
+ Here is the call graph for this function:

Member Function Documentation

◆ appendFormToModal()

ilTestScoringByQuestionsGUI::appendFormToModal ( ilTemplate  $tmp_tpl,
int  $pass,
int  $active_id,
int  $question_id,
float  $max_points 
)
private

Definition at line 565 of file class.ilTestScoringByQuestionsGUI.php.

References assQuestion\_getReachedPoints(), ilObjAdvancedEditing\_getRichTextEditor(), ILIAS\Repository\ctrl(), ilObjTest\getSingleManualFeedback(), ILIAS\Repository\int(), ILIAS\Repository\lng(), ilTextAreaInputGUI\setValue(), and HTML_Template_IT\setVariable().

Referenced by getAnswerDetail().

565  : void
566  {
567  $post_var = '[' . $pass . '][' . $active_id . '][' . $question_id . ']';
568  $scoring_post_var = 'scoring' . $post_var;
569  $reached_points = assQuestion::_getReachedPoints($active_id, $question_id, $pass);
570  $form = new ilPropertyFormGUI();
571  $feedback = ilObjTest::getSingleManualFeedback((int) $active_id, (int) $question_id, (int) $pass);
572  $disable = false;
573  $form->setFormAction($this->ctrl->getFormAction($this, 'showManScoringByQuestionParticipantsTable'));
574  $form->setTitle($this->lng->txt('manscoring'));
575 
576  if (isset($feedback['finalized_evaluation']) && $feedback['finalized_evaluation'] == 1) {
577  $disable = true;
578  $hidden_points = new ilHiddenInputGUI($scoring_post_var);
579  $scoring_post_var = $scoring_post_var . '_disabled';
580  $hidden_points->setValue((string) $reached_points);
581  $form->addItem($hidden_points);
582  }
583 
584  $feedback_text = '';
585  if (array_key_exists('feedback', $feedback)) {
586  $feedback_text = $feedback['feedback'];
587  }
588 
589  if ($disable) {
590  $feedback_input = new ilNonEditableValueGUI(
591  $this->lng->txt('set_manual_feedback'),
592  'm_feedback' . $post_var,
593  true
594  );
595  } else {
596  $tmp_tpl->setVariable('TINYMCE_ACTIVE', ilObjAdvancedEditing::_getRichTextEditor());
597  $feedback_input = new ilTextAreaInputGUI($this->lng->txt('set_manual_feedback'), 'm_feedback' . $post_var);
598  }
599  $feedback_input->setValue($feedback_text);
600  $form->addItem($feedback_input);
601 
602  $reached_points_form = new ilNumberInputGUI(
603  $this->lng->txt('tst_change_points_for_question'),
604  $scoring_post_var
605  );
606  $reached_points_form->allowDecimals(true);
607  $reached_points_form->setSize(5);
608  $reached_points_form->setMaxValue($max_points, true);
609  $reached_points_form->setMinValue(0);
610  $reached_points_form->setDisabled($disable);
611  $reached_points_form->setValue((string) $reached_points);
612  $reached_points_form->setClientSideValidation(true);
613  $form->addItem($reached_points_form);
614 
615  $hidden_points = new ilHiddenInputGUI('qst_max_points');
616  $hidden_points->setValue((string) $max_points);
617  $form->addItem($hidden_points);
618 
619  $hidden_points_name = new ilHiddenInputGUI('qst_hidden_points_name');
620  $hidden_points_name->setValue('scoring' . $post_var);
621  $form->addItem($hidden_points_name);
622 
623  $hidden_feedback_name = new ilHiddenInputGUI('qst_hidden_feedback_name');
624  $hidden_feedback_name->setValue('m_feedback' . $post_var);
625  $form->addItem($hidden_feedback_name);
626 
627  $hidden_feedback_id = new ilHiddenInputGUI('qst_hidden_feedback_id');
628  $post_id = '__' . $pass . '____' . $active_id . '____' . $question_id . '__';
629  $hidden_feedback_id->setValue('m_feedback' . $post_id);
630  $form->addItem($hidden_feedback_id);
631 
632  $evaluated = new ilCheckboxInputGUI($this->lng->txt('finalized_evaluation'), 'evaluated' . $post_var);
633  if (isset($feedback['finalized_evaluation']) && (int) $feedback['finalized_evaluation'] === 1) {
634  $evaluated->setChecked(true);
635  }
636  $form->addItem($evaluated);
637 
638  $form->addCommandButton('checkConstraintsBeforeSaving', $this->lng->txt('save'));
639 
640  $tmp_tpl->setVariable(
641  'MANUAL_FEEDBACK',
642  $form->getHTML()
643  );
644  $tmp_tpl->setVariable(
645  'MODAL_AJAX_URL',
646  $this->ctrl->getLinkTarget($this, 'checkConstraintsBeforeSaving', '', true, false)
647  );
648  $tmp_tpl->setVariable(
649  'INFO_TEXT_MAX_POINTS_EXCEEDS',
650  sprintf($this->lng->txt('tst_manscoring_maxpoints_exceeded_input_alert'), $max_points)
651  );
652  }
static _getRichTextEditor()
Returns the identifier for the Rich Text Editor.
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)
setVariable($variable, $value='')
Sets a variable value.
Definition: IT.php:546
static _getReachedPoints(int $active_id, int $question_id, int $pass)
This class represents a text area property in a property form.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ appendQuestionTitleToModal()

ilTestScoringByQuestionsGUI::appendQuestionTitleToModal ( ilTemplate  $tmp_tpl,
int  $question_id,
float  $max_points,
string  $title 
)
private

Definition at line 550 of file class.ilTestScoringByQuestionsGUI.php.

References ilTestServiceGUI\$lng, ILIAS\Repository\lng(), and HTML_Template_IT\setVariable().

Referenced by getAnswerDetail().

550  : void
551  {
552  $add_title = ' [' . $this->lng->txt('question_id_short') . ': ' . $question_id . ']';
553  $question_title = $this->object->getQuestionTitle($title);
554  $lng = $this->lng->txt('points');
555  if ($max_points == 1) {
556  $lng = $this->lng->txt('point');
557  }
558 
559  $tmp_tpl->setVariable(
560  'QUESTION_TITLE',
561  $question_title . ' (' . $max_points . ' ' . $lng . ')' . $add_title
562  );
563  }
setVariable($variable, $value='')
Sets a variable value.
Definition: IT.php:546
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ appendSolutionAndPointsToModal()

ilTestScoringByQuestionsGUI::appendSolutionAndPointsToModal ( ilTemplate  $tmp_tpl,
  $result_output,
  $reached_points,
  $max_points 
)
private
Parameters
ilTemplate$tmp_tpl
$result_output
$reached_points
$max_points

Definition at line 660 of file class.ilTestScoringByQuestionsGUI.php.

References ILIAS\Repository\lng(), and HTML_Template_IT\setVariable().

Referenced by getAnswerDetail().

665  : void {
666  $tmp_tpl->setVariable(
667  'SOLUTION_OUTPUT',
668  $result_output
669  );
670  $tmp_tpl->setVariable(
671  'RECEIVED_POINTS',
672  sprintf(
673  $this->lng->txt('part_received_a_of_b_points'),
674  $reached_points,
675  $max_points
676  )
677  );
678  }
setVariable($variable, $value='')
Sets a variable value.
Definition: IT.php:546
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ appendUserNameToModal()

ilTestScoringByQuestionsGUI::appendUserNameToModal ( ilTemplate  $tmp_tpl,
ilTestEvaluationUserData  $participant_data 
)
private

Definition at line 532 of file class.ilTestScoringByQuestionsGUI.php.

References ILIAS\Repository\access(), ilTestEvaluationUserData\getName(), ILIAS\Repository\lng(), ILIAS\Repository\object(), and HTML_Template_IT\setVariable().

Referenced by getAnswerDetail().

532  : void
533  {
534  $tmp_tpl->setVariable(
535  'TEXT_YOUR_SOLUTION',
536  $this->lng->txt('answers_of') . ' ' . $participant_data->getName()
537  );
538 
539  if (
540  $this->object->getAnonymity() == 1 ||
541  ($this->object->getAnonymity() == 2 && !$this->access->checkAccess('write', '', $this->object->getRefId()))
542  ) {
543  $tmp_tpl->setVariable(
544  'TEXT_YOUR_SOLUTION',
545  $this->lng->txt('answers_of') . ' ' . $this->lng->txt('anonymous')
546  );
547  }
548  }
setVariable($variable, $value='')
Sets a variable value.
Definition: IT.php:546
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ applyManScoringByQuestionFilter()

ilTestScoringByQuestionsGUI::applyManScoringByQuestionFilter ( )
protected

Definition at line 419 of file class.ilTestScoringByQuestionsGUI.php.

References ILIAS\Repository\access(), and showManScoringByQuestionParticipantsTable().

419  : void
420  {
422  $table->resetOffset();
423  $table->writeFilterToSession();
425  }
showManScoringByQuestionParticipantsTable(array $manPointsPost=[])
+ Here is the call graph for this function:

◆ checkConstraintsBeforeSaving()

ilTestScoringByQuestionsGUI::checkConstraintsBeforeSaving ( )

Definition at line 527 of file class.ilTestScoringByQuestionsGUI.php.

References saveManScoringByQuestion().

527  : void
528  {
529  $this->saveManScoringByQuestion(true);
530  }
+ Here is the call graph for this function:

◆ doesValueExistsInPostArray()

ilTestScoringByQuestionsGUI::doesValueExistsInPostArray ( array  $finalization,
int  $active_id,
int  $qst_id,
int  $pass 
)
private
Parameters
array<numeric-string|int,array<numeric-string|int,array<numeric-string|int,bool>>>$finalization

Definition at line 727 of file class.ilTestScoringByQuestionsGUI.php.

Referenced by saveFinalization().

727  : bool
728  {
729  return isset($finalization[$pass][$active_id][$qst_id]);
730  }
+ Here is the caller graph for this function:

◆ getActiveSubTabId()

ilTestScoringByQuestionsGUI::getActiveSubTabId ( )
protected

Definition at line 38 of file class.ilTestScoringByQuestionsGUI.php.

38  : string
39  {
40  return 'man_scoring_by_qst';
41  }

◆ getAnswerDetail()

ilTestScoringByQuestionsGUI::getAnswerDetail ( )
protected

Definition at line 435 of file class.ilTestScoringByQuestionsGUI.php.

References $data, ilTestServiceGUI\$lng, assQuestion\_getSuggestedSolutionOutput(), appendFormToModal(), appendQuestionTitleToModal(), appendSolutionAndPointsToModal(), appendUserNameToModal(), ilTestScoringGUI\getTestAccess(), ILIAS\FileDelivery\http(), ILIAS\Repository\int(), ILIAS\Repository\lng(), and ILIAS\Repository\object().

435  : void
436  {
437  $active_id = $this->testrequest->getActiveId();
438  $pass = $this->testrequest->getPassId();
439  $question_id = (int) $this->testrequest->raw('qst_id');
440 
441  if (!$this->getTestAccess()->checkScoreParticipantsAccessForActiveId($active_id)) {
442  $this->http->close(); // illegal ajax call
443  }
444 
445  $data = $this->object->getCompleteEvaluationData(false);
446  $participant = $data->getParticipant($active_id);
447  $question_gui = $this->object->createQuestionGUI('', $question_id);
448  $tmp_tpl = new ilTemplate('tpl.il_as_tst_correct_solution_output.html', true, true, 'Modules/Test');
449  if ($this->object->getAutosave()) {
450  $aresult_output = $question_gui->getAutoSavedSolutionOutput(
451  $active_id,
452  $pass,
453  false,
454  false,
455  false,
456  $this->object->getShowSolutionFeedback(),
457  false,
458  true,
459  false
460  );
461  if ($aresult_output) {
462  $tmp_tpl->setVariable('TEXT_ASOLUTION_OUTPUT', $this->lng->txt('autosavecontent'));
463  $tmp_tpl->setVariable('ASOLUTION_OUTPUT', $aresult_output);
464  }
465  }
466  $result_output = $question_gui->getSolutionOutput(
467  $active_id,
468  $pass,
469  false,
470  false,
471  false,
472  $this->object->getShowSolutionFeedback(),
473  false,
474  true
475  );
476  $max_points = $question_gui->object->getMaximumPoints();
477 
478  $this->appendUserNameToModal($tmp_tpl, $participant);
479  $this->appendQuestionTitleToModal($tmp_tpl, $question_id, $max_points, $question_gui->object->getTitleForHTMLOutput());
481  $tmp_tpl,
482  $result_output,
483  $question_gui->object->getReachedPoints($active_id, $pass),
484  $max_points
485  );
486  $this->appendFormToModal($tmp_tpl, $pass, $active_id, $question_id, $max_points);
487  $tmp_tpl->setVariable('TEXT_YOUR_SOLUTION', $this->lng->txt('answers_of') . ' ' . $participant->getName());
488  $suggested_solution = assQuestion::_getSuggestedSolutionOutput($question_id);
489  if ($this->object->getShowSolutionSuggested() && strlen($suggested_solution) > 0) {
490  $tmp_tpl->setVariable('TEXT_SOLUTION_HINT', $this->lng->txt("solution_hint"));
491  $tmp_tpl->setVariable("SOLUTION_HINT", assQuestion::_getSuggestedSolutionOutput($question_id));
492  }
493 
494  $tmp_tpl->setVariable('TEXT_SOLUTION_OUTPUT', $this->lng->txt('question'));
495  $tmp_tpl->setVariable('TEXT_RECEIVED_POINTS', $this->lng->txt('scoring'));
496  $add_title = ' [' . $this->lng->txt('question_id_short') . ': ' . $question_id . ']';
497  $question_title = $this->object->getQuestionTitle($question_gui->object->getTitleForHTMLOutput());
498  $lng = $this->lng->txt('points');
499  if ($max_points == 1) {
500  $lng = $this->lng->txt('point');
501  }
502 
503  $tmp_tpl->setVariable(
504  'QUESTION_TITLE',
505  $question_title . ' (' . $max_points . ' ' . $lng . ')' . $add_title
506  );
507  $tmp_tpl->setVariable('SOLUTION_OUTPUT', $result_output);
508 
509  $tmp_tpl->setVariable(
510  'RECEIVED_POINTS',
511  sprintf(
512  $this->lng->txt('part_received_a_of_b_points'),
513  $question_gui->object->getReachedPoints($active_id, $pass),
514  $max_points
515  )
516  );
517 
518  $this->http->saveResponse(
519  $this->http->response()->withBody(
520  \ILIAS\Filesystem\Stream\Streams::ofString($tmp_tpl->get())
521  )->withHeader(\ILIAS\HTTP\Response\ResponseHeader::CONTENT_TYPE, 'text/html')
522  );
523  $this->http->sendResponse();
524  $this->http->close();
525  }
static _getSuggestedSolutionOutput(int $question_id)
Class ChatMainBarProvider .
appendQuestionTitleToModal(ilTemplate $tmp_tpl, int $question_id, float $max_points, string $title)
appendSolutionAndPointsToModal(ilTemplate $tmp_tpl, $result_output, $reached_points, $max_points)
static http()
Fetches the global http state from ILIAS.
appendFormToModal(ilTemplate $tmp_tpl, int $pass, int $active_id, int $question_id, float $max_points)
appendUserNameToModal(ilTemplate $tmp_tpl, ilTestEvaluationUserData $participant_data)
+ Here is the call graph for this function:

◆ getDefaultCommand()

ilTestScoringByQuestionsGUI::getDefaultCommand ( )
protected

Definition at line 33 of file class.ilTestScoringByQuestionsGUI.php.

33  : string
34  {
35  return 'showManScoringByQuestionParticipantsTable';
36  }

◆ resetManScoringByQuestionFilter()

ilTestScoringByQuestionsGUI::resetManScoringByQuestionFilter ( )
protected

Definition at line 427 of file class.ilTestScoringByQuestionsGUI.php.

References ILIAS\Repository\access(), and showManScoringByQuestionParticipantsTable().

427  : void
428  {
430  $table->resetOffset();
431  $table->resetFilter();
433  }
showManScoringByQuestionParticipantsTable(array $manPointsPost=[])
+ Here is the call graph for this function:

◆ retrieveFeedback()

ilTestScoringByQuestionsGUI::retrieveFeedback ( int  $active_id,
int  $qst_id,
int  $pass 
)
protected

Definition at line 680 of file class.ilTestScoringByQuestionsGUI.php.

References ilObjAdvancedEditing\_getUsedHTMLTagsAsString(), and ilUtil\stripSlashes().

Referenced by saveManScoringByQuestion().

680  : ?string
681  {
682  $feedback = $this->testrequest->raw('feedback');
683  if ($feedback === null || $feedback === '') {
684  $feedback = $this->testrequest->raw('m_feedback');
685  }
686 
687  if ($feedback === null || $feedback === '') {
688  return null;
689  }
690 
691  return ilUtil::stripSlashes(
692  $feedback[$pass][$active_id][$qst_id],
693  false,
695  );
696  }
static stripSlashes(string $a_str, bool $a_strip_html=true, string $a_allow="")
static _getUsedHTMLTagsAsString(string $a_module="")
Returns a string of all allowed HTML tags for text editing.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ saveFinalization()

ilTestScoringByQuestionsGUI::saveFinalization ( array  $finalization,
int  $active_id,
int  $qst_id,
int  $pass,
?string  $feedback,
bool  $is_single_feedback 
)
private
Parameters
array<numeric-string|int,array<numeric-string|int,array<numeric-string|int,bool>>>$finalization

Definition at line 701 of file class.ilTestScoringByQuestionsGUI.php.

References doesValueExistsInPostArray().

Referenced by saveManScoringByQuestion().

708  : void {
709  $finalized = false;
710  if ($this->doesValueExistsInPostArray($finalization, $active_id, $qst_id, $pass)) {
711  $finalized = $finalization[$pass][$active_id][$qst_id] ?? false;
712  }
713 
714  $this->object->saveManualFeedback(
715  $active_id,
716  $qst_id,
717  $pass,
718  $feedback,
719  $finalized,
720  $is_single_feedback
721  );
722  }
doesValueExistsInPostArray(array $finalization, int $active_id, int $qst_id, int $pass)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ saveManScoringByQuestion()

ilTestScoringByQuestionsGUI::saveManScoringByQuestion ( bool  $ajax = false)
protected

26.09.23 sk: Ok, this is a hack, but to do this right we need to go through the whole flow here. It is very convoluted and I'm unsure what would happen if I would really change something. This feature is in urgent need of refactoring and a repo.

Definition at line 154 of file class.ilTestScoringByQuestionsGUI.php.

References ILIAS\LTI\ToolProvider\$key, ilTestServiceGUI\$participantData, ilObjTestAccess\_getParticipantId(), assQuestion\_getReachedPoints(), ilObjUser\_lookupFullname(), assQuestion\_setReachedPoints(), ilLPStatusWrapper\_updateStatus(), ILIAS\Repository\ctrl(), ilTestParticipantData\getActiveIds(), ilObjTest\getSingleManualFeedback(), ilTestScoringGUI\getTestAccess(), ILIAS\FileDelivery\http(), IL_CAL_DATETIME, IL_CAL_UNIX, assQuestion\instantiateQuestion(), ILIAS\Repository\lng(), ilTestParticipantData\load(), ILIAS\Repository\object(), ILIAS\Repository\refinery(), retrieveFeedback(), saveFinalization(), ilTestParticipantData\setActiveIdsFilter(), ilTestParticipantData\setParticipantAccessFilter(), showManScoringByQuestionParticipantsTable(), and ILIAS\Repository\user().

Referenced by checkConstraintsBeforeSaving().

154  : void
155  {
156  $transform_scoring = $this->refinery->custom()->transformation(function ($value) use (&$transform_scoring) {
157  if (is_array($value)) {
158  foreach ($value as $key => $val) {
159  $value[$key] = $transform_scoring->transform($val);
160  }
161  } elseif (is_string($value)) {
162  $value = $this->refinery->byTrying([
163  $this->refinery->kindlyTo()->float(),
164  $this->refinery->always(0.0)
165  ])->transform($value);
166  } else {
167  throw new \ILIAS\Refinery\ConstraintViolationException(
168  sprintf('The value "%s" is no array or string.', var_export($value, true)),
169  'value_is_no_array_or_string',
170  var_export($value, true)
171  );
172  }
173 
174  return $value;
175  });
176 
177  $transform_finalization = $this->refinery->custom()->transformation(
178  function ($value) use (&$transform_finalization) {
179  if (is_array($value)) {
180  foreach ($value as $key => $val) {
181  $value[$key] = $transform_finalization->transform($val);
182  }
183  } elseif (is_string($value)) {
184  $value = $this->refinery->byTrying([
185  $this->refinery->kindlyTo()->bool(),
186  $this->refinery->always(false)
187  ])->transform($value);
188  } else {
189  throw new \ILIAS\Refinery\ConstraintViolationException(
190  sprintf('The value "%s" is no array or string.', var_export($value, true)),
191  'value_is_no_array_or_string',
192  var_export($value, true)
193  );
194  }
195 
196  return $value;
197  }
198  );
199 
200  $scoring = $this->http->wrapper()->post()->retrieve(
201  'scoring',
202  $this->refinery->byTrying([
203  $transform_scoring,
204  $this->refinery->always([])
205  ])
206  );
207  $finalization = $this->http->wrapper()->post()->retrieve(
208  'evaluated',
209  $this->refinery->byTrying([
210  $transform_finalization,
211  $this->refinery->always([])
212  ])
213  );
214 
215  $pass = key($scoring);
216  $active_data = current($scoring);
217  $active_ids = array_keys($active_data);
218 
219  if (!$this->testAccess->checkScoreParticipantsAccessForActiveId(current($active_ids))) {
220  if ($ajax) {
221  $this->http->saveResponse(
222  $this->http->response()->withBody(
223  \ILIAS\Filesystem\Stream\Streams::ofString($this->lng->txt('cannot_edit_test'))
224  )
225  );
226  $this->http->sendResponse();
227  $this->http->close();
228  }
229 
230  $this->tpl->setOnScreenMessage('info', $this->lng->txt('cannot_edit_test'), true);
231  $this->ctrl->redirectByClass('ilobjtestgui', 'infoScreen');
232  }
233 
234  if ($scoring === []) {
235  $this->tpl->setOnScreenMessage('failure', $this->lng->txt('tst_save_manscoring_failed_unknown'));
237  return;
238  }
239 
240  $participantData = new ilTestParticipantData($this->db, $this->lng);
241  $manPointsPost = [];
242  $maxPointsByQuestionId = [];
243 
244  $participantData->setActiveIdsFilter($active_ids);
246  $this->participant_access_filter->getScoreParticipantsUserFilter($this->ref_id)
247  );
248  $participantData->load($this->object->getTestId());
249 
250  $changed_one = false;
251  $lastAndHopefullyCurrentQuestionId = null;
252 
253  foreach ($participantData->getActiveIds() as $active_id) {
254  $questions = $active_data[$active_id];
255  if (!is_array($questions)) {
256  continue;
257  }
258 
259  // check for existing test result data
260  if (!$this->object->getTestResult($active_id, $pass)) {
261  continue;
262  }
263 
264  $update_participant = false;
265  $qst_id = null;
266 
267  foreach ($questions as $qst_id => $reached_points_string) {
268  $reached_points = $this->refinery->kindlyTo()->float()
269  ->transform($reached_points_string);
270  if (!isset($manPointsPost[$pass])) {
271  $manPointsPost[$pass] = [];
272  }
273  if (!isset($manPointsPost[$pass][$active_id])) {
274  $manPointsPost[$pass][$active_id] = [];
275  }
276 
277  $feedback_text = $this->retrieveFeedback($active_id, $qst_id, $pass);
278 
285  $current_feedback_info = ilObjTest::getSingleManualFeedback($active_id, $qst_id, $pass);
286  if (isset($current_feedback_info['finalized_evaluation']) && $current_feedback_info['finalized_evaluation'] === 1) {
287  $reached_points = assQuestion::_getReachedPoints($active_id, $qst_id, $pass);
288  $feedback_text = $current_feedback_info['feedback'];
289  }
290 
291  $maxPointsByQuestionId[$qst_id] = $this->questioninfo->getMaximumPoints($qst_id);
292  $manPointsPost[$pass][$active_id][$qst_id] = $reached_points;
293  if ($reached_points > $maxPointsByQuestionId[$qst_id]) {
294  $this->tpl->setOnScreenMessage(
295  'failure',
296  sprintf($this->lng->txt('tst_save_manscoring_failed'), $pass + 1),
297  false
298  );
299  $this->showManScoringByQuestionParticipantsTable($manPointsPost);
300  return;
301  }
302 
303  $this->saveFinalization(
304  $finalization,
305  (int) $active_id,
306  (int) $qst_id,
307  (int) $pass,
308  $feedback_text,
309  $ajax
310  );
311  // fix #35543: save manual points only if they differ from the existing points
312  // this prevents a question being set to "answered" if only feedback is entered
313  $old_points = assQuestion::_getReachedPoints($active_id, $qst_id, $pass);
314  if ($reached_points !== $old_points) {
315  $update_participant = assQuestion::_setReachedPoints(
316  $active_id,
317  $qst_id,
318  $reached_points,
319  $maxPointsByQuestionId[$qst_id],
320  $pass,
321  true,
322  $this->object->areObligationsEnabled(),
323  $this->getTestAccess()->getTestId()
324  );
325  }
326  }
327 
328  if ($update_participant) {
330  $this->object->getId(),
332  );
333  }
334 
335  $changed_one = true;
336  $lastAndHopefullyCurrentQuestionId = $qst_id;
337  }
338 
339  $correction_feedback = [];
340  $correction_points = 0;
341 
342  if ($changed_one) {
343  $qTitle = '';
344 
345  if ($lastAndHopefullyCurrentQuestionId) {
346  $question = assQuestion::instantiateQuestion($lastAndHopefullyCurrentQuestionId);
347  $qTitle = $question->getTitleForHTMLOutput();
348  }
349 
350  $msg = sprintf(
351  $this->lng->txt('tst_saved_manscoring_by_question_successfully'),
352  $qTitle,
353  $pass + 1
354  );
355 
356  $this->tpl->setOnScreenMessage('success', $msg, true);
357 
358  if (isset($active_id) && $lastAndHopefullyCurrentQuestionId) {
359  $correction_feedback = ilObjTest::getSingleManualFeedback(
360  $active_id,
361  $lastAndHopefullyCurrentQuestionId,
362  $pass
363  );
364  $correction_points = assQuestion::_getReachedPoints(
365  $active_id,
366  $lastAndHopefullyCurrentQuestionId,
367  $pass
368  );
369  }
370  }
371 
372  if ($ajax && is_array($correction_feedback)) {
373  $finalized_by_usr_id = $correction_feedback['finalized_by_usr_id'];
374  if (!$finalized_by_usr_id) {
375  $finalized_by_usr_id = $this->user->getId();
376  }
377  $correction_feedback['finalized_by'] = ilObjUser::_lookupFullname($finalized_by_usr_id);
378  $correction_feedback['finalized_on_date'] = '';
379 
380  if (is_int($correction_feedback['finalized_tstamp'])) {
381  $time = new ilDateTime($correction_feedback['finalized_tstamp'], IL_CAL_UNIX);
382  $correction_feedback['finalized_on_date'] = $time->get(IL_CAL_DATETIME);
383  }
384 
385  if (!$correction_feedback['feedback']) {
386  $correction_feedback['feedback'] = [];
387  }
388  if ($correction_feedback['finalized_evaluation'] == 1) {
389  $correction_feedback['finalized_evaluation'] = $this->lng->txt('yes');
390  } else {
391  $correction_feedback['finalized_evaluation'] = $this->lng->txt('no');
392  $correction_feedback['finalized_by'] = '';
393  }
394 
395  $this->http->saveResponse(
396  $this->http->response()->withBody(
397  \ILIAS\Filesystem\Stream\Streams::ofString(
398  json_encode(
399  [
400  'feedback' => $correction_feedback,
401  'points' => $correction_points,
402  "translation" => [
403  'yes' => $this->lng->txt('yes'),
404  'no' => $this->lng->txt('no')
405  ]
406  ],
407  JSON_THROW_ON_ERROR
408  )
409  )
410  )
411  );
412  $this->http->sendResponse();
413  $this->http->close();
414  }
415 
417  }
const IL_CAL_DATETIME
static _getParticipantId($active_id)
Get user id for active id.
static _lookupFullname(int $a_user_id)
Class ChatMainBarProvider .
const IL_CAL_UNIX
static instantiateQuestion(int $question_id)
static getSingleManualFeedback(int $active_id, int $question_id, int $pass)
setParticipantAccessFilter(Closure $participantAccessFilter)
static http()
Fetches the global http state from ILIAS.
setActiveIdsFilter(array $active_ids_filter)
static _getReachedPoints(int $active_id, int $question_id, int $pass)
string $key
Consumer key/client ID value.
Definition: System.php:193
ilTestParticipantData $participantData
showManScoringByQuestionParticipantsTable(array $manPointsPost=[])
static _setReachedPoints(int $active_id, int $question_id, float $points, float $maxpoints, int $pass, bool $manualscoring, bool $obligationsEnabled, ?int $test_id=null)
Sets the points, a learner has reached answering the question Additionally objective results are upda...
retrieveFeedback(int $active_id, int $qst_id, int $pass)
saveFinalization(array $finalization, int $active_id, int $qst_id, int $pass, ?string $feedback, bool $is_single_feedback)
static _updateStatus(int $a_obj_id, int $a_usr_id, ?object $a_obj=null, bool $a_percentage=false, bool $a_force_raise=false)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ showManScoringByQuestionParticipantsTable()

ilTestScoringByQuestionsGUI::showManScoringByQuestionParticipantsTable ( array  $manPointsPost = [])
protected
Parameters
array$manPointsPost

Definition at line 46 of file class.ilTestScoringByQuestionsGUI.php.

References $data, ilTestServiceGUI\$participantData, assQuestion\_getReachedPoints(), ILIAS\Repository\access(), ILIAS\Repository\ctrl(), ilTestParticipantData\getActiveIds(), iljQueryUtil\initjQuery(), ilYuiUtil\initOverlay(), ilYuiUtil\initPanel(), ILIAS\Repository\int(), ILIAS\Repository\lng(), ilTestParticipantData\load(), ILIAS\Repository\object(), ilTestParticipantData\setActiveIdsFilter(), ilTestParticipantData\setParticipantAccessFilter(), ilTestTabsManager\TAB_ID_MANUAL_SCORING, and ILIAS\Repository\tabs().

Referenced by applyManScoringByQuestionFilter(), resetManScoringByQuestionFilter(), and saveManScoringByQuestion().

46  : void
47  {
49 
50  if (!$this->testAccess->checkScoreParticipantsAccess()) {
51  $this->tpl->setOnScreenMessage('info', $this->lng->txt('cannot_edit_test'), true);
52  $this->ctrl->redirectByClass('ilobjtestgui', 'infoScreen');
53  }
54 
58 
59  $mathJaxSetting = new ilSetting('MathJax');
60 
61  if ($mathJaxSetting->get("enable")) {
62  $this->tpl->addJavaScript($mathJaxSetting->get("path_to_mathjax"));
63  }
64 
65  $this->tpl->addJavaScript("./Services/JavaScript/js/Basic.js");
66  $this->tpl->addJavaScript("./Services/Form/js/Form.js");
67  $this->tpl->addJavascript('./Services/UIComponent/Modal/js/Modal.js');
68  $this->lng->toJSMap(['answer' => $this->lng->txt('answer')]);
69 
71 
72  $qst_id = (int) $table->getFilterItemByPostVar('question')->getValue();
73  $passNr = $table->getFilterItemByPostVar('pass')->getValue();
74  $finalized_filter = $table->getFilterItemByPostVar('finalize_evaluation')->getValue();
75  $answered_filter = $table->getFilterItemByPostVar('only_answered')->getChecked();
76  $table_data = [];
77  $selected_questionData = null;
78  $complete_feedback = $this->object->getCompleteManualFeedback($qst_id);
79 
80  if (is_numeric($qst_id)) {
81  $info = $this->questioninfo->getQuestionInfo($qst_id);
82  $selected_questionData = $info;
83  }
84 
85  if ($selected_questionData && is_numeric($passNr)) {
86  $data = $this->object->getCompleteEvaluationData(false);
87  $participants = $data->getParticipants();
88  $participantData = new ilTestParticipantData($this->db, $this->lng);
89  $participantData->setActiveIdsFilter(array_keys($data->getParticipants()));
91  $this->participant_access_filter->getScoreParticipantsUserFilter($this->ref_id)
92  );
93  $participantData->load($this->object->getTestId());
94 
95  foreach ($participantData->getActiveIds() as $active_id) {
96  $participant = $participants[$active_id];
97  $testResultData = $this->object->getTestResult($active_id, $passNr - 1);
98 
99  foreach ($testResultData as $questionData) {
100  $feedback = [];
101  $is_answered = (bool) ($questionData['answered'] ?? false);
102  $finalized_evaluation = (bool) ($questionData['finalized_evaluation'] ?? false);
103 
104  if (isset($complete_feedback[$active_id][$passNr - 1][$qst_id])) {
105  $feedback = $complete_feedback[$active_id][$passNr - 1][$qst_id];
106  }
107 
108  if (!isset($questionData['qid'])
109  || $questionData['qid'] !== $selected_questionData['question_id']
110  || $finalized_filter === self::ONLY_FINALIZED && !$finalized_evaluation
111  || $finalized_filter === self::EXCEPT_FINALIZED && $finalized_evaluation
112  || $answered_filter === true && !$is_answered) {
113  continue;
114  }
115 
116  $table_data[] = [
117  'pass_id' => $passNr - 1,
118  'active_id' => $active_id,
119  'qst_id' => $questionData['qid'],
120  'reached_points' => assQuestion::_getReachedPoints(
121  $active_id,
122  (int) $questionData['qid'],
123  $passNr - 1
124  ),
125  'maximum_points' => $this->questioninfo->getMaximumPoints((int) $questionData['qid']),
126  'name' => $participant->getName()
127  ] + $feedback;
128  }
129  }
130  } else {
131  $table->disable('header');
132  }
133 
134  $table->setTitle($this->lng->txt('tst_man_scoring_by_qst'));
135 
136  if ($selected_questionData) {
137  $maxpoints = $this->questioninfo->getMaximumPoints((int) $selected_questionData['question_id']);
138  $table->setCurQuestionMaxPoints($maxpoints);
139  $maxpoints_txt = ' (' . $maxpoints . ' ' . $this->lng->txt('points') . ')';
140  if ($maxpoints == 1) {
141  $maxpoints_txt = ' (' . $maxpoints . ' ' . $this->lng->txt('point') . ')';
142  }
143 
144  $table->setTitle(
145  $this->lng->txt('tst_man_scoring_by_qst') . ': ' . $selected_questionData['title'] . $maxpoints_txt .
146  ' [' . $this->lng->txt('question_id_short') . ': ' . $selected_questionData['question_id'] . ']'
147  );
148  }
149 
150  $table->setData($table_data);
151  $this->tpl->setContent($table->getHTML());
152  }
setParticipantAccessFilter(Closure $participantAccessFilter)
setActiveIdsFilter(array $active_ids_filter)
static _getReachedPoints(int $active_id, int $question_id, int $pass)
ilTestParticipantData $participantData
static initjQuery(ilGlobalTemplateInterface $a_tpl=null)
inits and adds the jQuery JS-File to the global or a passed template
static initPanel(bool $a_resize=false, ?ilGlobalTemplateInterface $a_main_tpl=null)
Init yui panel used in Modules/Test, Services/TermsOfService (Jan 2022)
static initOverlay(?ilGlobalTemplateInterface $a_main_tpl=null)
Init YUI Overlay module used in Modules/Test, Services/TermsOfService, Services/Tracking, Services/UIComponent.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Field Documentation

◆ EXCEPT_FINALIZED

const ilTestScoringByQuestionsGUI::EXCEPT_FINALIZED = '1'

◆ ONLY_FINALIZED

const ilTestScoringByQuestionsGUI::ONLY_FINALIZED = '2'

The documentation for this class was generated from the following file: