diff --git a/Modules/Test/classes/Results/class.ilTestResult.php b/Modules/Test/classes/Results/class.ilTestPassResult.php
similarity index 86%
rename from Modules/Test/classes/Results/class.ilTestResult.php
rename to Modules/Test/classes/Results/class.ilTestPassResult.php
index 69658c5badd6..8183a25d9168 100644
--- a/Modules/Test/classes/Results/class.ilTestResult.php
+++ b/Modules/Test/classes/Results/class.ilTestPassResult.php
@@ -22,18 +22,24 @@
* @package Modules/Test
* Results for one user and pass
*/
-class ilTestResult
+class ilTestPassResult
{
/**
* @param ilQuestionResult[] $question_results
*/
public function __construct(
+ protected ilTestPassResultsSettings $settings,
protected int $active_id,
protected int $pass_id,
protected array $question_results
) {
}
+ public function getSettings(): ilTestPassResultsSettings
+ {
+ return $this->settings;
+ }
+
public function getActiveId(): int
{
return $this->active_id;
diff --git a/Modules/Test/classes/Results/ilTestResultsSettings.php b/Modules/Test/classes/Results/class.ilTestPassResultsSettings.php
similarity index 98%
rename from Modules/Test/classes/Results/ilTestResultsSettings.php
rename to Modules/Test/classes/Results/class.ilTestPassResultsSettings.php
index ed2b80785668..8f57f6c3a59f 100644
--- a/Modules/Test/classes/Results/ilTestResultsSettings.php
+++ b/Modules/Test/classes/Results/class.ilTestPassResultsSettings.php
@@ -22,7 +22,7 @@
* @package Modules/Test
* Environment/settings to control result presentation
*/
-class ilTestResultsSettings
+class ilTestPassResultsSettings
{
protected bool $show_hidden_questions = false;
protected bool $show_optional_questions = false;
diff --git a/Modules/Test/classes/Results/class.ilTestResultsOverviewTable.php b/Modules/Test/classes/Results/class.ilTestPassResultsTable.php
similarity index 97%
rename from Modules/Test/classes/Results/class.ilTestResultsOverviewTable.php
rename to Modules/Test/classes/Results/class.ilTestPassResultsTable.php
index f9dce8541bf0..6ae090570603 100644
--- a/Modules/Test/classes/Results/class.ilTestResultsOverviewTable.php
+++ b/Modules/Test/classes/Results/class.ilTestPassResultsTable.php
@@ -23,9 +23,9 @@
/**
* @package Modules/Test
- * Results Overview Table
+ * Table Presentation of Pass Results
*/
-class ilTestResultsOverviewTable
+class ilTestPassResultsTable
{
private const ENV = 'e';
private const LNG = 'l';
@@ -47,14 +47,11 @@ public function __construct(
protected ILIAS\HTTP\Services $http,
ILIAS\Data\Factory $data_factory,
ilLanguage $lng,
- string $title,
- ilTestResult $test_results,
- ilTestResultsSettings $environment
+ ilTestPassResult $test_results,
+ string $title
) {
list($mode, $sortation) = $this->getViewControlsParameter();
-
$results = $this->applyControls($mode, $sortation, $test_results->getQuestionResults());
-
$target = new URLBuilder($data_factory->uri($http->request()->getUri()->__toString()));
$this->table = $ui_factory->table()->presentation(
@@ -63,7 +60,7 @@ public function __construct(
$this->getMapping()
)
->withEnvironment([
- self::ENV => $environment,
+ self::ENV => $test_results->getSettings(),
self::LNG => $lng
])
->withData($results);
diff --git a/Modules/Test/classes/Results/class.ilTestResultsFactory.php b/Modules/Test/classes/Results/class.ilTestResultsFactory.php
index d6c13c3d4056..0bca6794a878 100644
--- a/Modules/Test/classes/Results/class.ilTestResultsFactory.php
+++ b/Modules/Test/classes/Results/class.ilTestResultsFactory.php
@@ -20,50 +20,47 @@
/**
* @package Modules/Test
- * Results for one user and pass
+ * Results (currently, for one user and pass)
*/
class ilTestResultsFactory
{
- protected ilObjTest $test_obj;
- protected int $active_id;
- protected int $pass_id;
- protected bool $is_user_output = true;
-
/**
* @param ilQuestionResult[] $question_results
*/
public function __construct(
protected ilTestShuffler $shuffler,
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 ilLanguage $lng
+ protected ILIAS\UI\Renderer $ui_renderer
) {
}
- public function for(
+ public function getPassResultsFor(
ilObjTest $test_obj,
int $active_id,
int $pass_id,
bool $is_user_output = true
- ): self {
- $clone = clone $this;
- $clone->test_obj = $test_obj;
- $clone->active_id = $active_id;
- $clone->pass_id = $pass_id;
- $clone->is_user_output = $is_user_output;
- return $clone;
+ ): ilTestPassResult {
+ $settings = $this->getPassResultsSettings($test_obj, $is_user_output);
+ return $this->buildPassResults(
+ $settings,
+ $test_obj,
+ $active_id,
+ $pass_id,
+ $is_user_output
+ );
}
- protected function getResults(): ilTestResult
- {
- $settings = $this->getResultsSettings();
+ protected function buildPassResults(
+ ilTestPassResultsSettings $settings,
+ ilObjTest $test_obj,
+ int $active_id,
+ int $pass_id,
+ bool $is_user_output
+ ): ilTestPassResult {
$question_results = [];
- $results = $this->test_obj->getTestResult(
- $this->active_id,
- $this->pass_id,
+ $results = $test_obj->getTestResult(
+ $active_id,
+ $pass_id,
false, //$ordered_sequence
$settings->getShowHiddenQuestions(),
$settings->getShowOptionalQuestions()
@@ -80,7 +77,7 @@ protected function getResults(): ilTestResult
$show_inline_feedback = true;
foreach ($results as $idx => $qresult) {
- if (! is_numeric($idx)) {
+ if (!is_numeric($idx)) {
continue;
}
@@ -92,16 +89,16 @@ protected function getResults(): ilTestResult
$workedthrough = (bool)$qresult['workedthrough'];
$answered = (bool)$qresult['answered'];
- $question_gui = $this->test_obj->createQuestionGUI("", $qid);
- $shuffle_trafo = $this->shuffler->getAnswerShuffleFor($qid, $this->active_id, $this->pass_id);
+ $question_gui = $test_obj->createQuestionGUI("", $qid);
+ $shuffle_trafo = $this->shuffler->getAnswerShuffleFor($qid, $active_id, $pass_id);
$question_gui->object->setShuffler($shuffle_trafo);
$graphical_output = true;
$show_correct_solution = false;
$show_inline_feedback = $settings->getShowFeedback();
$usr_solution = $question_gui->getSolutionOutput(
- $this->active_id,
- $this->pass_id,
+ $active_id,
+ $pass_id,
$graphical_output,
$result_output,
$show_question_only,
@@ -116,8 +113,8 @@ protected function getResults(): ilTestResult
$show_correct_solution = true;
$show_inline_feedback = false;
$best_solution = $question_gui->getSolutionOutput(
- $this->active_id,
- $this->pass_id,
+ $active_id,
+ $pass_id,
$graphical_output,
$result_output,
$show_question_only,
@@ -133,10 +130,10 @@ protected function getResults(): ilTestResult
$best_solution = $this->ui_renderer->render($this->ui_factory->legacy('
' . $best_solution . '
'));
}
- $feedback = $question_gui->getGenericFeedbackOutput($this->active_id, $this->pass_id);
+ $feedback = $question_gui->getGenericFeedbackOutput($active_id, $pass_id);
$recapitulation = null;
- if ($this->is_user_output && $settings->getShowRecapitulation()) {
+ if ($is_user_output && $settings->getShowRecapitulation()) {
$recapitulation = $question_gui->object->getSuggestedSolutionOutput();
}
@@ -155,23 +152,26 @@ protected function getResults(): ilTestResult
);
}
- return new ilTestResult(
- $this->active_id,
- $this->pass_id,
+ return new ilTestPassResult(
+ $settings,
+ $active_id,
+ $pass_id,
$question_results
);
}
- protected function getResultsSettings(): ilTestResultsSettings
- {
- $settings = $this->test_obj->getScoreSettings();
+ protected function getPassResultsSettings(
+ ilObjTest $test_obj,
+ bool $is_user_output
+ ): ilTestPassResultsSettings {
+ $settings = $test_obj->getScoreSettings();
$settings_summary = $settings->getResultSummarySettings();
$settings_result = $settings->getResultDetailsSettings();
- $show_best_solution = $this->is_user_output ?
+ $show_best_solution = $is_user_output ?
$settings_result->getShowSolutionListComparison() :
(bool)ilSession::get('tst_results_show_best_solutions');
- $environment = (new ilTestResultsSettings())
+ $pass_result_settings = (new ilTestPassResultsSettings())
->withShowHiddenQuestions(false)
->withShowOptionalQuestions(true)
->withShowBestSolution($show_best_solution)
@@ -179,22 +179,6 @@ protected function getResultsSettings(): ilTestResultsSettings
->withQuestionTextOnly($settings_result->getShowSolutionAnswersOnly())
->withShowRecapitulation($settings_result->getShowSolutionSuggested())
;
-
- return $environment;
- }
-
- public function getTable(string $title = ''): ilTestResultsOverviewTable
- {
- return new ilTestResultsOverviewTable(
- $this->ui_factory,
- $this->ui_renderer,
- $this->refinery,
- $this->http,
- $this->data_factory,
- $this->lng,
- $title,
- $this->getResults(),
- $this->getResultsSettings()
- );
+ return $pass_result_settings;
}
}
diff --git a/Modules/Test/classes/Results/class.ilTestResultsPresentationFactory.php b/Modules/Test/classes/Results/class.ilTestResultsPresentationFactory.php
new file mode 100644
index 000000000000..8857f76f379b
--- /dev/null
+++ b/Modules/Test/classes/Results/class.ilTestResultsPresentationFactory.php
@@ -0,0 +1,52 @@
+ui_factory,
+ $this->ui_renderer,
+ $this->refinery,
+ $this->http,
+ $this->data_factory,
+ $this->lng,
+ $pass_results,
+ $title
+ );
+ }
+}
diff --git a/Modules/Test/classes/class.ilTestDIC.php b/Modules/Test/classes/class.ilTestDIC.php
index ec8148186d1d..1673e4a99fa4 100644
--- a/Modules/Test/classes/class.ilTestDIC.php
+++ b/Modules/Test/classes/class.ilTestDIC.php
@@ -47,17 +47,26 @@ protected static function buildDIC(): Container
new ilTestResultsFactory(
$c['shuffler'],
$dic['ui.factory'],
- $dic['ui.renderer'],
- $dic['refinery'],
- new ILIAS\Data\Factory(),
- $dic['http'],
- $dic['lng']
+ $dic['ui.renderer']
);
+ $dic['factory.results_presentation'] = static fn($c): ilTestResultsPresentationFactory =>
+ new ilTestResultsPresentationFactory(
+ $dic['ui.factory'],
+ $dic['ui.renderer'],
+ $dic['refinery'],
+ new ILIAS\Data\Factory(),
+ $dic['http'],
+ $dic['lng']
+ );
+
+
$dic['participantAccessFilterFactory'] = static fn($c): ilTestParticipantAccessFilterFactory =>
new ilTestParticipantAccessFilterFactory($dic['ilAccess']);
+
$dic['manScoringDoneHelper'] = static fn($c): TestManScoringDoneHelper =>
new TestManScoringDoneHelper();
+
$dic['request.internal'] = static fn($c): InternalRequestService =>
new InternalRequestService($dic['http'], $dic['refinery']);
diff --git a/Modules/Test/classes/class.ilTestEvaluationGUI.php b/Modules/Test/classes/class.ilTestEvaluationGUI.php
index a1f098054471..28f0b957c166 100644
--- a/Modules/Test/classes/class.ilTestEvaluationGUI.php
+++ b/Modules/Test/classes/class.ilTestEvaluationGUI.php
@@ -911,9 +911,17 @@ public function outParticipantsPassDetails()
ilObjUser::_lookupFullname($this->object->_getUserIdFromActiveId($active_id))
);
- $results = $this->results_factory->for($this->object, $active_id, $pass, false);
+ $pass_results = $this->results_factory->getPassResultsFor(
+ $this->object,
+ $active_id,
+ $pass,
+ false
+ );
- $table = $results->getTable($title);
+ $table = $this->results_presentation_factory->getPassResultsPresentationTable(
+ $pass_results,
+ $title
+ );
$this->tpl->addCss(ilObjStyleSheet::getContentStylePath(0));
@@ -1168,8 +1176,18 @@ public function outUserPassDetails(): void
$pass + 1,
ilObjUser::_lookupFullname($this->object->_getUserIdFromActiveId($active_id))
);
- $results = $this->results_factory->for($this->object, $active_id, $pass, true);
- $table = $results->getTable($title);
+
+ $pass_results = $this->results_factory->getPassResultsFor(
+ $this->object,
+ $active_id,
+ $pass,
+ true
+ );
+
+ $table = $this->results_presentation_factory->getPassResultsPresentationTable(
+ $pass_results,
+ $title
+ );
$tpl->setVariable("LIST_OF_ANSWERS", $table->render());
diff --git a/Modules/Test/classes/class.ilTestServiceGUI.php b/Modules/Test/classes/class.ilTestServiceGUI.php
index 2e044ee09340..a9e8e58fcf06 100755
--- a/Modules/Test/classes/class.ilTestServiceGUI.php
+++ b/Modules/Test/classes/class.ilTestServiceGUI.php
@@ -160,6 +160,7 @@ public function __construct(
$this->participant_access_filter = $local_dic['participantAccessFilterFactory'];
$this->shuffler = $local_dic['shuffler'];
$this->results_factory = $local_dic['factory.results'];
+ $this->results_presentation_factory = $local_dic['factory.results_presentation'];
}
public function setParticipantData(ilTestParticipantData $participantData): void
diff --git a/Modules/Test/test/TestResultsSettingsTest.php b/Modules/Test/test/TestPassResultsSettingsTest.php
similarity index 95%
rename from Modules/Test/test/TestResultsSettingsTest.php
rename to Modules/Test/test/TestPassResultsSettingsTest.php
index 10679bd5be93..6576f259db47 100644
--- a/Modules/Test/test/TestResultsSettingsTest.php
+++ b/Modules/Test/test/TestPassResultsSettingsTest.php
@@ -26,7 +26,7 @@ class TestResultsSettingsTest extends TestCase
{
public function testTestResultsSettingsDefaults(): void
{
- $trs = new \ilTestResultsSettings();
+ $trs = new \ilTestPassResultsSettings();
$this->assertFalse($trs->getShowHiddenQuestions());
$this->assertFalse($trs->getShowOptionalQuestions());
$this->assertTrue($trs->getShowBestSolution());
@@ -37,7 +37,7 @@ public function testTestResultsSettingsDefaults(): void
public function testTestResultsSettingsBasicProps(): void
{
- $trs = new \ilTestResultsSettings();
+ $trs = new \ilTestPassResultsSettings();
$this->assertTrue($trs->withShowHiddenQuestions(true)->getShowHiddenQuestions());
$this->assertFalse($trs->withShowHiddenQuestions(false)->getShowHiddenQuestions());
$this->assertTrue($trs->withShowOptionalQuestions(true)->getShowOptionalQuestions());