diff --git a/Modules/Test/classes/Setup/class.ilTestSetupAgent.php b/Modules/Test/classes/Setup/class.ilTestSetupAgent.php index 1f15f3403def..138c095d7862 100644 --- a/Modules/Test/classes/Setup/class.ilTestSetupAgent.php +++ b/Modules/Test/classes/Setup/class.ilTestSetupAgent.php @@ -26,6 +26,7 @@ use ILIAS\Refinery\Transformation; use ILIAS\Test\Setup\ilManScoringSettingsToOwnDbTableMigration; use ILIAS\Test\Setup\ilRemoveDynamicTestsAndCorrespondingDataMigration; +use ILIAS\Test\Setup\ilSeparateQuestionListSettingMigration; class ilTestSetupAgent extends NullAgent { @@ -65,7 +66,8 @@ public function getMigrations(): array { return [ new ilManScoringSettingsToOwnDbTableMigration(), - new ilRemoveDynamicTestsAndCorrespondingDataMigration() + new ilRemoveDynamicTestsAndCorrespondingDataMigration(), + new ilSeparateQuestionListSettingMigration() ]; } } diff --git a/Modules/Test/classes/Setup/ilSeparateQuestionListSettingMigration.php b/Modules/Test/classes/Setup/ilSeparateQuestionListSettingMigration.php new file mode 100644 index 000000000000..e0a8bd94de14 --- /dev/null +++ b/Modules/Test/classes/Setup/ilSeparateQuestionListSettingMigration.php @@ -0,0 +1,87 @@ +db = $environment->getResource(Setup\Environment::RESOURCE_DATABASE); + } + + /** + * @throws Exception + */ + public function step(Environment $environment): void + { + $this->db->manipulate( + 'UPDATE tst_tests SET show_questionlist = 1 WHERE show_summary > 0' + ); + + $this->db->manipulate( + 'UPDATE tst_tests SET show_questionlist = 0 WHERE show_summary = 0' + ); + } + + public function getRemainingAmountOfSteps(): int + { + $result = $this->db->query( + "SELECT count(*) as cnt FROM tst_tests WHERE show_questionlist is NULL" + ); + $row = $this->db->fetchAssoc($result); + + return (int) $row['cnt'] ?? 0; + } +}