diff --git a/Modules/Test/classes/ScoreReporting/class.ilObjTestScoreSettingsDatabaseRepository.php b/Modules/Test/classes/ScoreReporting/class.ilObjTestScoreSettingsDatabaseRepository.php index 387f51b4cbb4..12a897d3b090 100644 --- a/Modules/Test/classes/ScoreReporting/class.ilObjTestScoreSettingsDatabaseRepository.php +++ b/Modules/Test/classes/ScoreReporting/class.ilObjTestScoreSettingsDatabaseRepository.php @@ -70,7 +70,8 @@ protected function doSelect(string $where_part): ilObjTestScoreSettings if ($reporting_date) { $reporting_date = \DateTimeImmutable::createFromFormat( self::STORAGE_DATE_FORMAT, - $reporting_date + $reporting_date, + new DateTimeZone('UTC') ); } else { $reporting_date = null; diff --git a/Modules/Test/classes/ScoreReporting/ilObjTestSettingsResultSummary.php b/Modules/Test/classes/ScoreReporting/ilObjTestSettingsResultSummary.php index b7b6e3118c5f..cd1a855423ae 100644 --- a/Modules/Test/classes/ScoreReporting/ilObjTestSettingsResultSummary.php +++ b/Modules/Test/classes/ScoreReporting/ilObjTestSettingsResultSummary.php @@ -70,8 +70,13 @@ function ($v) { self::SCORE_REPORTING_DATE => $f->group( [ $f->dateTime($lng->txt('tst_reporting_date'), "") + ->withTimezone($environment['user_time_zone']) ->withUseTime(true) - ->withValue($this->getReportingDate()) + ->withValue( + $this->getReportingDate()?->setTimezone( + new DateTimeZone($environment['user_time_zone']) + )->format($environment['user_date_format']) + ) ->withRequired(true) ], $lng->txt('tst_results_access_date'), @@ -156,7 +161,8 @@ public function toStorage(): array { $dat = $this->getReportingDate(); if ($dat) { - $dat = $dat->format(ilObjTestScoreSettingsDatabaseRepository::STORAGE_DATE_FORMAT); + $dat = $dat->setTimezone(new DateTimeZone('UTC')) + ->format(ilObjTestScoreSettingsDatabaseRepository::STORAGE_DATE_FORMAT); } return [ 'pass_deletion_allowed' => ['integer', (int) $this->getPassDeletionAllowed()], diff --git a/Modules/Test/classes/class.ilObjTestGUI.php b/Modules/Test/classes/class.ilObjTestGUI.php index 50db44f088c3..a5ba87109b0a 100755 --- a/Modules/Test/classes/class.ilObjTestGUI.php +++ b/Modules/Test/classes/class.ilObjTestGUI.php @@ -453,7 +453,11 @@ public function executeCommand(): void $ilTabs, $this->getTestObject()->getScoreSettingsRepository(), $this->getTestObject()->getTestId(), - ...$this->ui + $this->ui[0], + $this->ui[1], + $this->ui[2], + $this->ui[3], + $this->user ); $this->ctrl->forwardCommand($gui); diff --git a/Modules/Test/classes/class.ilObjTestSettingsScoringResultsGUI.php b/Modules/Test/classes/class.ilObjTestSettingsScoringResultsGUI.php index 472b25a3eaed..c0804df46c15 100644 --- a/Modules/Test/classes/class.ilObjTestSettingsScoringResultsGUI.php +++ b/Modules/Test/classes/class.ilObjTestSettingsScoringResultsGUI.php @@ -21,7 +21,6 @@ use ILIAS\UI\Factory as UIFactory; use ILIAS\UI\Renderer as UIRenderer; use ILIAS\Refinery\Factory as Refinery; -use ILIAS\UI\Component\Input\Field; use ILIAS\UI\Component\Input\Container\Form\Form; use Psr\Http\Message\ServerRequestInterface as Request; @@ -63,6 +62,7 @@ class ilObjTestSettingsScoringResultsGUI extends ilTestSettingsGUI protected UIRenderer $ui_renderer; protected Refinery $refinery; protected ilTabsGUI $tabs; + protected ilObjUser $active_user; public function __construct( @@ -80,7 +80,8 @@ public function __construct( UIFactory $ui_factory, UIRenderer $ui_renderer, Refinery $refinery, - Request $request + Request $request, + ilObjUser $active_user ) { $this->ctrl = $ctrl; $this->access = $access; @@ -92,6 +93,7 @@ public function __construct( $this->testOBJ = $testGUI->getObject(); $this->tpl = $main_template; $this->tabs = $tabs; + $this->active_user = $active_user; $this->testQuestionSetConfigFactory = new ilTestQuestionSetConfigFactory( $this->tree, @@ -223,14 +225,30 @@ private function buildForm(): Form $this->refinery ]; - $anonymity_flag = (bool) $this->testOBJ->getAnonymity(); + $environment = []; + $df = (new \ILIAS\Data\Factory())->dateFormat(); + switch ($this->active_user->getDateFormat()) { + case ilCalendarSettings::DATE_FORMAT_DMY: + $date_format = $df->germanShort(); + break; + case ilCalendarSettings::DATE_FORMAT_MDY: + //americanShort + $date_format = $df->custom()->month()->slash()->day()->slash()->year()->get(); + break; + case ilCalendarSettings::DATE_FORMAT_YMD: + default: + $date_format = $df->standard(); + } + $environment['user_date_format'] = $date_format->toString() . 'H:i'; + $environment['user_time_zone'] = $this->active_user->getTimeZone(); + $disabled_flag = ($this->areScoringSettingsWritable() === false); $settings = $this->loadScoreSettings(); $sections = [ 'scoring' => $settings->getScoringSettings()->toForm(...$ui_pack) ->withDisabled($disabled_flag), - 'summary' => $settings->getResultSummarySettings()->toForm(...$ui_pack), + 'summary' => $settings->getResultSummarySettings()->toForm(...array_merge($ui_pack, [$environment])), 'details' => $settings->getResultDetailsSettings()->toForm( ...array_merge($ui_pack, [['taxonomy_options' => $this->getTaxonomyOptions()]]) ), diff --git a/Modules/Test/test/ScoreSettingsTest.php b/Modules/Test/test/ScoreSettingsTest.php index 764c1a575928..e32db4997cb0 100644 --- a/Modules/Test/test/ScoreSettingsTest.php +++ b/Modules/Test/test/ScoreSettingsTest.php @@ -160,7 +160,7 @@ public function testScoreSettingsSectionScoring(): void $expected = <<

test_scoring

- +
@@ -185,7 +185,7 @@ public function testScoreSettingsSectionScoring(): void
- +
@@ -259,7 +259,12 @@ public function testScoreSettingsSectionSummary(): void $s = new ilObjTestSettingsResultSummary(666); $actual = $this->getDefaultRenderer()->render( - $s->toForm(...$ui) + $s->toForm(...array_merge($ui, [[ + 'user_time_zone' => 'Europe/Berlin', + 'user_date_format' => $data_factory->dateFormat()->withTime24( + $data_factory->dateFormat()->standard() + ) + ]])) ); $expected = <<
- +
@@ -474,13 +479,13 @@ public function testScoreSettingsSectionGamification(): void

tst_results_gamification

- +
tst_highscore_description
- +
@@ -513,7 +518,7 @@ public function testScoreSettingsSectionGamification(): void
tst_highscore_top_num_description
- +
@@ -556,7 +561,7 @@ public function testScoreSettingsSectionGamification(): void
tst_highscore_wtime_description
- +
diff --git a/Modules/Test/test/ilObjTestSettingsScoringResultsGUITest.php b/Modules/Test/test/ilObjTestSettingsScoringResultsGUITest.php index ec2ae577a196..6137528ca60d 100644 --- a/Modules/Test/test/ilObjTestSettingsScoringResultsGUITest.php +++ b/Modules/Test/test/ilObjTestSettingsScoringResultsGUITest.php @@ -80,7 +80,8 @@ public function testScoringResultsGUIConstruct(): void $ui_factory, $ui_renderer, $refinery, - $request + $request, + $this->getMockBuilder(ilObjUser::class)->disableOriginalConstructor()->getMock(), ); $this->assertInstanceOf(ilObjTestSettingsScoringResultsGUI::class, $this->testObj);