From 81697781d5890b79e66e5111852a329cca174e1a Mon Sep 17 00:00:00 2001 From: Nils Haagen Date: Thu, 28 Nov 2024 12:33:24 +0100 Subject: [PATCH] TA: 37918, numeric question --- .../classes/class.assClozeTestGUI.php | 22 +++---- .../classes/class.assErrorTextGUI.php | 2 +- .../classes/class.assFormulaQuestionGUI.php | 66 +++++++++---------- .../classes/class.assImagemapQuestionGUI.php | 12 ++-- .../classes/class.assKprimChoiceGUI.php | 2 - .../classes/class.assLongMenuGUI.php | 24 +------ .../classes/class.assMatchingQuestionGUI.php | 6 +- .../classes/class.assMultipleChoiceGUI.php | 6 +- .../classes/class.assNumericGUI.php | 62 +++++++++++++---- .../class.assOrderingHorizontalGUI.php | 6 +- .../classes/class.assOrderingQuestionGUI.php | 20 +++--- .../classes/class.assSingleChoiceGUI.php | 4 +- .../classes/class.assTextQuestionGUI.php | 4 +- .../classes/class.assTextSubsetGUI.php | 8 +-- 14 files changed, 127 insertions(+), 117 deletions(-) diff --git a/Modules/TestQuestionPool/classes/class.assClozeTestGUI.php b/Modules/TestQuestionPool/classes/class.assClozeTestGUI.php index b6b3be0aa6c9..9cc3d3fb4002 100755 --- a/Modules/TestQuestionPool/classes/class.assClozeTestGUI.php +++ b/Modules/TestQuestionPool/classes/class.assClozeTestGUI.php @@ -1007,7 +1007,7 @@ public function renderSolutionOutput( $gaptemplate = new ilTemplate("tpl.il_as_qpl_cloze_question_output_solution_gap.html", true, true, "Modules/TestQuestionPool"); $found = []; foreach ($user_solutions as $solutionarray) { - if ($solutionarray["value1"] == $gap_index) { + if ($solutionarray['value1'] == $gap_index) { $found = $solutionarray; } } @@ -1083,12 +1083,12 @@ public function renderSolutionOutput( case CLOZE_TEXT: $solutiontext = ""; if (($active_id > 0) && (!$show_correct_solution)) { - if ((count($found) == 0) || (strlen(trim($found["value2"])) == 0)) { + if ((count($found) == 0) || (strlen(trim($found['value2'])) == 0)) { for ($chars = 0; $chars < $gap->getMaxWidth(); $chars++) { $solutiontext .= " "; } } else { - $solutiontext = ilLegacyFormElementsUtil::prepareFormOutput($found["value2"]); + $solutiontext = ilLegacyFormElementsUtil::prepareFormOutput($found['value2']); } } else { $solutiontext = $this-> getBestSolutionText($gap, $gap_index, $check_for_gap_combinations); @@ -1101,12 +1101,12 @@ public function renderSolutionOutput( case CLOZE_SELECT: $solutiontext = ""; if (($active_id > 0) && (!$show_correct_solution)) { - if ((count($found) == 0) || (strlen(trim($found["value2"])) == 0)) { + if ((count($found) == 0) || (strlen(trim($found['value2'])) == 0)) { for ($chars = 0; $chars < $gap->getMaxWidth(); $chars++) { $solutiontext .= " "; } } else { - $item = $gap->getItem($found["value2"]); + $item = $gap->getItem($found['value2']); if (is_object($item)) { $solutiontext = ilLegacyFormElementsUtil::prepareFormOutput($item->getAnswertext()); } else { @@ -1251,9 +1251,9 @@ public function getTestOutput( $gaptemplate->setVariable("GAP_COUNTER", $gap_index); foreach ($user_solution as $solution) { - if (strcmp($solution["value1"], $gap_index) == 0) { + if (strcmp($solution['value1'], $gap_index) == 0) { $gaptemplate->setVariable("VALUE_GAP", " value=\"" . ilLegacyFormElementsUtil::prepareFormOutput( - $solution["value2"] + $solution['value2'] ) . "\""); } } @@ -1271,8 +1271,8 @@ public function getTestOutput( ilLegacyFormElementsUtil::prepareFormOutput($item->getAnswerText()) ); foreach ($user_solution as $solution) { - if (strcmp($solution["value1"], $gap_index) == 0) { - if (strcmp($solution["value2"], $item->getOrder()) == 0) { + if (strcmp($solution['value1'], $gap_index) == 0) { + if (strcmp($solution['value2'], $item->getOrder()) == 0) { $gaptemplate->setVariable("SELECT_GAP_SELECTED", " selected=\"selected\""); } } @@ -1295,9 +1295,9 @@ public function getTestOutput( $gaptemplate->setVariable("GAP_COUNTER", $gap_index); foreach ($user_solution as $solution) { - if (strcmp($solution["value1"], $gap_index) == 0) { + if (strcmp($solution['value1'], $gap_index) == 0) { $gaptemplate->setVariable("VALUE_GAP", " value=\"" . ilLegacyFormElementsUtil::prepareFormOutput( - $solution["value2"] + $solution['value2'] ) . "\""); } } diff --git a/Modules/TestQuestionPool/classes/class.assErrorTextGUI.php b/Modules/TestQuestionPool/classes/class.assErrorTextGUI.php index 556a455bbcaf..175a2117d2b8 100644 --- a/Modules/TestQuestionPool/classes/class.assErrorTextGUI.php +++ b/Modules/TestQuestionPool/classes/class.assErrorTextGUI.php @@ -241,7 +241,7 @@ public function analyze(): void * current errorText question object. * @param integer $active_id The active test id * @param integer $pass The test pass counter - * @param boolean $graphical_output Show visual feedback for right/wrong answers + * @param boolean $graphicalOutput Show visual feedback for right/wrong answers * @param boolean $result_output Show the reached points for parts of the question * @param boolean $show_question_only Show the question without the ILIAS content around * @param boolean $show_feedback Show the question feedback diff --git a/Modules/TestQuestionPool/classes/class.assFormulaQuestionGUI.php b/Modules/TestQuestionPool/classes/class.assFormulaQuestionGUI.php index e11658290a08..78c7fbbd1376 100755 --- a/Modules/TestQuestionPool/classes/class.assFormulaQuestionGUI.php +++ b/Modules/TestQuestionPool/classes/class.assFormulaQuestionGUI.php @@ -81,8 +81,8 @@ protected function writePostData(bool $always = false): int $this->object->setQuestion($this->request->string('question')); $this->object->parseQuestionText(); - $found_vars = array(); - $found_results = array(); + $found_vars = []; + $found_results = []; foreach ($this->request->getParsedBody() as $key => $value) { if (preg_match("/^unit_(\\\$v\d+)$/", $key, $matches)) { @@ -189,7 +189,7 @@ public function resetSavedPreviewSession(): void $user_id = $ilUser->getId(); $question_id = $this->object->getId(); $ilAssQuestionPreviewSession = new ilAssQuestionPreviewSession($user_id, $question_id); - $ilAssQuestionPreviewSession->setParticipantsSolution(array()); + $ilAssQuestionPreviewSession->setParticipantsSolution([]); } public function isSaveCommand(): bool @@ -225,7 +225,7 @@ public function editQuestion($checkonly = false, string $suggest_range_for_resul $categorized_units = $this->object->getUnitrepository()->getCategorizedUnits(); $result_units = $this->object->getAllResultUnits(); - $unit_options = array(); + $unit_options = []; $category_name = ''; $new_category = false; foreach ($categorized_units as $item) { @@ -302,8 +302,8 @@ public function editQuestion($checkonly = false, string $suggest_range_for_resul $form->addItem($intprecision); } } - $quest_vars = array(); - $result_vars = array(); + $quest_vars = []; + $result_vars = []; $results = $this->object->getResults(); if (count($results)) { uasort($results, function (assFormulaQuestionResult $r1, assFormulaQuestionResult $r2) { @@ -352,7 +352,7 @@ public function editQuestion($checkonly = false, string $suggest_range_for_resul $range_max->setRequired(true); $range_max->setValue($result->getRangeMax()); - $matches = array(); + $matches = []; $precision = new ilNumberInputGUI($this->lng->txt('precision'), 'precision_' . $result->getResult()); $precision->setRequired(true); @@ -382,7 +382,7 @@ public function editQuestion($checkonly = false, string $suggest_range_for_resul $mc_result_units = new ilMultiSelectInputGUI($this->lng->txt('result_units'), 'units_' . $result->getResult()); $mc_result_units->setOptions($unit_options); $mc_result_units->setInfo($this->lng->txt('result_units_info')); - $selectedvalues = array(); + $selectedvalues = []; foreach ($unit_options as $unit_id => $txt) { if ($this->hasResultUnit($result, $unit_id, $result_units)) { $selectedvalues[] = $unit_id; @@ -470,9 +470,9 @@ public function editQuestion($checkonly = false, string $suggest_range_for_resul $form->addItem($rating_type); } - $defined_result_vars = array(); + $defined_result_vars = []; - $defined_result_res = array(); + $defined_result_res = []; foreach ($variables as $key => $object) { $quest_vars[$key] = $key; @@ -552,8 +552,8 @@ public function editQuestion($checkonly = false, string $suggest_range_for_resul $errors = $checked; if ($save) { - $found_vars = array(); - $found_results = array(); + $found_vars = []; + $found_results = []; foreach ($this->request->getParsedBody() as $key => $value) { if (preg_match("/^unit_(\\\$v\d+)$/", $key, $matches)) { array_push($found_vars, $matches[1]); @@ -882,7 +882,7 @@ public function renderSolutionOutput( public function getPreview($show_question_only = false, $showInlineFeedback = false): string { - $user_solution = array(); + $user_solution = []; if (is_object($this->getPreviewSession())) { $solutions = (array) $this->getPreviewSession()->getParticipantsSolution(); @@ -892,12 +892,12 @@ public function getPreview($show_question_only = false, $showInlineFeedback = fa $user_solution[$matches[1]] = $val2; } elseif (preg_match("/^(\\\$r\\d+)$/", $val1, $matches)) { if (!array_key_exists($matches[1], $user_solution)) { - $user_solution[$matches[1]] = array(); + $user_solution[$matches[1]] = []; } $user_solution[$matches[1]]["value"] = $val2; } elseif (preg_match("/^(\\\$r\\d+)_unit$/", $val1, $matches)) { if (!array_key_exists($matches[1], $user_solution)) { - $user_solution[$matches[1]] = array(); + $user_solution[$matches[1]] = []; } $user_solution[$matches[1]]["unit"] = $val2; } @@ -920,7 +920,7 @@ public function getPreview($show_question_only = false, $showInlineFeedback = fa if (is_object($this->getPreviewSession())) { $questiontext = $this->object->substituteVariables($user_solution); } else { - $questiontext = $this->object->substituteVariables(array()); + $questiontext = $this->object->substituteVariables([]); } $template->setVariable("QUESTIONTEXT", ilLegacyFormElementsUtil::prepareTextareaOutput($questiontext, true)); $questionoutput = $template->get(); @@ -937,41 +937,37 @@ public function getTestOutput($active_id, $pass, $is_postponed = false, $use_pos { $this->tpl->setOnScreenMessage('info', $this->lng->txt('enter_valid_values')); // get the solution of the user for the active pass or from the last pass if allowed - $user_solution = array(); + $user_solution = []; if ($active_id) { - - $actualPassIndex = null; if ($this->object->getTestPresentationConfig()->isSolutionInitiallyPrefilled()) { $actualPassIndex = ilObjTest::_getPass($active_id); } - - $solutions = []; foreach ($this->object->getTestOutputSolutions($active_id, $pass) as $val1 => $val2) { - $solutions[] = array('value1' => $val1, 'value2' => $val2); + $solutions[] = ['value1' => $val1, 'value2' => $val2]; } foreach ($solutions as $idx => $solution_value) { - if (preg_match("/^(\\\$v\\d+)$/", $solution_value["value1"], $matches)) { + if (preg_match("/^(\\\$v\\d+)$/", $solution_value['value1'], $matches)) { if ($this->object->getTestPresentationConfig()->isSolutionInitiallyPrefilled()) { - $this->object->saveCurrentSolution($active_id, $actualPassIndex, $matches[1], $solution_value["value2"], true); + $this->object->saveCurrentSolution($active_id, $actualPassIndex, $matches[1], $solution_value['value2'], true); } - $user_solution[$matches[1]] = $solution_value["value2"]; - } elseif (preg_match("/^(\\\$r\\d+)$/", $solution_value["value1"], $matches)) { + $user_solution[$matches[1]] = $solution_value['value2']; + } elseif (preg_match("/^(\\\$r\\d+)$/", $solution_value['value1'], $matches)) { if (!array_key_exists($matches[1], $user_solution)) { - $user_solution[$matches[1]] = array(); + $user_solution[$matches[1]] = []; } - $user_solution[$matches[1]]["value"] = $solution_value["value2"]; - } elseif (preg_match("/^(\\\$r\\d+)_unit$/", $solution_value["value1"], $matches)) { + $user_solution[$matches[1]]["value"] = $solution_value['value2']; + } elseif (preg_match("/^(\\\$r\\d+)_unit$/", $solution_value['value1'], $matches)) { if (!array_key_exists($matches[1], $user_solution)) { - $user_solution[$matches[1]] = array(); + $user_solution[$matches[1]] = []; } - $user_solution[$matches[1]]["unit"] = $solution_value["value2"]; + $user_solution[$matches[1]]["unit"] = $solution_value['value2']; } - if (preg_match("/^(\\\$r\\d+)/", $solution_value["value1"], $matches) && !isset($user_solution[$matches[1]]["result_type"])) { - $user_solution[$matches[1]]["result_type"] = assFormulaQuestionResult::getResultTypeByQstId($this->object->getId(), $solution_value["value1"]); + if (preg_match("/^(\\\$r\\d+)/", $solution_value['value1'], $matches) && !isset($user_solution[$matches[1]]["result_type"])) { + $user_solution[$matches[1]]["result_type"] = assFormulaQuestionResult::getResultTypeByQstId($this->object->getId(), $solution_value['value1']); } } } @@ -982,8 +978,8 @@ public function getTestOutput($active_id, $pass, $is_postponed = false, $use_pos $solutions[] = array('value1' => $val1, 'value2' => $val2); } foreach ($solutions as $idx => $solution_value) { - if (preg_match("/^(\\\$v\\d+)$/", $solution_value["value1"], $matches)) { - $user_solution[$matches[1]] = $solution_value["value2"]; + if (preg_match("/^(\\\$v\\d+)$/", $solution_value['value1'], $matches)) { + $user_solution[$matches[1]] = $solution_value['value2']; } } diff --git a/Modules/TestQuestionPool/classes/class.assImagemapQuestionGUI.php b/Modules/TestQuestionPool/classes/class.assImagemapQuestionGUI.php index ad953beab794..51baa39a1124 100755 --- a/Modules/TestQuestionPool/classes/class.assImagemapQuestionGUI.php +++ b/Modules/TestQuestionPool/classes/class.assImagemapQuestionGUI.php @@ -397,8 +397,8 @@ protected function completeTestOutputFormAction($formAction, $active_id, $pass) $info = $this->object->getTestOutputSolutions($active_id, $pass); if (count($info)) { - if ($info[0]["value1"] !== "") { - $formAction .= "&selImage=" . $info[0]["value1"]; + if ($info[0]['value1'] !== "") { + $formAction .= "&selImage=" . $info[0]['value1']; } } @@ -496,7 +496,7 @@ public function renderSolutionOutput( if (is_array($user_solutions)) { $preview = new ilImagemapPreview($this->object->getImagePath() . $this->object->getImageFilename()); foreach ($user_solutions as $idx => $solution_value) { - $value1 = $solution_value["value1"]; + $value1 = $solution_value['value1']; if ( $value1 === '' || !isset($this->object->answers[$value1]) @@ -667,9 +667,9 @@ public function getTestOutput($active_id, $pass, $is_postponed = false, $use_pos $preview = new ilImagemapPreview($this->object->getImagePath() . $this->object->getImageFilename()); foreach ($solutions as $idx => $solution_value) { - if ($solution_value["value1"] !== null) { - $preview->addArea($solution_value["value1"], $this->object->answers[$solution_value["value1"]]->getArea(), $this->object->answers[$solution_value["value1"]]->getCoords(), $this->object->answers[$solution_value["value1"]]->getAnswertext(), "", "", true, $this->linecolor); - $userSelection[$selectionIndex] = $solution_value["value1"]; + if ($solution_value['value1'] !== null) { + $preview->addArea($solution_value['value1'], $this->object->answers[$solution_value['value1']]->getArea(), $this->object->answers[$solution_value['value1']]->getCoords(), $this->object->answers[$solution_value['value1']]->getAnswertext(), "", "", true, $this->linecolor); + $userSelection[$selectionIndex] = $solution_value['value1']; $selectionIndex = $this->object->getIsMultipleChoice() ? ++$selectionIndex : $selectionIndex; } diff --git a/Modules/TestQuestionPool/classes/class.assKprimChoiceGUI.php b/Modules/TestQuestionPool/classes/class.assKprimChoiceGUI.php index 7f0c7e047b39..70aaaa460a90 100644 --- a/Modules/TestQuestionPool/classes/class.assKprimChoiceGUI.php +++ b/Modules/TestQuestionPool/classes/class.assKprimChoiceGUI.php @@ -569,7 +569,6 @@ public function getSolutionOutput( if (($active_id > 0) && (!$show_correct_solution)) { $solutions = $this->object->getSolutionValues($active_id, $pass); foreach ($solutions as $idx => $solution_value) { - //$user_solution[$solution_value['value1']] = $solution_value['value2']; $user_solution[] = [ 'value1' => $solution_value['value1'], 'value2' => $solution_value['value2'] @@ -578,7 +577,6 @@ public function getSolutionOutput( } else { // take the correct solution instead of the user solution foreach ($this->object->getAnswers() as $answer) { - //$user_solution[$answer->getPosition()] = $answer->getCorrectness(); $user_solution[] = [ 'value1' => $answer->getPosition(), 'value2' => $answer->getCorrectness() diff --git a/Modules/TestQuestionPool/classes/class.assLongMenuGUI.php b/Modules/TestQuestionPool/classes/class.assLongMenuGUI.php index 189f8f282529..3179fd31ca04 100644 --- a/Modules/TestQuestionPool/classes/class.assLongMenuGUI.php +++ b/Modules/TestQuestionPool/classes/class.assLongMenuGUI.php @@ -52,26 +52,6 @@ public function __construct($id = -1) } - /** - * @param $active_id - * @param $pass - * @return array - */ - /* - protected function getUserSolution($active_id, $pass): array - { - $user_solution = array(); - if ($active_id) { - $solutions = $this->object->getSolutionValues($active_id, $pass, true); - // hey. - foreach ($solutions as $idx => $solution_value) { - $user_solution[$solution_value["value1"]] = $solution_value["value2"]; - } - return $user_solution; - } - return $user_solution; - }*/ - public function getCommand($cmd) { return $cmd; @@ -410,7 +390,7 @@ public function renderSolutionOutput( $user_solution = []; foreach ($user_solutions as $idx => $solution_value) { - $user_solution[$solution_value["value1"]] = $solution_value["value2"]; + $user_solution[$solution_value['value1']] = $solution_value['value2']; } @@ -479,7 +459,7 @@ public function getTestOutput( if ($active_id) { $solutions = $this->object->getUserSolutionPreferingIntermediate($active_id, $pass); foreach ($solutions as $idx => $solution_value) { - $user_solution[$solution_value["value1"]] = $solution_value["value2"]; + $user_solution[$solution_value['value1']] = $solution_value['value2']; } } diff --git a/Modules/TestQuestionPool/classes/class.assMatchingQuestionGUI.php b/Modules/TestQuestionPool/classes/class.assMatchingQuestionGUI.php index 42647d1dc556..d3ec8b8c8e4e 100755 --- a/Modules/TestQuestionPool/classes/class.assMatchingQuestionGUI.php +++ b/Modules/TestQuestionPool/classes/class.assMatchingQuestionGUI.php @@ -866,10 +866,10 @@ public function getTestOutput($active_id, $pass, $is_postponed = false, $user_po $counter = 0; foreach ($solutions as $idx => $solution_value) { - if (($solution_value["value2"] > -1) && ($solution_value["value1"] > -1)) { + if (($solution_value['value2'] > -1) && ($solution_value['value1'] > -1)) { $template->setCurrentBlock("matching_data"); - $template->setVariable("TERM_ID", $solution_value["value1"]); - $template->setVariable("DEFINITION_ID", $solution_value["value2"]); + $template->setVariable("TERM_ID", $solution_value['value1']); + $template->setVariable("DEFINITION_ID", $solution_value['value2']); $template->parseCurrentBlock(); } diff --git a/Modules/TestQuestionPool/classes/class.assMultipleChoiceGUI.php b/Modules/TestQuestionPool/classes/class.assMultipleChoiceGUI.php index c0e374d4bbe7..5f5862fbea41 100755 --- a/Modules/TestQuestionPool/classes/class.assMultipleChoiceGUI.php +++ b/Modules/TestQuestionPool/classes/class.assMultipleChoiceGUI.php @@ -272,7 +272,7 @@ public function renderSolutionOutput( $user_solution = []; foreach ($user_solutions as $idx => $solution_value) { - array_push($user_solution, $solution_value["value1"]); + array_push($user_solution, $solution_value['value1']); } $keys = $this->getChoiceKeys(); @@ -555,12 +555,12 @@ public function getTestOutput( // hey. foreach ($solutions as $idx => $solution_value) { // fau: testNav - don't add the dummy entry for 'none of the above' to the user options - if ($solution_value["value1"] == 'mc_none_above') { + if ($solution_value['value1'] == 'mc_none_above') { $this->setUseEmptySolutionInputChecked(true); continue; } - $user_solution[] = $solution_value["value1"]; + $user_solution[] = $solution_value['value1']; // fau. } diff --git a/Modules/TestQuestionPool/classes/class.assNumericGUI.php b/Modules/TestQuestionPool/classes/class.assNumericGUI.php index 1b330a39f033..43161ed3d28b 100755 --- a/Modules/TestQuestionPool/classes/class.assNumericGUI.php +++ b/Modules/TestQuestionPool/classes/class.assNumericGUI.php @@ -1,4 +1,5 @@ 0) && (!$show_correct_solution)) { $solutions = $this->object->getSolutionValues($active_id, $pass); } else { - array_push($solutions, array("value1" => sprintf($this->lng->txt("value_between_x_and_y"), $this->object->getLowerLimit(), $this->object->getUpperLimit()))); + array_push($solutions, [ + 'value1' => sprintf( + $this->lng->txt("value_between_x_and_y"), + $this->object->getLowerLimit(), + $this->object->getUpperLimit() + ) + ]); } - // generate the question output + return $this->renderSolutionOutput( + $solutions, + $active_id, + $pass, + $graphicalOutput, + $result_output, + $show_question_only, + $show_feedback, + $show_correct_solution, + $show_manual_scoring, + $show_question_text, + false, + false, + ); + } + + public function renderSolutionOutput( + mixed $user_solutions, + int $active_id, + int $pass, + bool $graphical_output = false, + bool $result_output = false, + bool $show_question_only = true, + bool $show_feedback = false, + bool $show_correct_solution = false, + bool $show_manual_scoring = false, + bool $show_question_text = true, + bool $show_autosave_title = false, + bool $show_inline_feedback = false, + ): ?string { $template = new ilTemplate("tpl.il_as_qpl_numeric_output_solution.html", true, true, "Modules/TestQuestionPool"); $solutiontemplate = new ilTemplate("tpl.il_as_tst_solution_output.html", true, true, "Modules/TestQuestionPool"); - if (is_array($solutions)) { + if (is_array($user_solutions)) { if (($active_id > 0) && (!$show_correct_solution)) { - if ($graphicalOutput) { + if ($graphical_output) { if ($this->object->getStep() === null) { $reached_points = $this->object->getReachedPoints($active_id, $pass); } else { @@ -205,10 +241,10 @@ public function getSolutionOutput( $template->parseCurrentBlock(); } } - foreach ($solutions as $solution) { - $template->setVariable("NUMERIC_VALUE", $solution["value1"]); + foreach ($user_solutions as $solution) { + $template->setVariable("NUMERIC_VALUE", $solution['value1']); } - if (count($solutions) == 0) { + if (count($user_solutions) == 0) { $template->setVariable("NUMERIC_VALUE", "      "); } } @@ -288,7 +324,7 @@ public function getTestOutput($active_id, $pass, $is_postponed = false, $use_pos $template = new ilTemplate("tpl.il_as_qpl_numeric_output.html", true, true, "Modules/TestQuestionPool"); if (is_array($solutions)) { foreach ($solutions as $solution) { - $template->setVariable("NUMERIC_VALUE", " value=\"" . $solution["value1"] . "\""); + $template->setVariable("NUMERIC_VALUE", " value=\"" . $solution['value1'] . "\""); } } $template->setVariable("NUMERIC_SIZE", $this->object->getMaxChars()); @@ -390,7 +426,7 @@ public function populateAnswerSpecificFormPart(\ilPropertyFormGUI $form): ilProp */ public function getAfterParticipationSuppressionAnswerPostVars(): array { - return array(); + return []; } /** @@ -404,7 +440,7 @@ public function getAfterParticipationSuppressionAnswerPostVars(): array */ public function getAfterParticipationSuppressionQuestionPostVars(): array { - return array(); + return []; } /** @@ -422,7 +458,7 @@ public function getAggregatedAnswersView(array $relevant_answers): string public function aggregateAnswers($relevant_answers_chosen): array { - $aggregate = array(); + $aggregate = []; foreach ($relevant_answers_chosen as $relevant_answer) { if (array_key_exists($relevant_answer['value1'], $aggregate)) { @@ -462,7 +498,7 @@ public function renderAggregateView($aggregate): ilTemplate public function getAnswersFrequency($relevantAnswers, $questionIndex): array { - $answers = array(); + $answers = []; foreach ($relevantAnswers as $ans) { if (!isset($answers[$ans['value1']])) { diff --git a/Modules/TestQuestionPool/classes/class.assOrderingHorizontalGUI.php b/Modules/TestQuestionPool/classes/class.assOrderingHorizontalGUI.php index 2b510b382255..9033a917a244 100644 --- a/Modules/TestQuestionPool/classes/class.assOrderingHorizontalGUI.php +++ b/Modules/TestQuestionPool/classes/class.assOrderingHorizontalGUI.php @@ -177,8 +177,8 @@ public function renderSolutionOutput( bool $show_inline_feedback = false, ): ?string { $elements = []; - if (count($user_solutions) && strlen($user_solutions[0]["value1"])) { - $elements = explode("{::}", $user_solutions[0]["value1"]); + if (count($user_solutions) && strlen($user_solutions[0]['value1'])) { + $elements = explode("{::}", $user_solutions[0]['value1']); } if (!count($elements)) { @@ -331,7 +331,7 @@ public function getTestOutput($active_id, $pass, $is_postponed = false, $use_pos $solutions = $this->object->getTestOutputSolutions($active_id, $pass); // hey. if (is_array($solutions) && count($solutions) == 1) { - $elements = explode("{::}", $solutions[0]["value1"]); + $elements = explode("{::}", $solutions[0]['value1']); } } if (!is_array($solutions) || count($solutions) == 0) { diff --git a/Modules/TestQuestionPool/classes/class.assOrderingQuestionGUI.php b/Modules/TestQuestionPool/classes/class.assOrderingQuestionGUI.php index 38d655d9cb28..593c4453040c 100755 --- a/Modules/TestQuestionPool/classes/class.assOrderingQuestionGUI.php +++ b/Modules/TestQuestionPool/classes/class.assOrderingQuestionGUI.php @@ -600,7 +600,7 @@ public function getTestOutput($activeId, $pass, $isPostponed = false, $userSolut // hey. { // hey: prevPassSolutions - fixed variable type, makes phpstorm stop crying - $userSolutionPost = is_array($userSolutionPost) ? $userSolutionPost : array(); + $userSolutionPost = is_array($userSolutionPost) ? $userSolutionPost : []; // hey. $orderingGUI = $this->object->buildNestedOrderingElementInputGui(); @@ -664,7 +664,7 @@ public function getSpecificFeedbackOutput(array $userSolution): string */ public function getAfterParticipationSuppressionAnswerPostVars(): array { - return array(); + return []; } /** @@ -678,7 +678,7 @@ public function getAfterParticipationSuppressionAnswerPostVars(): array */ public function getAfterParticipationSuppressionQuestionPostVars(): array { - return array(); + return []; } /** @@ -699,12 +699,12 @@ public function getAggregatedAnswersView(array $relevant_answers): string public function aggregateAnswers($relevant_answers_chosen, $answers_defined_on_question): array { - $passdata = array(); // Regroup answers into units of passes. + $passdata = []; // Regroup answers into units of passes. foreach ($relevant_answers_chosen as $answer_chosen) { $passdata[$answer_chosen['active_fi'] . '-' . $answer_chosen['pass']][$answer_chosen['value2']] = $answer_chosen['value1']; } - $variants = array(); // Determine unique variants. + $variants = []; // Determine unique variants. foreach ($passdata as $key => $data) { $hash = md5(implode('-', $data)); $value_set = false; @@ -720,7 +720,7 @@ public function aggregateAnswers($relevant_answers_chosen, $answers_defined_on_q } } - $aggregate = array(); // Render aggregate from variant. + $aggregate = []; // Render aggregate from variant. foreach ($variants as $key => $variant_entry) { $variant = $passdata[$key]; @@ -830,26 +830,26 @@ protected function getAnswerStatisticOrderingVariantHtml(ilAssOrderingElementLis public function getAnswersFrequency($relevantAnswers, $questionIndex): array { - $answersByActiveAndPass = array(); + $answersByActiveAndPass = []; foreach ($relevantAnswers as $row) { $key = $row['active_fi'] . ':' . $row['pass']; if (!isset($answersByActiveAndPass[$key])) { - $answersByActiveAndPass[$key] = array(); + $answersByActiveAndPass[$key] = []; } $answersByActiveAndPass[$key][$row['value1']] = $row['value2']; } - $solutionLists = array(); + $solutionLists = []; foreach ($answersByActiveAndPass as $indexedSolutions) { $solutionLists[] = $this->object->getSolutionOrderingElementList($indexedSolutions); } /* @var ilAssOrderingElementList[] $answers */ - $answers = array(); + $answers = []; foreach ($solutionLists as $orderingElementList) { $hash = $orderingElementList->getHash(); diff --git a/Modules/TestQuestionPool/classes/class.assSingleChoiceGUI.php b/Modules/TestQuestionPool/classes/class.assSingleChoiceGUI.php index 3b64fcc4e094..c640769f0ce3 100755 --- a/Modules/TestQuestionPool/classes/class.assSingleChoiceGUI.php +++ b/Modules/TestQuestionPool/classes/class.assSingleChoiceGUI.php @@ -296,7 +296,7 @@ public function renderSolutionOutput( ): ?string { $user_solution = ''; foreach ($user_solutions as $idx => $solution_value) { - $user_solution = $solution_value["value1"]; + $user_solution = $solution_value['value1']; } $keys = $this->getChoiceKeys(); @@ -476,7 +476,7 @@ public function getTestOutput($active_id, $pass, $is_postponed = false, $use_pos if ($active_id) { $solutions = $this->object->getTestOutputSolutions($active_id, $pass); foreach ($solutions as $idx => $solution_value) { - $user_solution = $solution_value["value1"]; + $user_solution = $solution_value['value1']; } } diff --git a/Modules/TestQuestionPool/classes/class.assTextQuestionGUI.php b/Modules/TestQuestionPool/classes/class.assTextQuestionGUI.php index 15841812d2f2..e3f4f0153170 100755 --- a/Modules/TestQuestionPool/classes/class.assTextQuestionGUI.php +++ b/Modules/TestQuestionPool/classes/class.assTextQuestionGUI.php @@ -443,7 +443,7 @@ private function getUserAnswer($active_id, $pass) $user_solution = ""; $solutions = $this->object->getSolutionValues($active_id, $pass); foreach ($solutions as $idx => $solution_value) { - $user_solution = $solution_value["value1"]; + $user_solution = $solution_value['value1']; } return $user_solution; } @@ -503,7 +503,7 @@ public function getTestOutput($active_id, $pass = null, $is_postponed = false, $ if ($active_id) { $solutions = $this->object->getUserSolutionPreferingIntermediate($active_id, $pass); foreach ($solutions as $idx => $solution_value) { - $user_solution = $solution_value["value1"]; + $user_solution = $solution_value['value1']; } if ($this->tiny_mce_enabled) { diff --git a/Modules/TestQuestionPool/classes/class.assTextSubsetGUI.php b/Modules/TestQuestionPool/classes/class.assTextSubsetGUI.php index 030881870350..03d467358a4e 100755 --- a/Modules/TestQuestionPool/classes/class.assTextSubsetGUI.php +++ b/Modules/TestQuestionPool/classes/class.assTextSubsetGUI.php @@ -217,12 +217,12 @@ public function renderSolutionOutput( $solutiontemplate = new ilTemplate("tpl.il_as_tst_solution_output.html", true, true, "Modules/TestQuestionPool"); $available_answers = &$this->object->getAvailableAnswers(); for ($i = 0; $i < $this->object->getCorrectAnswers(); $i++) { - if (!array_key_exists($i, $user_solutions) || (strcmp($user_solutions[$i]["value1"], "") == 0)) { + if (!array_key_exists($i, $user_solutions) || (strcmp($user_solutions[$i]['value1'], "") == 0)) { } else { if (($active_id > 0) && (!$show_correct_solution)) { if ($graphical_output) { // output of ok/not ok icons for user entered solutions - $index = $this->object->isAnswerCorrect($available_answers, $user_solutions[$i]["value1"]); + $index = $this->object->isAnswerCorrect($available_answers, $user_solutions[$i]['value1']); $correct = false; if ($index !== false) { unset($available_answers[$index]); @@ -239,7 +239,7 @@ public function renderSolutionOutput( } } $template->setCurrentBlock("textsubset_row"); - $template->setVariable("SOLUTION", $this->escapeTemplatePlaceholders($user_solutions[$i]["value1"])); + $template->setVariable("SOLUTION", $this->escapeTemplatePlaceholders($user_solutions[$i]['value1'])); $template->setVariable("COUNTER", $i + 1); if ($result_output) { $points = $user_solutions[$i]["points"]; @@ -316,7 +316,7 @@ public function getTestOutput($active_id, $pass = null, $is_postponed = false, $ foreach ($solutions as $idx => $solution_value) { if ($idx == $i) { $template->setVariable("TEXTFIELD_VALUE", " value=\"" - . $this->escapeTemplatePlaceholders($solution_value["value1"]) + . $this->escapeTemplatePlaceholders($solution_value['value1']) . "\""); } }