ILIAS  trunk Revision v12.0_alpha-16-g3e876e53c80
ILIAS\Test\Setup\RemoveLegacyTestSettingsMigration Class Reference
+ Inheritance diagram for ILIAS\Test\Setup\RemoveLegacyTestSettingsMigration:
+ Collaboration diagram for ILIAS\Test\Setup\RemoveLegacyTestSettingsMigration:

Public Member Functions

 getLabel ()
 
 getDefaultAmountOfStepsPerRun ()
 Tell the default amount of steps to be executed for one run of the migration. More...
 
 getPreconditions (Environment $environment)
 Objectives the migration depend on. More...
 
 prepare (Environment $environment)
 Prepare the migration by means of some environment. More...
 
 step (Environment $environment)
 Run one step of the migration. More...
 
 getRemainingAmountOfSteps ()
 Count up how many "things" need to be migrated. More...
 
 getLabel ()
 
 getDefaultAmountOfStepsPerRun ()
 Tell the default amount of steps to be executed for one run of the migration. More...
 
 getPreconditions (Environment $environment)
 Objectives the migration depend on. More...
 
 prepare (Environment $environment)
 Prepare the migration by means of some environment. More...
 
 step (Environment $environment)
 Run one step of the migration. More...
 
 getRemainingAmountOfSteps ()
 Count up how many "things" need to be migrated. More...
 

Private Member Functions

 dropColumn (string $table, string $column)
 

Private Attributes

const array UNUSED_LEGACY_COLUMNS
 
ilDBInterface $db
 
bool $data_loss_detected = false
 

Additional Inherited Members

- Data Fields inherited from ILIAS\Setup\Migration
const INFINITE = -1
 

Detailed Description

Definition at line 27 of file RemoveLegacyTestSettingsMigration.php.

Member Function Documentation

◆ dropColumn()

ILIAS\Test\Setup\RemoveLegacyTestSettingsMigration::dropColumn ( string  $table,
string  $column 
)
private

Definition at line 111 of file RemoveLegacyTestSettingsMigration.php.

111 : void
112 {
113 if ($this->db->tableColumnExists($table, $column)) {
114 $this->db->dropTableColumn($table, $column);
115 }
116 }

Referenced by ILIAS\Test\Setup\RemoveLegacyTestSettingsMigration\step().

+ Here is the caller graph for this function:

◆ getDefaultAmountOfStepsPerRun()

ILIAS\Test\Setup\RemoveLegacyTestSettingsMigration::getDefaultAmountOfStepsPerRun ( )

Tell the default amount of steps to be executed for one run of the migration.

Return Migration::INFINITE if all units should be migrated at once.

Implements ILIAS\Setup\Migration.

Definition at line 56 of file RemoveLegacyTestSettingsMigration.php.

56 : int
57 {
58 return 1;
59 }

◆ getLabel()

ILIAS\Test\Setup\RemoveLegacyTestSettingsMigration::getLabel ( )
Returns
string - a meaningful and concise description for your migration.

Implements ILIAS\Setup\Migration.

Definition at line 51 of file RemoveLegacyTestSettingsMigration.php.

51 : string
52 {
53 return 'Remove columns from tst_tests and tst_test_defaults that are now in tst_test_settings';
54 }

◆ getPreconditions()

ILIAS\Test\Setup\RemoveLegacyTestSettingsMigration::getPreconditions ( Environment  $environment)

Objectives the migration depend on.

Exceptions
UnachievableExceptionif the objective is not achievable
Returns
Objective[]

Implements ILIAS\Setup\Migration.

Definition at line 61 of file RemoveLegacyTestSettingsMigration.php.

61 : array
62 {
63 return [
64 new \ilDatabaseInitializedObjective(),
65 ];
66 }

◆ getRemainingAmountOfSteps()

ILIAS\Test\Setup\RemoveLegacyTestSettingsMigration::getRemainingAmountOfSteps ( )

