Skip to content

Commit

Permalink
TA: PresentationTable for results, some renaming and use-statements
Browse files Browse the repository at this point in the history
  • Loading branch information
nhaagen committed Oct 18, 2023
1 parent 67fa414 commit 1fa5759
Show file tree
Hide file tree
Showing 7 changed files with 40 additions and 26 deletions.
6 changes: 3 additions & 3 deletions Modules/Test/classes/Results/class.ilQuestionResult.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public function __construct(
protected string $feedback,
protected bool $workedthrough,
protected bool $answered,
protected ?string $recapitulation
protected ?string $content_for_recapitulation
) {
}

Expand Down Expand Up @@ -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;
}
}
27 changes: 16 additions & 11 deletions Modules/Test/classes/Results/class.ilTestPassResultsTable.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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(
Expand All @@ -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() : '';

Expand All @@ -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
]);
Expand Down Expand Up @@ -234,7 +239,7 @@ protected function getMapping(): \Closure
return $row
->withHeadline($title)
->withLeadingSymbol($correct_icon)
->withImportantFields($important)
->withImportantFields($important_fields)
->withContent($content);
};
}
Expand Down
7 changes: 5 additions & 2 deletions Modules/Test/classes/Results/class.ilTestResultsFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,24 @@

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
*/
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
) {
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -266,12 +266,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);
Expand Down
2 changes: 1 addition & 1 deletion Modules/Test/test/TestPassResultsSettingsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

use PHPUnit\Framework\TestCase;

class TestResultsSettingsTest extends TestCase
class TestPassResultsSettingsTest extends TestCase
{
public function testTestResultsSettingsDefaults(): void
{
Expand Down
2 changes: 1 addition & 1 deletion Modules/Test/test/TestResultsQuestionResultsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}
}

0 comments on commit 1fa5759

Please sign in to comment.