19 declare(strict_types=1);
33 protected \ilResourceStorageMigrationHelper
$helper;
37 return "Migration of exercise instructions files to the resource storage service.";
47 return \ilResourceStorageMigrationHelper::getPreconditions();
52 $this->helper = new \ilResourceStorageMigrationHelper(
60 $r = $this->helper->getDatabase()->query(
61 "SELECT id, exc_id, owner FROM exc_assignment JOIN object_data ON exc_id = obj_id WHERE if_rcid IS NULL OR if_rcid = '' LIMIT 1;" 63 $d = $this->helper->getDatabase()->fetchObject(
$r);
68 $exec_id = (
int)
$d->exc_id;
69 $assignment_id = (
int)
$d->id;
70 $resource_owner_id = (
int)
$d->owner;
71 $base_path = $this->buildAbsolutPath($exec_id, $assignment_id);
72 if (is_dir($base_path)) {
73 $collection_id = $this->helper->moveFilesOfPathToCollection(
78 $collection = $this->helper->getCollectionBuilder()->new($resource_owner_id);
79 if ($this->helper->getCollectionBuilder()->store($collection)) {
80 $collection_id = $collection->getIdentification()->serialize();
82 throw new ilException(
"Could not build collection");
86 $this->helper->getDatabase()->update(
89 'if_rcid' => [
'text', $collection_id]
92 'id' => [
'integer', $assignment_id],
93 'exc_id' => [
'integer', $exec_id]
100 $r = $this->helper->getDatabase()->query(
101 "SELECT count(id) AS amount FROM exc_assignment JOIN object_data ON exc_id = obj_id WHERE if_rcid IS NULL OR if_rcid = ''" 103 $d = $this->helper->getDatabase()->fetchObject(
$r);
105 return (
int)
$d->amount;
115 ) .
"/ass_$assignment_id";
buildAbsolutPath(int $exec_id, int $assignment_id)
getPreconditions(Environment $environment)
Objectives the migration depend on.
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.
step(Environment $environment)
Run one step of the migration.
ilResourceStorageMigrationHelper $helper
static createPathFromId(int $a_container_id, string $a_name)
getRemainingAmountOfSteps()
Count up how many "things" need to be migrated.
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.
getDefaultAmountOfStepsPerRun()
Tell the default amount of steps to be executed for one run of the migration.