19 declare(strict_types=1);
50 $result = $this->db->queryF(
51 "SELECT active_id FROM manscoring_done WHERE active_id = %s",
56 return $result->numRows() === 1;
61 return "Migrate manual scoring done setting from ilSettings db table to own table for improved performance";
98 $this->db->setLimit(self::TESTS_PER_STEP);
99 $result = $this->db->query(
100 "SELECT keyword, value FROM settings WHERE " . $this->db->like(
'keyword',
'text',
'manscoring_done_%')
102 while ($row = $this->db->fetchAssoc($result)) {
105 $keyword = $row[
"keyword"];
107 if (!preg_match(
'/manscoring_done_(\d+)$/', $keyword, $match)) {
110 $activeId = $match[1];
111 if (!is_numeric($activeId)) {
115 $activeId = (
int) $activeId;
118 $failed[$activeId] =
"Entry with active_id '$activeId' already exists in table '" . self::TABLE_NAME .
"'.";
122 if ((
int) $this->db->manipulateF(
123 "INSERT INTO " . self::TABLE_NAME .
" (active_id, done) VALUES (%s, %s)",
124 [
"integer",
"integer"],
125 [$activeId, (
int) $row[
"value"]]
127 $failed[$activeId] =
"Error occurred while trying to insert manscoring done status into new table ' " . self::TABLE_NAME .
"'.";
131 if ((
int) $this->db->manipulateF(
132 "DELETE FROM settings WHERE keyword = %s",
136 $failed[$activeId] =
"Error occurred while trying to delete manscoring done status '$keyword' from old table 'settings'.";
140 $success[] = $activeId;
146 $this->io->error($reason);
149 $successCount = count($success);
150 $failedCount = count($failed);
153 "Successfully migrated $successCount of $totalCount ($failedCount failed) entries " .
154 "from table 'settings' to table '" . self::TABLE_NAME .
"'." 160 $result = $this->db->query(
161 "SELECT COUNT(*) AS cnt FROM settings WHERE " . $this->db->like(
'keyword',
'text',
'manscoring_done_%')
163 $row = $this->db->fetchAssoc($result);
165 $num_legacy_tests = (
int) ($row[
'cnt'] ?? 0);
167 return (
int) ceil($num_legacy_tests / self::TESTS_PER_STEP);
getDefaultAmountOfStepsPerRun()
Tell the default amount of steps to be executed for one run of the migration.
step(Environment $environment)
Run one step of the migration.
A migration is a potentially long lasting operation that can be broken into discrete steps...
prepare(Environment $environment)
Prepare the migration by means of some environment.
getResource(string $id)
Consumers of this method should check if the result is what they expect, e.g.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
An environment holds resources to be used in the setup process.
getPreconditions(Environment $environment)
Objectives the migration depend on.
const RESOURCE_ADMIN_INTERACTION
manScoringDoneEntryExists(int $activeId)
getRemainingAmountOfSteps()
Count up how many "things" need to be migrated.