19 declare(strict_types=1);
29 protected \ilResourceStorageMigrationHelper
$helper;
33 return "Migration of exercise sample solutions to the resource storage service.";
43 return \ilResourceStorageMigrationHelper::getPreconditions();
48 $this->helper = new \ilResourceStorageMigrationHelper(
56 $db = $this->helper->getDatabase();
57 $r = $this->helper->getDatabase()->query(
58 "SELECT id, exc_id, owner FROM exc_assignment JOIN object_data ON exc_id = obj_id WHERE solution_rid IS NULL LIMIT 1;" 60 $d = $this->helper->getDatabase()->fetchObject(
$r);
61 $exec_id = (
int)
$d->exc_id;
62 $assignment_id = (
int)
$d->id;
63 $resource_owner_id = (
int)
$d->owner;
64 $base_path = $this->buildAbsolutPath($exec_id, $assignment_id);
65 $pattern =
'/[^\.].*/m';
67 if (is_dir($base_path)) {
68 $rid = $this->helper->moveFirstFileOfPatternToStorage(
74 $this->helper->getDatabase()->update(
77 'solution_rid' => [
'text', (
string) $rid]
80 'id' => [
'integer', $assignment_id],
81 'exc_id' => [
'integer', $exec_id]
88 $r = $this->helper->getDatabase()->query(
89 "SELECT count(id) AS amount FROM exc_assignment JOIN object_data ON exc_id = obj_id WHERE solution_rid IS NULL" 91 $d = $this->helper->getDatabase()->fetchObject(
$r);
93 return (
int)
$d->amount;
103 ) .
"/feedb_$assignment_id/0";
getDefaultAmountOfStepsPerRun()
Tell the default amount of steps to be executed for one run of the migration.
A migration is a potentially long lasting operation that can be broken into discrete steps...
static createPathFromId(int $a_container_id, string $a_name)
buildAbsolutPath(int $exec_id, int $assignment_id)
ilResourceStorageMigrationHelper $helper
getRemainingAmountOfSteps()
Count up how many "things" need to be migrated.
An environment holds resources to be used in the setup process.
prepare(Environment $environment)
Prepare the migration by means of some environment.
getPreconditions(Environment $environment)
Objectives the migration depend on.
step(Environment $environment)
Run one step of the migration.