19declare(strict_types=1);
42 return 'Migration of SCORM/AICC Learning Modules to the Resource Storage Service.';
56 new \
ILIAS\ScormAicc\Setup\ScormAiccDatabaseUpdateSteps()
68 $io = $environment->
getResource(Environment::RESOURCE_ADMIN_INTERACTION);
76 $r = $this->helper->getDatabase()->query(
77 "SELECT lm.id, object_data.owner AS owner_id
78 FROM " . self::TABLE_NAME .
" lm
79 LEFT JOIN object_data ON object_data.obj_id = lm.id
80 WHERE rid IS NULL OR rid = ''
84 $d = $this->helper->getDatabase()->fetchObject($r);
85 $object_id = (
int) (
$d->id ??
null);
87 $resource_owner_id = (
int) (
$d->owner_id ?? 6);
91 if (!is_dir($lm_path)) {
93 "Legacy SCORM/AICC directory $lm_path for object id $object_id does not exist. " .
94 "Marking record as migration-failed (rid='-')."
96 $this->helper->getDatabase()->update(
98 [
'rid' => [
'text',
'-']],
99 [
'id' => [
'integer', $object_id],]
106 "Trying to move SCORM/AICC directory $lm_path for object id $object_id to the storage service."
108 $rid = $this->helper->moveDirectoryToContainerResource(
112 $this->
inform(
"Migration proceeded without error for object id $object_id.");
113 }
catch (\Throwable
$e) {
115 "Failed to move SCORM/AICC directory $lm_path for object id $object_id " .
116 "to the storage service with exception: {$e->getMessage()}"
118 $this->
error($e->getTraceAsString());
124 "IRSS identification for object id $object_id: {$rid->serialize()}",
127 $this->helper->getDatabase()->update(
129 [
'rid' => [
'text', $rid->serialize()]],
130 [
'id' => [
'integer', $object_id],]
136 'IRSS returned NULL as identification when trying to move SCORM/AICC directory ' .
137 "$lm_path for object id $object_id to the storage service."
139 $this->helper->getDatabase()->update(
141 [
'rid' => [
'text',
'-']],
142 [
'id' => [
'integer', $object_id],]
149 if (!is_dir($path)) {
153 $files = array_diff(scandir($path), [
'.',
'..']);
154 foreach (
$files as $file) {
155 (is_dir(
"$path/$file")) ? $this->
recursiveRmDir(
"$path/$file") : unlink(
"$path/$file");
162 $r = $this->helper->getDatabase()->query(
163 "SELECT COUNT(id) AS amount FROM " . self::TABLE_NAME .
" WHERE rid IS NULL OR rid = ''"
165 $d = $this->helper->getDatabase()->fetchObject($r) ??
new stdClass();
167 return (
int) (
$d->amount ?? 0);
177 if ($this->io ===
null || (!$force && !$this->io->isVerbose())) {
181 $this->io->inform(
$text);
186 if ($this->io ===
null) {
190 $this->io->error(
$text);
Wrapper around symfonies input and output facilities to provide just the functionality required for t...
This class attempt to achieve a set of database update steps.
Class ilResourceStorageMigrationHelper.
static getPreconditions()
Moves the on-disk content of SCORM/AICC learning modules (public/data/lm_data/lm_<id>) into a contain...
inform(string $text, bool $force=false)
recursiveRmDir(string $path)
prepare(Environment $environment)
Prepare the migration by means of some environment.
getPreconditions(Environment $environment)
Objectives the migration depend on.
buildBasePath(int $object_id)
step(Environment $environment)
Run one step of the migration.
getRemainingAmountOfSteps()
Count up how many "things" need to be migrated.
ilResourceStorageMigrationHelper $helper
getDefaultAmountOfStepsPerRun()
Tell the default amount of steps to be executed for one run of the migration.
Stakeholder for SCORM/AICC learning module content (table sahs_lm).
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.
Interface Observer \BackgroundTasks Contains several chained tasks and infos about them.