19declare(strict_types=1);
31 private \ilDBInterface
$db;
35 return 'Migrate personal test template settings from tst_test_defaults to tst_test_settings';
45 return [new \ilDatabaseInitializedObjective()];
55 $row = $this->db->fetchAssoc(
56 $this->db->query(
"SELECT * FROM tst_test_defaults WHERE settings_id IS NULL LIMIT 1")
59 $settings_id = $this->db->nextId(
'tst_test_settings');
63 $raw_settings = unserialize($row[
'defaults'], [
'allowed_classes' => [\DateTimeImmutable::class]]);
64 foreach (self::SETTINGS_COLUMNS as $column_name => $column) {
65 [$column_def, $raw_name] = $column;
66 if (isset($raw_settings[$raw_name])) {
67 $value = $raw_settings[$raw_name];
69 if ($column_name ===
'reporting_date') {
73 $setting_data[$column_name] = [$column_def[
'type'], $value];
78 $this->db->insert(
'tst_test_settings', $setting_data);
86 $raw_marks = json_decode($row[
'marks'],
true);
87 foreach ($raw_marks as $mark_data) {
88 $mark_id = $this->db->nextId(
'tst_mark');
103 'tst_defaults_marks',
114 $result = $this->db->query(
"SELECT COUNT(test_defaults_id) AS cnt FROM tst_test_defaults WHERE settings_id IS NULL");
115 return (
int) $this->db->fetchObject($result)->cnt;
getDefaultAmountOfStepsPerRun()
Tell the default amount of steps to be executed for one run of the migration.
getPreconditions(Environment $environment)
Objectives the migration depend on.
getRemainingAmountOfSteps()
Count up how many "things" need to be migrated.
prepare(Environment $environment)
Prepare the migration by means of some environment.
step(Environment $environment)
Run one step of the migration.
An environment holds resources to be used in the setup process.
getResource(string $id)
Consumers of this method should check if the result is what they expect, e.g.
A migration is a potentially long lasting operation that can be broken into discrete steps.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
convertLegacyDate(string|\DateTimeImmutable|null $date)