ILIAS  release_7 Revision v7.30-3-g800a261c036
All Data Structures Namespaces Files Functions Variables Modules Pages
ilTestScoringByQuestionsGUI Class Reference

ilTestScoringByQuestionsGUI More...

+ Inheritance diagram for ilTestScoringByQuestionsGUI:
+ Collaboration diagram for ilTestScoringByQuestionsGUI:

Public Member Functions

 __construct (ilObjTest $a_object)
 
 checkConstraintsBeforeSaving ()
 
- Public Member Functions inherited from ilTestServiceGUI
 isContextResultPresentation ()
 
 setContextResultPresentation ($contextResultPresentation)
 
 __construct (ilObjTest $a_object)
 The constructor takes the test object reference as parameter. More...
 
 setParticipantData ($participantData)
 
 getParticipantData ()
 
 getPassOverviewTableData (ilTestSession $testSession, $passes, $withResults)
 
 setObjectiveOrientedContainer (ilTestObjectiveOrientedContainer $objectiveOrientedContainer)
 
 getObjectiveOrientedContainer ()
 
 executeCommand ()
 execute command More...
 
 getCommand ($cmd)
 Retrieves the ilCtrl command. More...
 
 buildPassOverviewTableGUI ($targetGUI)
 
 getPassListOfAnswers (&$result_array, $active_id, $pass, $show_solutions=false, $only_answered_questions=false, $show_question_only=false, $show_reached_points=false, $anchorNav=false, ilTestQuestionRelatedObjectivesList $objectivesList=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 $objectivesList=null)
 Returns an output of the solution to an answer compared to the correct solution. More...
 
 getResultsOfUserOutput ($testSession, $active_id, $pass, $targetGUI, $show_pass_details=true, $show_answers=true, $show_question_only=false, $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 ($question_id, $test_id)
 Creates a HTML representation for the results of a given question in a test. More...
 
 populatePassFinishDate ($tpl, $passFinishDate)
 
 populateExamId (ilTemplate $tpl, int $activeId, int $pass)
 
- Public Member Functions inherited from ilTestScoringGUI
 __construct (ilObjTest $a_object)
 ilTestScoringGUI constructor More...
 
 getTestAccess ()
 
 setTestAccess ($testAccess)
 
 executeCommand ()
 execute command More...
 

Data Fields

const ONLY_FINALIZED = 1
 
const EXCEPT_FINALIZED = 2
 
- Data Fields inherited from ilTestServiceGUI
 $object = null
 
 $service = null
 
 $lng
 
 $tpl
 
 $ctrl
 
 $ilias
 
 $tree
 
 $ref_id
 
- Data Fields inherited from ilTestScoringGUI
const PART_FILTER_ACTIVE_ONLY = 1
 
const PART_FILTER_INACTIVE_ONLY = 2
 
const PART_FILTER_ALL_USERS = 3
 
const PART_FILTER_MANSCORING_DONE = 4
 
const PART_FILTER_MANSCORING_NONE = 5
 

Protected Member Functions

 getDefaultCommand ()
 
 getActiveSubTabId ()
 
 showManScoringByQuestionParticipantsTable ($manPointsPost=array())
 
 saveManScoringByQuestion ($ajax=false)
 
 applyManScoringByQuestionFilter ()
 
 resetManScoringByQuestionFilter ()
 
 getAnswerDetail ()
 
 retrieveFeedback (int $active_id, int $qst_id, int $pass)
 
 saveFinalization ($active_id, $qst_id, $pass, $feedback, $is_single_feedback)
 
 doesValueExistsInPostArray ($post_value, $active_id, $qst_id, $pass)
 
- Protected Member Functions inherited from ilTestServiceGUI
 isPdfDeliveryRequest ()
 
 buildQuestionAnswerShuffler (string $question_id, string $active_id, string $active_pass)
 
 buildFixedShufflerSeedFromBasicSeed (string $basic_seed)
 
 getPassDetailsOverviewTableGUI ($result_array, $active_id, $pass, $targetGUI, $targetCMD, $questionDetailsCMD, $questionAnchorNav, ilTestQuestionRelatedObjectivesList $objectivesList=null, $multipleObjectivesInvolved=true)
 
 buildPassDetailsOverviewTableGUI ($targetGUI, $targetCMD)
 
 isGradingMessageRequired ()
 
 getGradingMessageBuilder ($activeId)
 
 buildQuestionRelatedObjectivesList (ilLOTestQuestionAdapter $objectivesAdapter, ilTestQuestionSequence $testSequence)
 
 getFilteredTestResult ($active_id, $pass, $considerHiddenQuestions, $considerOptionalQuestions)
 
 populateContent ($content)
 
 buildUserTestResultsToolbarGUI ()
 
 outCorrectSolutionCmd ()
 
 outCorrectSolution ()
 Creates an output of the solution of an answer compared to the correct solution. More...
 
- Protected Member Functions inherited from ilTestScoringGUI
 getDefaultCommand ()
 
 getActiveSubTabId ()
 

Private Member Functions

 appendUserNameToModal ($tmp_tpl, $participant)
 
 appendQuestionTitleToModal ($tmp_tpl, $question_id, $max_points, $title)
 
 appendFormToModal ($tmp_tpl, $pass, $active_id, $question_id, $max_points)
 
 appendSolutionAndPointsToModal ($tmp_tpl, $result_output, $reached_points, $max_points)
 

Additional Inherited Members

- Protected Attributes inherited from ilTestServiceGUI
const FIXED_SHUFFLER_SEED_MIN_LENGTH = 8
 
 $db
 
 $refinery
 
 $tabs
 
 $objCache
 
 $testSessionFactory = null
 
 $testSequenceFactory = null
 
 $participantData
 
- Protected Attributes inherited from ilTestScoringGUI
 $testAccess
 

Detailed Description

Constructor & Destructor Documentation

◆ __construct()

ilTestScoringByQuestionsGUI::__construct ( ilObjTest  $a_object)
Parameters
ilObjTest$a_object

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

References ILIAS\GlobalScreen\Provider\__construct().

24  {
25  parent::__construct($a_object);
26  }
__construct(Container $dic, ilPlugin $plugin)
+ Here is the call graph for this function:

Member Function Documentation

◆ appendFormToModal()

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

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

References $DIC, $pass, ilCharSelectorGUI\_getCurrentGUI(), assQuestion\_getReachedPoints(), ilObjAdvancedEditing\_getRichTextEditor(), ilNumberInputGUI\allowDecimals(), ilCharSelectorConfig\DISABLED, ilCheckboxInputGUI\setChecked(), and ilTextAreaInputGUI\setValue().

Referenced by getAnswerDetail().

501  {
502  global $DIC;
503 
504  $ilCtrl = $DIC->ctrl();
505  $post_var = '[' . $pass . '][' . $active_id . '][' . $question_id . ']';
506  $scoring_post_var = 'scoring' . $post_var;
507  $reached_points = assQuestion::_getReachedPoints($active_id, $question_id, $pass);
508  $form = new ilPropertyFormGUI();
509  $feedback = $this->object->getSingleManualFeedback($active_id, $question_id, $pass);
510  $disable = false;
511  $form->setFormAction($ilCtrl->getFormAction($this, 'showManScoringByQuestionParticipantsTable'));
512  $form->setTitle($this->lng->txt('manscoring'));
513 
514  if (isset($feedback['finalized_evaluation']) && $feedback['finalized_evaluation'] == 1) {
515  $disable = true;
516  $hidden_points = new ilHiddenInputGUI($scoring_post_var);
517  $scoring_post_var = $scoring_post_var . '_disabled';
518  $hidden_points->setValue($reached_points);
519  $form->addItem($hidden_points);
520  }
521 
522  $feedback_text = '';
523  if (array_key_exists('feedback', $feedback)) {
524  $feedback_text = $feedback['feedback'];
525  }
526 
527  if ($disable) {
528  $feedback_input = new ilNonEditableValueGUI($this->lng->txt('set_manual_feedback'), 'm_feedback' . $post_var, true);
529  } else {
530  $tmp_tpl->setVariable('TINYMCE_ACTIVE', ilObjAdvancedEditing::_getRichTextEditor());
531  $feedback_input = new ilTextAreaInputGUI($this->lng->txt('set_manual_feedback'), 'm_feedback' . $post_var);
532  }
533  $feedback_input->setValue($feedback_text);
534  $form->addItem($feedback_input);
535 
536  $reached_points_form = new ilNumberInputGUI($this->lng->txt('tst_change_points_for_question'), $scoring_post_var);
537  $reached_points_form->allowDecimals(true);
538  $reached_points_form->setSize(5);
539  $reached_points_form->setMaxValue($max_points, true);
540  $reached_points_form->setMinValue(0);
541  $reached_points_form->setDisabled($disable);
542  $reached_points_form->setValue($reached_points);
543  $reached_points_form->setClientSideValidation(true);
544  $form->addItem($reached_points_form);
545 
546  $hidden_points = new ilHiddenInputGUI('qst_max_points');
547  $hidden_points->setValue($max_points);
548  $form->addItem($hidden_points);
549 
550  $hidden_points_name = new ilHiddenInputGUI('qst_hidden_points_name');
551  $hidden_points_name->setValue('scoring' . $post_var);
552  $form->addItem($hidden_points_name);
553 
554  $hidden_feedback_name = new ilHiddenInputGUI('qst_hidden_feedback_name');
555  $hidden_feedback_name->setValue('m_feedback' . $post_var);
556  $form->addItem($hidden_feedback_name);
557 
558  $hidden_feedback_id = new ilHiddenInputGUI('qst_hidden_feedback_id');
559  $post_id = '__' . $pass . '____' . $active_id . '____' . $question_id . '__';
560  $hidden_feedback_id->setValue('m_feedback' . $post_id);
561  $form->addItem($hidden_feedback_id);
562 
563  $evaluated = new ilCheckboxInputGUI($this->lng->txt('finalized_evaluation'), 'evaluated' . $post_var);
564  if (isset($feedback['finalized_evaluation']) && $feedback['finalized_evaluation'] == 1) {
565  $evaluated->setChecked(true);
566  }
567  $form->addItem($evaluated);
568 
569  $form->addCommandButton('checkConstraintsBeforeSaving', $this->lng->txt('save'));
570  $CharSelector = ilCharSelectorGUI::_getCurrentGUI();
571  $CharSelector->getConfig()->setAvailability(ilCharSelectorConfig::DISABLED);
572 
573  $tmp_tpl->setVariable(
574  'MANUAL_FEEDBACK',
575  $form->getHTML()
576  );
577  $tmp_tpl->setVariable(
578  'MODAL_AJAX_URL',
579  $this->ctrl->getLinkTarget($this, 'checkConstraintsBeforeSaving', '', true, false)
580  );
581  $tmp_tpl->setVariable(
582  'INFO_TEXT_MAX_POINTS_EXCEEDS',
583  sprintf($this->lng->txt('tst_manscoring_maxpoints_exceeded_input_alert'), $max_points)
584  );
585  }
static _getRichTextEditor()
Returns the identifier for the Rich Text Editor.
This class represents a property form user interface.
setValue($a_value)
Set Value.
This class represents a checkbox property in a property form.
allowDecimals($a_value)
Toggle Decimals.
setChecked($a_checked)
Set Checked.
This class represents a hidden form property in a property form.
This class represents a number property in a property form.
global $DIC
Definition: goto.php:24
static _getCurrentGUI(ilObjTest $a_test_obj=null)
Get the GUI that is used for the currently available selector (other GUI instances may exist for conf...
This class represents a non editable value in a property form.
This class represents a text area property in a property form.
static _getReachedPoints($active_id, $question_id, $pass=null)
Returns the points, a learner has reached answering the question.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ appendQuestionTitleToModal()

ilTestScoringByQuestionsGUI::appendQuestionTitleToModal (   $tmp_tpl,
  $question_id,
  $max_points,
  $title 
)
private
Parameters
ilTemplate$tmp_tpl
$question_id
$max_points
$title

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

References ilTestServiceGUI\$lng.

Referenced by getAnswerDetail().

479  {
480  $add_title = ' [' . $this->lng->txt('question_id_short') . ': ' . $question_id . ']';
481  $question_title = $this->object->getQuestionTitle($title);
482  $lng = $this->lng->txt('points');
483  if ($max_points == 1) {
484  $lng = $this->lng->txt('point');
485  }
486 
487  $tmp_tpl->setVariable(
488  'QUESTION_TITLE',
489  $question_title . ' (' . $max_points . ' ' . $lng . ')' . $add_title
490  );
491  }
+ Here is the caller graph for this function:

◆ appendSolutionAndPointsToModal()

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

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

Referenced by getAnswerDetail().

594  {
595  $tmp_tpl->setVariable(
596  'SOLUTION_OUTPUT',
597  $result_output
598  );
599  $tmp_tpl->setVariable(
600  'RECEIVED_POINTS',
601  sprintf(
602  $this->lng->txt('part_received_a_of_b_points'),
603  $reached_points,
604  $max_points
605  )
606  );
607  }
+ Here is the caller graph for this function:

◆ appendUserNameToModal()

ilTestScoringByQuestionsGUI::appendUserNameToModal (   $tmp_tpl,
  $participant 
)
private
Parameters
ilTemplate$tmp_tpl
$participant

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

References $DIC.

Referenced by getAnswerDetail().

452  {
453  global $DIC;
454  $ilAccess = $DIC->access();
455 
456  $tmp_tpl->setVariable(
457  'TEXT_YOUR_SOLUTION',
458  $this->lng->txt('answers_of') . ' ' . $participant->getName()
459  );
460 
461  if (
462  $this->object->anonymity == 1 ||
463  ($this->object->getAnonymity() == 2 && !$ilAccess->checkAccess('write', '', $this->object->getRefId()))
464  ) {
465  $tmp_tpl->setVariable(
466  'TEXT_YOUR_SOLUTION',
467  $this->lng->txt('answers_of') . ' ' . $this->lng->txt('anonymous')
468  );
469  }
470  }
global $DIC
Definition: goto.php:24
+ Here is the caller graph for this function:

◆ applyManScoringByQuestionFilter()

ilTestScoringByQuestionsGUI::applyManScoringByQuestionFilter ( )
protected

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

References showManScoringByQuestionParticipantsTable().

344  {
346  $table->resetOffset();
347  $table->writeFilterToSession();
349  }
showManScoringByQuestionParticipantsTable($manPointsPost=array())
+ Here is the call graph for this function:

◆ checkConstraintsBeforeSaving()

ilTestScoringByQuestionsGUI::checkConstraintsBeforeSaving ( )

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

References saveManScoringByQuestion().

443  {
444  $this->saveManScoringByQuestion(true);
445  }
+ Here is the call graph for this function:

◆ doesValueExistsInPostArray()

ilTestScoringByQuestionsGUI::doesValueExistsInPostArray (   $post_value,
  $active_id,
  $qst_id,
  $pass 
)
protected
Parameters
$post_value
$active_id
$qst_id
$pass
Returns
bool

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

References $_POST, and $pass.

Referenced by saveFinalization().

652  {
653  return (
654  isset($_POST[$post_value][$pass][$active_id][$qst_id]) &&
655  strlen($_POST[$post_value][$pass][$active_id][$qst_id]) > 0
656  );
657  }
$_POST["username"]
+ Here is the caller graph for this function:

◆ getActiveSubTabId()

ilTestScoringByQuestionsGUI::getActiveSubTabId ( )
protected
Returns
string

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

40  {
41  return 'man_scoring_by_qst';
42  }

◆ getAnswerDetail()

ilTestScoringByQuestionsGUI::getAnswerDetail ( )
protected

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

References $_GET, $data, ilTestServiceGUI\$lng, $pass, assQuestion\_getSuggestedSolutionOutput(), appendFormToModal(), appendQuestionTitleToModal(), appendSolutionAndPointsToModal(), appendUserNameToModal(), exit, and ilTestScoringGUI\getTestAccess().

363  {
364  $active_id = (int) $_GET['active_id'];
365  $pass = (int) $_GET['pass_id'];
366  $question_id = (int) $_GET['qst_id'];
367 
368  if (!$this->getTestAccess()->checkScoreParticipantsAccessForActiveId($active_id)) {
369  exit; // illegal ajax call
370  }
371 
372  $data = $this->object->getCompleteEvaluationData(false);
373  $participant = $data->getParticipant($active_id);
374  $question_gui = $this->object->createQuestionGUI('', $question_id);
375  $tmp_tpl = new ilTemplate('tpl.il_as_tst_correct_solution_output.html', true, true, 'Modules/Test');
376  if ($question_gui->supportsIntermediateSolutionOutput() && $question_gui->hasIntermediateSolution($active_id, $pass)) {
377  $question_gui->setUseIntermediateSolution(true);
378  $aresult_output = $question_gui->getSolutionOutput($active_id, $pass, false, false, true, false, false, true);
379  $question_gui->setUseIntermediateSolution(false);
380  $tmp_tpl->setVariable('TEXT_ASOLUTION_OUTPUT', $this->lng->txt('autosavecontent'));
381  $tmp_tpl->setVariable('ASOLUTION_OUTPUT', $aresult_output);
382  }
383  $result_output = $question_gui->getSolutionOutput(
384  $active_id,
385  $pass,
386  false,
387  false,
388  false,
389  $this->object->getShowSolutionFeedback(),
390  false,
391  true
392  );
393  $max_points = $question_gui->object->getMaximumPoints();
394 
395  $this->appendUserNameToModal($tmp_tpl, $participant);
396  $this->appendQuestionTitleToModal($tmp_tpl, $question_id, $max_points, $question_gui->object->getTitle());
398  $tmp_tpl,
399  $result_output,
400  $question_gui->object->getReachedPoints($active_id, $pass),
401  $max_points
402  );
403  $this->appendFormToModal($tmp_tpl, $pass, $active_id, $question_id, $max_points);
404  $tmp_tpl->setVariable('TEXT_YOUR_SOLUTION', $this->lng->txt('answers_of') . ' ' . $participant->getName());
405  $suggested_solution = assQuestion::_getSuggestedSolutionOutput($question_id);
406  if ($this->object->getShowSolutionSuggested() && strlen($suggested_solution) > 0) {
407  $tmp_tpl->setVariable('TEXT_SOLUTION_HINT', $this->lng->txt("solution_hint"));
408  $tmp_tpl->setVariable("SOLUTION_HINT", assQuestion::_getSuggestedSolutionOutput($question_id));
409  }
410 
411  $tmp_tpl->setVariable('TEXT_SOLUTION_OUTPUT', $this->lng->txt('question'));
412  $tmp_tpl->setVariable('TEXT_RECEIVED_POINTS', $this->lng->txt('scoring'));
413  $add_title = ' [' . $this->lng->txt('question_id_short') . ': ' . $question_id . ']';
414  $question_title = $this->object->getQuestionTitle($question_gui->object->getTitle());
415  $lng = $this->lng->txt('points');
416  if ($max_points == 1) {
417  $lng = $this->lng->txt('point');
418  }
419 
420  $tmp_tpl->setVariable(
421  'QUESTION_TITLE',
422  $question_title . ' (' . $max_points . ' ' . $lng . ')' . $add_title
423  );
424  $tmp_tpl->setVariable('SOLUTION_OUTPUT', $result_output);
425 
426  $tmp_tpl->setVariable(
427  'RECEIVED_POINTS',
428  sprintf(
429  $this->lng->txt('part_received_a_of_b_points'),
430  $question_gui->object->getReachedPoints($active_id, $pass),
431  $max_points
432  )
433  );
434 
435  echo $tmp_tpl->get();
436  exit();
437  }
exit
Definition: login.php:29
$data
Definition: storeScorm.php:23
$_GET["client_id"]
appendFormToModal($tmp_tpl, $pass, $active_id, $question_id, $max_points)
appendSolutionAndPointsToModal($tmp_tpl, $result_output, $reached_points, $max_points)
appendQuestionTitleToModal($tmp_tpl, $question_id, $max_points, $title)
static _getSuggestedSolutionOutput($question_id)
Returns the output of the suggested solution.
+ Here is the call graph for this function:

◆ getDefaultCommand()

ilTestScoringByQuestionsGUI::getDefaultCommand ( )
protected
Returns
string

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

32  {
33  return 'showManScoringByQuestionParticipantsTable';
34  }

◆ resetManScoringByQuestionFilter()

ilTestScoringByQuestionsGUI::resetManScoringByQuestionFilter ( )
protected

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

References showManScoringByQuestionParticipantsTable().

355  {
357  $table->resetOffset();
358  $table->resetFilter();
360  }
showManScoringByQuestionParticipantsTable($manPointsPost=array())
+ Here is the call graph for this function:

◆ retrieveFeedback()

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

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

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

Referenced by saveManScoringByQuestion().

609  : ?string
610  {
611  $feedback = $_POST['feedback'];
612  if ($feedback === null || $feedback === '') {
613  $feedback = $_POST['m_feedback'];
614  }
615 
616  if ($feedback === null || $feedback === '') {
617  return null;
618  }
619 
620  return ilUtil::stripSlashes(
621  $feedback[$pass][$active_id][$qst_id],
622  false,
624  );
625  }
static _getUsedHTMLTagsAsString($a_module="")
Returns a string of all allowed HTML tags for text editing.
static stripSlashes($a_str, $a_strip_html=true, $a_allow="")
strip slashes if magic qoutes is enabled
$_POST["username"]
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ saveFinalization()

ilTestScoringByQuestionsGUI::saveFinalization (   $active_id,
  $qst_id,
  $pass,
  $feedback,
  $is_single_feedback 
)
protected
Parameters
$active_id
$qst_id
$pass
$feedback

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

References $_POST, $pass, and doesValueExistsInPostArray().

Referenced by saveManScoringByQuestion().

634  {
635  $evaluated = false;
636  if ($this->doesValueExistsInPostArray('evaluated', $active_id, $qst_id, $pass)) {
637  $evaluated = (int) $_POST['evaluated'][$pass][$active_id][$qst_id];
638  if ($evaluated === 1) {
639  $evaluated = true;
640  }
641  }
642  $this->object->saveManualFeedback($active_id, $qst_id, $pass, $feedback, $evaluated, $is_single_feedback);
643  }
doesValueExistsInPostArray($post_value, $active_id, $qst_id, $pass)
$_POST["username"]
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ saveManScoringByQuestion()

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

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 170 of file class.ilTestScoringByQuestionsGUI.php.

References $_POST, $DIC, ilTestServiceGUI\$participantData, $pass, assQuestion\_getMaximumPoints(), ilObjTestAccess\_getParticipantId(), assQuestion\_getReachedPoints(), assQuestion\_instantiateQuestion(), ilObjUser\_lookupFullname(), assQuestion\_setReachedPoints(), ilLPStatusWrapper\_updateStatus(), exit, ilTestParticipantAccessFilter\getScoreParticipantsUserFilter(), ilObjTest\getSingleManualFeedback(), IL_CAL_DATETIME, IL_CAL_UNIX, retrieveFeedback(), saveFinalization(), ilUtil\sendFailure(), ilUtil\sendInfo(), and showManScoringByQuestionParticipantsTable().

Referenced by checkConstraintsBeforeSaving().

171  {
172  global $DIC;
173  $ilAccess = $DIC->access();
174 
175  if (
176  false == $ilAccess->checkAccess("write", "", $this->ref_id) &&
177  false == $ilAccess->checkAccess("man_scoring_access", "", $this->ref_id)
178  ) {
179  if ($ajax) {
180  echo $this->lng->txt('cannot_edit_test');
181  exit();
182  }
183 
184  ilUtil::sendInfo($this->lng->txt('cannot_edit_test'), true);
185  $this->ctrl->redirectByClass('ilobjtestgui', 'infoScreen');
186  }
187 
188  if (false == isset($_POST['scoring']) || false == is_array($_POST['scoring'])) {
189  ilUtil::sendFailure($this->lng->txt('tst_save_manscoring_failed_unknown'));
191  return;
192  }
193 
194  $pass = key($_POST['scoring']);
195  $activeData = current($_POST['scoring']);
196  $participantData = new ilTestParticipantData($DIC->database(), $DIC->language());
197  $manPointsPost = [];
198  $skipParticipant = [];
199  $maxPointsByQuestionId = [];
200 
201  $participantData->setActiveIdsFilter(array_keys($activeData));
202  $participantData->setParticipantAccessFilter(
204  );
205  $participantData->load($this->object->getTestId());
206 
207  foreach ($participantData->getActiveIds() as $active_id) {
208  $questions = $activeData[$active_id];
209 
210  // check for existing test result data
211  if (!$this->object->getTestResult($active_id, $pass)) {
212  if (false == isset($skipParticipant[$pass])) {
213  $skipParticipant[$pass] = [];
214  }
215  $skipParticipant[$pass][$active_id] = true;
216 
217  continue;
218  }
219 
220  foreach ((array) $questions as $qst_id => $reached_points) {
221  if (false == isset($manPointsPost[$pass])) {
222  $manPointsPost[$pass] = [];
223  }
224  if (false == isset($manPointsPost[$pass][$active_id])) {
225  $manPointsPost[$pass][$active_id] = [];
226  }
227 
228  $feedback_text = $this->retrieveFeedback($active_id, $qst_id, $pass);
229 
236  $current_feedback_info = ilObjTest::getSingleManualFeedback($active_id, $qst_id, $pass);
237  if (isset($current_feedback_info['finalized_evaluation']) && $current_feedback_info['finalized_evaluation'] === 1) {
238  $reached_points = assQuestion::_getReachedPoints($active_id, $qst_id, $pass);
239  $feedback_text = $current_feedback_info['feedback'];
240  }
241 
242  $maxPointsByQuestionId[$qst_id] = assQuestion::_getMaximumPoints($qst_id);
243  $manPointsPost[$pass][$active_id][$qst_id] = $reached_points;
244 
245  if ($reached_points > $maxPointsByQuestionId[$qst_id]) {
246  ilUtil::sendFailure(sprintf($this->lng->txt('tst_save_manscoring_failed'), $pass + 1));
247  $this->showManScoringByQuestionParticipantsTable($manPointsPost);
248  return;
249  }
250  }
251  }
252 
253  $changed_one = false;
254  $lastAndHopefullyCurrentQuestionId = null;
255 
256  foreach ($participantData->getActiveIds() as $active_id) {
257  $questions = $activeData[$active_id];
258  $update_participant = false;
259 
260  if (false == $skipParticipant[$pass][$active_id]) {
261  foreach ((array) $questions as $qst_id => $reached_points) {
262  $this->saveFinalization((int) $active_id, (int) $qst_id, (int) $pass, $feedback_text, $ajax);
263  // fix #35543: save manual points only if they differ from the existing points
264  // this prevents a question being set to "answered" if only feedback is entered
265  $old_points = assQuestion::_getReachedPoints($active_id, $qst_id, $pass);
266  if ($reached_points != $old_points) {
267  $update_participant = assQuestion::_setReachedPoints(
268  $active_id,
269  $qst_id,
270  $reached_points,
271  $maxPointsByQuestionId[$qst_id],
272  $pass,
273  1,
274  $this->object->areObligationsEnabled()
275  );
276  }
277  }
278 
279  if ($update_participant) {
281  $this->object->getId(),
283  );
284  }
285 
286  $changed_one = true;
287  $lastAndHopefullyCurrentQuestionId = $qst_id;
288  }
289  }
290 
291  $correction_feedback = [];
292  $correction_points = 0;
293 
294  if ($changed_one) {
295  $qTitle = '';
296 
297  if ($lastAndHopefullyCurrentQuestionId) {
298  $question = assQuestion::_instantiateQuestion($lastAndHopefullyCurrentQuestionId);
299  $qTitle = $question->getTitle();
300  }
301 
302  $msg = sprintf(
303  $this->lng->txt('tst_saved_manscoring_by_question_successfully'),
304  $qTitle,
305  $pass + 1
306  );
307 
308  ilUtil::sendSuccess($msg, true);
309 
310  if (isset($active_id)) {
311  $correction_feedback = $this->object->getSingleManualFeedback($active_id, $qst_id, $pass);
312  $correction_points = assQuestion::_getReachedPoints($active_id, $qst_id, $pass);
313  }
314  }
315 
316  if ($ajax && is_array($correction_feedback)) {
317  $correction_feedback['finalized_by'] = ilObjUser::_lookupFullname($correction_feedback['finalized_by_usr_id']);
318  $correction_feedback['finalized_on_date'] = '';
319 
320  if (strlen($correction_feedback['finalized_tstamp']) > 0) {
321  $time = new ilDateTime($correction_feedback['finalized_tstamp'], IL_CAL_UNIX);
322  $correction_feedback['finalized_on_date'] = $time->get(IL_CAL_DATETIME);
323  }
324 
325  if (!$correction_feedback['feedback']) {
326  $correction_feedback['feedback'] = [];
327  }
328  if ($correction_feedback['finalized_evaluation'] == 1) {
329  $correction_feedback['finalized_evaluation'] = $this->lng->txt('yes');
330  } else {
331  $correction_feedback['finalized_evaluation'] = $this->lng->txt('no');
332  }
333  echo json_encode([ 'feedback' => $correction_feedback, 'points' => $correction_points, "translation" => ['yes' => $this->lng->txt('yes'), 'no' => $this->lng->txt('no')]]);
334  exit();
335  } else {
337  }
338  }
showManScoringByQuestionParticipantsTable($manPointsPost=array())
exit
Definition: login.php:29
const IL_CAL_DATETIME
static _getParticipantId($active_id)
Get user id for active id.
static _lookupFullname($a_user_id)
Lookup Full Name.
static _updateStatus($a_obj_id, $a_usr_id, $a_obj=null, $a_percentage=false, $a_force_raise=false)
Update status.
const IL_CAL_UNIX
static _getMaximumPoints($question_id)
Returns the maximum points, a learner can reach answering the question.
static sendInfo($a_info="", $a_keep=false)
Send Info Message to Screen.
global $DIC
Definition: goto.php:24
static _instantiateQuestion($question_id)
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
saveFinalization($active_id, $qst_id, $pass, $feedback, $is_single_feedback)
static _getReachedPoints($active_id, $question_id, $pass=null)
Returns the points, a learner has reached answering the question.
retrieveFeedback(int $active_id, int $qst_id, int $pass)
$_POST["username"]
static _setReachedPoints($active_id, $question_id, $points, $maxpoints, $pass, $manualscoring, $obligationsEnabled)
Sets the points, a learner has reached answering the question Additionally objective results are upda...
static getSingleManualFeedback($active_id, $question_id, $pass)
Retrieves the manual feedback for a question in a test.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ showManScoringByQuestionParticipantsTable()

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

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

References $data, $DIC, $mathJaxSetting, ilTestServiceGUI\$participantData, ilTestServiceGUI\$tpl, assQuestion\_getMaximumPoints(), assQuestion\_getQuestionInfo(), assQuestion\_getReachedPoints(), ilTestParticipantAccessFilter\getScoreParticipantsUserFilter(), iljQueryUtil\initjQuery(), ilYuiUtil\initOverlay(), ilYuiUtil\initPanel(), ilUtil\sendInfo(), and ilTestTabsManager\TAB_ID_MANUAL_SCORING.

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

48  {
49  global $DIC;
50 
51  $tpl = $DIC->ui()->mainTemplate();
52  $ilAccess = $DIC->access();
53 
54  $DIC->tabs()->activateTab(ilTestTabsManager::TAB_ID_MANUAL_SCORING);
55 
56  if (
57  false == $ilAccess->checkAccess("write", "", $this->ref_id) &&
58  false == $ilAccess->checkAccess("man_scoring_access", "", $this->ref_id)
59  ) {
60  ilUtil::sendInfo($this->lng->txt('cannot_edit_test'), true);
61  $this->ctrl->redirectByClass('ilobjtestgui', 'infoScreen');
62  }
63 
67 
68  $mathJaxSetting = new ilSetting('MathJax');
69 
70  if ($mathJaxSetting->get("enable")) {
71  $tpl->addJavaScript($mathJaxSetting->get("path_to_mathjax"));
72  }
73 
74  $tpl->addJavaScript("./Services/JavaScript/js/Basic.js");
75  $tpl->addJavaScript("./Services/Form/js/Form.js");
76  $tpl->addJavascript('./Services/UIComponent/Modal/js/Modal.js');
77  $this->lng->toJSMap(['answer' => $this->lng->txt('answer')]);
78 
80  $table->setManualScoringPointsPostData($manPointsPost);
81 
82  $qst_id = $table->getFilterItemByPostVar('question')->getValue();
83  $passNr = $table->getFilterItemByPostVar('pass')->getValue();
84  $finalized_filter = $table->getFilterItemByPostVar('finalize_evaluation')->getValue();
85  $answered_filter = $table->getFilterItemByPostVar('only_answered')->getChecked();
86  $table_data = [];
87  $selected_questionData = null;
88  $complete_feedback = $this->object->getCompleteManualFeedback($qst_id);
89 
90  if (is_numeric($qst_id)) {
91  $info = assQuestion::_getQuestionInfo($qst_id);
92  $selected_questionData = $info;
93  }
94 
95  if ($selected_questionData && is_numeric($passNr)) {
96  $data = $this->object->getCompleteEvaluationData(false);
97  $participants = $data->getParticipants();
98  $participantData = new ilTestParticipantData($DIC->database(), $DIC->language());
99  $participantData->setActiveIdsFilter(array_keys($data->getParticipants()));
100  $participantData->setParticipantAccessFilter(
102  );
103  $participantData->load($this->object->getTestId());
104 
105  foreach ($participantData->getActiveIds() as $active_id) {
106  $participant = $participants[$active_id];
107  $testResultData = $this->object->getTestResult($active_id, $passNr - 1);
108 
109  foreach ($testResultData as $questionData) {
110  $feedback = [];
111 
112  if (isset($complete_feedback[$active_id][$passNr - 1][$qst_id])) {
113  $feedback = $complete_feedback[$active_id][$passNr - 1][$qst_id];
114  }
115 
116  if (false == isset($feedback['finalized_evaluation'])) {
117  $feedback['finalized_evaluation'] = "";
118  }
119 
120  $check_filter =
121  ($finalized_filter != self::ONLY_FINALIZED || $feedback['finalized_evaluation'] == 1) &&
122  ($finalized_filter != self::EXCEPT_FINALIZED || $feedback['finalized_evaluation'] != 1);
123 
124  $check_answered = ($answered_filter == false || $questionData['answered']);
125 
126  if (
127  isset($questionData['qid']) &&
128  $questionData['qid'] == $selected_questionData['question_id'] &&
129  $check_filter &&
130  $check_answered
131  ) {
132  $table_data[] = [
133  'pass_id' => $passNr - 1,
134  'active_id' => $active_id,
135  'qst_id' => $questionData['qid'],
136  'reached_points' => assQuestion::_getReachedPoints($active_id, $questionData['qid'], $passNr - 1),
137  'maximum_points' => assQuestion::_getMaximumPoints($questionData['qid']),
138  'name' => $participant->getName()
139  ] + $feedback;
140  }
141  }
142  }
143  } else {
144  $table->disable('header');
145  }
146 
147  $table->setTitle($this->lng->txt('tst_man_scoring_by_qst'));
148 
149  if ($selected_questionData) {
150  $maxpoints = assQuestion::_getMaximumPoints($selected_questionData['question_id']);
151  $table->setCurQuestionMaxPoints($maxpoints);
152  $maxpoints = ' (' . $maxpoints . ' ' . $this->lng->txt('points') . ')';
153  if ($maxpoints == 1) {
154  $maxpoints = ' (' . $maxpoints . ' ' . $this->lng->txt('point') . ')';
155  }
156 
157  $table->setTitle(
158  $this->lng->txt('tst_man_scoring_by_qst') . ': ' . $selected_questionData['title'] . $maxpoints .
159  ' [' . $this->lng->txt('question_id_short') . ': ' . $selected_questionData['question_id'] . ']'
160  );
161  }
162 
163  $table->setData($table_data);
164  $tpl->setContent($table->getHTML());
165  }
$data
Definition: storeScorm.php:23
if(strpos($jquery_path, './')===0) elseif(strpos($jquery_path, '.')===0) $mathJaxSetting
Definition: latex.php:54
static initPanel($a_resize=false, ilGlobalTemplateInterface $a_main_tpl=null)
Init yui panel.
static _getMaximumPoints($question_id)
Returns the maximum points, a learner can reach answering the question.
static _getQuestionInfo($question_id)
Returns question information from the database.
static sendInfo($a_info="", $a_keep=false)
Send Info Message to Screen.
global $DIC
Definition: goto.php:24
static initOverlay(ilGlobalTemplateInterface $a_main_tpl=null)
Init YUI Overlay module.
static initjQuery(ilGlobalTemplateInterface $a_tpl=null)
inits and adds the jQuery JS-File to the global or a passed template
static _getReachedPoints($active_id, $question_id, $pass=null)
Returns the points, a learner has reached answering the question.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Field Documentation

◆ EXCEPT_FINALIZED

const ilTestScoringByQuestionsGUI::EXCEPT_FINALIZED = 2

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

◆ ONLY_FINALIZED

const ilTestScoringByQuestionsGUI::ONLY_FINALIZED = 1

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


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