Count up how many "things" need to be migrated.

This helps the admin to decide how big he can create the steps and also how long a migration takes

Implements ILIAS\Setup\Migration.

Definition at line 104 of file RemoveLegacyTestSettingsMigration.php.

104 : int
105 {
106 return (int) ($this->db->tableColumnExists('tst_tests', array_key_first(self::SETTINGS_COLUMNS))
107 || $this->db->tableColumnExists('tst_tests', self::UNUSED_LEGACY_COLUMNS[0])
108 || $this->db->tableColumnExists('tst_test_defaults', 'defaults'));
109 }

◆ prepare()

ILIAS\Test\Setup\RemoveLegacyTestSettingsMigration::prepare ( Environment  $environment)

Prepare the migration by means of some environment.

This is not supposed to modify the environment, but will be run to prime the migration object to run step and getRemainingAmountOfSteps afterwards.

Implements ILIAS\Setup\Migration.

Definition at line 68 of file RemoveLegacyTestSettingsMigration.php.

68 : void
69 {
70 $this->db = $environment->getResource(Setup\Environment::RESOURCE_DATABASE);
71
72 $move_settings = new MoveTestSettingsMigration();
73 $move_settings->prepare($environment);
74 if ($move_settings->getRemainingAmountOfSteps() > 0) {
75 $this->data_loss_detected = true;
76 return;
77 }
78
79 $move_templates = new MoveSettingsTemplatesMigration();
80 $move_templates->prepare($environment);
81 if ($move_templates->getRemainingAmountOfSteps() > 0) {
82 $this->data_loss_detected = true;
83 return;
84 }
85 }

References ILIAS\Setup\Environment\getResource(), and ILIAS\Setup\Environment\RESOURCE_DATABASE.

+ Here is the call graph for this function:

◆ step()

ILIAS\Test\Setup\RemoveLegacyTestSettingsMigration::step ( Environment  $environment)

Run one step of the migration.

Implements ILIAS\Setup\Migration.

Definition at line 87 of file RemoveLegacyTestSettingsMigration.php.

87 : void
88 {
89 if ($this->data_loss_detected) {
90 throw new Setup\UnachievableException(
91 'Failed to remove legacy test settings. Please run MoveTestSettingsMigration and MoveSettingsTemplatesMigration first.'
92 );
93 }
94
95 $test_columns = array_merge(array_keys(self::SETTINGS_COLUMNS), self::UNUSED_LEGACY_COLUMNS);
96 foreach ($test_columns as $column) {
97 $this->dropColumn('tst_tests', $column);
98 }
99
100 $this->dropColumn('tst_test_defaults', 'marks');
101 $this->dropColumn('tst_test_defaults', 'defaults');
102 }

References ILIAS\Test\Setup\RemoveLegacyTestSettingsMigration\dropColumn().

+ Here is the call graph for this function:

Field Documentation

◆ $data_loss_detected

bool ILIAS\Test\Setup\RemoveLegacyTestSettingsMigration::$data_loss_detected = false
private

Definition at line 49 of file RemoveLegacyTestSettingsMigration.php.

◆ $db

ilDBInterface ILIAS\Test\Setup\RemoveLegacyTestSettingsMigration::$db
private

Definition at line 48 of file RemoveLegacyTestSettingsMigration.php.

◆ UNUSED_LEGACY_COLUMNS

const array ILIAS\Test\Setup\RemoveLegacyTestSettingsMigration::UNUSED_LEGACY_COLUMNS
private
Initial value:
= [
'ects_output',
'ects_fx',
'ects_a',
'ects_b',
'ects_c',
'ects_d',
'ects_e',
'keep_questions',
'mc_scoring',
'show_question_titles',
'certificate_visibility',
'resultoutput',
'pool_usage',
'info_screen',
]

Definition at line 31 of file RemoveLegacyTestSettingsMigration.php.


The documentation for this class was generated from the following file: