19declare(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 $db = $this->helper->getDatabase();
61 $r = $this->helper->getDatabase()->query(
62 "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;"
64 $d = $this->helper->getDatabase()->fetchObject($r);
65 $exec_id = (
int)
$d->exc_id;
66 $assignment_id = (
int)
$d->id;
67 $resource_owner_id = (
int)
$d->owner;
68 $base_path = $this->buildAbsolutPath($exec_id, $assignment_id);
69 if (is_dir($base_path)) {
70 $collection_id = $this->helper->moveFilesOfPathToCollection(
75 $collection = $this->helper->getCollectionBuilder()->new($resource_owner_id);
76 if ($this->helper->getCollectionBuilder()->store($collection)) {
77 $collection_id = $collection->getIdentification()->serialize();
79 throw new ilException(
"Could not build collection");
83 $this->helper->getDatabase()->update(
86 'if_rcid' => [
'text', $collection_id]
89 'id' => [
'integer', $assignment_id],
90 'exc_id' => [
'integer', $exec_id]
97 $r = $this->helper->getDatabase()->query(
98 "SELECT count(id) AS amount FROM exc_assignment JOIN object_data ON exc_id = obj_id WHERE if_rcid IS NULL OR if_rcid = ''"
100 $d = $this->helper->getDatabase()->fetchObject($r);
102 return (
int)
$d->amount;
112 ) .
"/ass_$assignment_id";
Class ResourceCollection.
Base class for ILIAS Exception handling.
getRemainingAmountOfSteps()
Count up how many "things" need to be migrated.
getPreconditions(Environment $environment)
Objectives the migration depend on.
ilResourceStorageMigrationHelper $helper
prepare(Environment $environment)
Prepare the migration by means of some environment.
getDefaultAmountOfStepsPerRun()
Tell the default amount of steps to be executed for one run of the migration.
buildAbsolutPath(int $exec_id, int $assignment_id)
step(Environment $environment)
Run one step of the migration.
static createPathFromId(int $a_container_id, string $a_name)
An environment holds resources to be used in the setup process.
A migration is a potentially long lasting operation that can be broken into discrete steps.