From 543b3dea6b47620ab6dd2de94adc07ef106a29e6 Mon Sep 17 00:00:00 2001 From: Nils Haagen Date: Wed, 18 Oct 2023 12:48:35 +0200 Subject: [PATCH] TA: PresentationTable for results, some renaming and use-statements --- .../Results/class.ilQuestionResult.php | 6 ++--- .../Results/class.ilTestPassResultsTable.php | 27 +++++++++++-------- .../Results/class.ilTestResultsFactory.php | 7 +++-- ...class.ilTestResultsPresentationFactory.php | 16 +++++++---- .../class.ilTestPassOverviewTableGUI.php | 13 +++++---- .../Test/test/TestPassResultsSettingsTest.php | 2 +- .../test/TestResultsQuestionResultsTest.php | 2 +- 7 files changed, 45 insertions(+), 28 deletions(-) diff --git a/Modules/Test/classes/Results/class.ilQuestionResult.php b/Modules/Test/classes/Results/class.ilQuestionResult.php index 389890194057..1de0a45ad2ad 100644 --- a/Modules/Test/classes/Results/class.ilQuestionResult.php +++ b/Modules/Test/classes/Results/class.ilQuestionResult.php @@ -39,7 +39,7 @@ public function __construct( protected string $feedback, protected bool $workedthrough, protected bool $answered, - protected ?string $recapitulation + protected ?string $content_for_recapitulation ) { } @@ -97,8 +97,8 @@ public function isAnswered(): bool { return $this->answered; } - public function getRecapitulation(): ?string + public function getContentForRecapitulation(): ?string { - return $this->recapitulation; + return $this->content_for_recapitulation; } } diff --git a/Modules/Test/classes/Results/class.ilTestPassResultsTable.php b/Modules/Test/classes/Results/class.ilTestPassResultsTable.php index 6ae090570603..589e1ad03225 100644 --- a/Modules/Test/classes/Results/class.ilTestPassResultsTable.php +++ b/Modules/Test/classes/Results/class.ilTestPassResultsTable.php @@ -20,6 +20,11 @@ use ILIAS\UI\Implementation\Component\Table\Presentation; use ILIAS\UI\URLBuilder; +use ILIAS\UI\Factory as UIFactory; +use ILIAS\UI\Renderer as UIRenderer; +use ILIAS\Refinery\Factory as Refinery; +use ILIAS\HTTP\Services as HTTPService; +use ILIAS\Data\Factory as DataFactory; /** * @package Modules/Test @@ -41,11 +46,11 @@ class ilTestPassResultsTable protected Presentation $table; public function __construct( - ILIAS\UI\Factory $ui_factory, - protected \ILIAS\UI\Renderer $ui_renderer, - protected ILIAS\Refinery\Factory $refinery, - protected ILIAS\HTTP\Services $http, - ILIAS\Data\Factory $data_factory, + UIFactory $ui_factory, + protected UIRenderer $ui_renderer, + protected Refinery $refinery, + protected HTTPService $http, + DataFactory $data_factory, ilLanguage $lng, ilTestPassResult $test_results, string $title @@ -120,8 +125,8 @@ protected function getViewControlsParameter(): array * return \ILIAS\UI\ViewControl\ViewControl[] */ protected function getViewControls( - \ILIAS\UI\Factory $ui_factory, - \ilLanguage $lng, + UIFactory $ui_factory, + ilLanguage $lng, URLBuilder $target, string $mode, string $sortation @@ -170,7 +175,7 @@ protected function getMapping(): \Closure (string)$question->getId() ); - $important = [ + $important_fields = [ $lng->txt('question_id') => (string)$question->getId(), $lng->txt('question_type') => $question->getType(), $lng->txt('points') => sprintf( @@ -180,7 +185,7 @@ protected function getMapping(): \Closure (string)$question->getUserScorePercent() ) ]; - $stats = $ui_factory->listing()->characteristicValue()->text($important); + $stats = $ui_factory->listing()->characteristicValue()->text($important_fields); $user_answer = $question->getUserAnswer(); $best_solution = $env->getShowBestSolution() ? $question->getBestSolution() : ''; @@ -196,7 +201,7 @@ protected function getMapping(): \Closure $contents[] = $feedback; } - if ($recap = $question->getRecapitulation()) { + if ($recap = $question->getContentForRecapitulation()) { $contents[] = $ui_factory->listing()->descriptive([ $lng->txt('suggested_solution') => $recap ]); @@ -234,7 +239,7 @@ protected function getMapping(): \Closure return $row ->withHeadline($title) ->withLeadingSymbol($correct_icon) - ->withImportantFields($important) + ->withImportantFields($important_fields) ->withContent($content); }; } diff --git a/Modules/Test/classes/Results/class.ilTestResultsFactory.php b/Modules/Test/classes/Results/class.ilTestResultsFactory.php index 0bca6794a878..69bf9b7a71c4 100644 --- a/Modules/Test/classes/Results/class.ilTestResultsFactory.php +++ b/Modules/Test/classes/Results/class.ilTestResultsFactory.php @@ -18,6 +18,9 @@ declare(strict_types=1); +use ILIAS\UI\Factory as UIFactory; +use ILIAS\UI\Renderer as UIRenderer; + /** * @package Modules/Test * Results (currently, for one user and pass) @@ -29,8 +32,8 @@ class ilTestResultsFactory */ public function __construct( protected ilTestShuffler $shuffler, - protected ILIAS\UI\Factory $ui_factory, - protected ILIAS\UI\Renderer $ui_renderer + protected UIFactory $ui_factory, + protected UIRenderer $ui_renderer ) { } public function getPassResultsFor( diff --git a/Modules/Test/classes/Results/class.ilTestResultsPresentationFactory.php b/Modules/Test/classes/Results/class.ilTestResultsPresentationFactory.php index 8857f76f379b..286437be7d99 100644 --- a/Modules/Test/classes/Results/class.ilTestResultsPresentationFactory.php +++ b/Modules/Test/classes/Results/class.ilTestResultsPresentationFactory.php @@ -18,6 +18,12 @@ declare(strict_types=1); +use ILIAS\UI\Factory as UIFactory; +use ILIAS\UI\Renderer as UIRenderer; +use ILIAS\Refinery\Factory as Refinery; +use ILIAS\HTTP\Services as HTTPService; +use ILIAS\Data\Factory as DataFactory; + /** * @package Modules/Test * Results for one user and pass in a Presentation Table @@ -25,11 +31,11 @@ class ilTestResultsPresentationFactory { public function __construct( - protected ILIAS\UI\Factory $ui_factory, - protected ILIAS\UI\Renderer $ui_renderer, - protected ILIAS\Refinery\Factory $refinery, - protected ILIAS\Data\Factory $data_factory, - protected ILIAS\HTTP\Services $http, + protected UIFactory $ui_factory, + protected UIRenderer $ui_renderer, + protected Refinery $refinery, + protected DataFactory $data_factory, + protected HTTPService $http, protected ilLanguage $lng ) { } diff --git a/Modules/Test/classes/tables/class.ilTestPassOverviewTableGUI.php b/Modules/Test/classes/tables/class.ilTestPassOverviewTableGUI.php index ea10c5684836..a63f35c386d3 100644 --- a/Modules/Test/classes/tables/class.ilTestPassOverviewTableGUI.php +++ b/Modules/Test/classes/tables/class.ilTestPassOverviewTableGUI.php @@ -18,13 +18,16 @@ declare(strict_types=1); +use ILIAS\UI\Factory as UIFactory; +use ILIAS\UI\Renderer as UIRenderer; + /** * Class ilTestPassOverviewTableGUI */ class ilTestPassOverviewTableGUI extends ilTable2GUI { - private \ILIAS\UI\Factory $ui_factory; - private \ILIAS\UI\Renderer $ui_renderer; + private UIFactory $ui_factory; + private UIRenderer $ui_renderer; protected bool $resultPresentationEnabled = false; protected bool $pdfPresentationEnabled = false; @@ -266,12 +269,12 @@ private function buildActionsHtml($actions, $pass): string } $this->ctrl->setParameter($this->parent_obj, 'pass', $pass); - $act = []; + $action_links = []; if (count($actions) > 1) { foreach ($actions as $cmd => $label) { - $act[] = $this->ui_factory->link()->standard($label, $this->ctrl->getLinkTarget($this->parent_obj, $cmd)); + $action_links[] = $this->ui_factory->link()->standard($label, $this->ctrl->getLinkTarget($this->parent_obj, $cmd)); } - $dropdown = $this->ui_factory->dropdown()->standard($act)->withLabel($this->lng->txt('actions')); + $dropdown = $this->ui_factory->dropdown()->standard($action_links)->withLabel($this->lng->txt('actions')); $html = $this->ui_renderer->render($dropdown); } else { $cmd = key($actions); diff --git a/Modules/Test/test/TestPassResultsSettingsTest.php b/Modules/Test/test/TestPassResultsSettingsTest.php index 6576f259db47..149d2da3b10c 100644 --- a/Modules/Test/test/TestPassResultsSettingsTest.php +++ b/Modules/Test/test/TestPassResultsSettingsTest.php @@ -22,7 +22,7 @@ use PHPUnit\Framework\TestCase; -class TestResultsSettingsTest extends TestCase +class TestPassResultsSettingsTest extends TestCase { public function testTestResultsSettingsDefaults(): void { diff --git a/Modules/Test/test/TestResultsQuestionResultsTest.php b/Modules/Test/test/TestResultsQuestionResultsTest.php index 90f4d2651339..5c5c0a6e9005 100644 --- a/Modules/Test/test/TestResultsQuestionResultsTest.php +++ b/Modules/Test/test/TestResultsQuestionResultsTest.php @@ -50,6 +50,6 @@ public function testTestResultsQuestionResultsBasicProps(): void $this->assertEquals($feedback, $qr->getFeedback()); $this->assertTrue($qr->isWorkedThrough()); $this->assertTrue($qr->isAnswered()); - $this->assertEquals($recapitulation, $qr->getRecapitulation()); + $this->assertEquals($recapitulation, $qr->getContentForRecapitulation()); } }