ILIAS  trunk Revision v11.0_alpha-1749-g1a06bdef097
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
ilExerciseInstructionFilesMigration Class Reference
+ Inheritance diagram for ilExerciseInstructionFilesMigration:
+ Collaboration diagram for ilExerciseInstructionFilesMigration:

Public Member Functions

 getLabel ()
 
 getDefaultAmountOfStepsPerRun ()
 Tell the default amount of steps to be executed for one run of the migration. More...
 
 getPreconditions (Environment $environment)
 Objectives the migration depend on. More...
 
 prepare (Environment $environment)
 Prepare the migration by means of some environment. More...
 
 step (Environment $environment)
 Run one step of the migration. More...
 
 getRemainingAmountOfSteps ()
 Count up how many "things" need to be migrated. More...
 

Protected Member Functions

 buildAbsolutPath (int $exec_id, int $assignment_id)
 

Protected Attributes

ilResourceStorageMigrationHelper $helper
 

Additional Inherited Members

- Data Fields inherited from ILIAS\Setup\Migration
const INFINITE = -1
 

Detailed Description

Member Function Documentation

◆ buildAbsolutPath()

ilExerciseInstructionFilesMigration::buildAbsolutPath ( int  $exec_id,
int  $assignment_id 
)
protected

Definition at line 105 of file class.ilExerciseInstructionFilesMigration.php.

References CLIENT_WEB_DIR, and ilFileSystemAbstractionStorage\createPathFromId().

105  : string
106  {
107  return CLIENT_WEB_DIR
108  . '/ilExercise/'
110  $exec_id,
111  "exc"
112  ) . "/ass_$assignment_id";
113  }
static createPathFromId(int $a_container_id, string $a_name)
const CLIENT_WEB_DIR
Definition: constants.php:47
+ Here is the call graph for this function:

◆ getDefaultAmountOfStepsPerRun()

ilExerciseInstructionFilesMigration::getDefaultAmountOfStepsPerRun ( )

Tell the default amount of steps to be executed for one run of the migration.

Return Migration::INFINITE if all units should be migrated at once.

Implements ILIAS\Setup\Migration.

Definition at line 40 of file class.ilExerciseInstructionFilesMigration.php.

40  : int
41  {
42  return 1000;
43  }

◆ getLabel()

ilExerciseInstructionFilesMigration::getLabel ( )
Returns
string - a meaningful and concise description for your migration.

Implements ILIAS\Setup\Migration.

Definition at line 35 of file class.ilExerciseInstructionFilesMigration.php.

35  : string
36  {
37  return "Migration of exercise instructions files to the resource storage service.";
38  }

◆ getPreconditions()

ilExerciseInstructionFilesMigration::getPreconditions ( Environment  $environment)

Objectives the migration depend on.

Exceptions
UnachievableExceptionif the objective is not achievable
Returns
Objective[]

Implements ILIAS\Setup\Migration.

Definition at line 45 of file class.ilExerciseInstructionFilesMigration.php.

45  : array
46  {
47  return \ilResourceStorageMigrationHelper::getPreconditions();
48  }

◆ getRemainingAmountOfSteps()

ilExerciseInstructionFilesMigration::getRemainingAmountOfSteps ( )

Count up how many "things" need to be migrated.

This helps the admin to decide how big he can create the steps and also how long a migration takes

Implements ILIAS\Setup\Migration.

Definition at line 95 of file class.ilExerciseInstructionFilesMigration.php.

References Vendor\Package\$d, and $r.

95  : int
96  {
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 = ''"
99  );
100  $d = $this->helper->getDatabase()->fetchObject($r);
101 
102  return (int) $d->amount;
103  }
$r

◆ prepare()

ilExerciseInstructionFilesMigration::prepare ( Environment  $environment)

Prepare the migration by means of some environment.

This is not supposed to modify the environment, but will be run to prime the migration object to run step and getRemainingAmountOfSteps afterwards.

Implements ILIAS\Setup\Migration.

Definition at line 50 of file class.ilExerciseInstructionFilesMigration.php.

50  : void
51  {
52  $this->helper = new \ilResourceStorageMigrationHelper(
54  $environment
55  );
56  }

◆ step()

ilExerciseInstructionFilesMigration::step ( Environment  $environment)

Run one step of the migration.

Implements ILIAS\Setup\Migration.

Definition at line 58 of file class.ilExerciseInstructionFilesMigration.php.

References Vendor\Package\$d, $r, and ILIAS\Repository\int().

58  : void
59  {
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;"
63  );
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(
71  $base_path,
72  $resource_owner_id
73  );
74  } else {
75  $collection = $this->helper->getCollectionBuilder()->new($resource_owner_id);
76  if ($this->helper->getCollectionBuilder()->store($collection)) {
77  $collection_id = $collection->getIdentification()->serialize();
78  } else {
79  throw new ilException("Could not build collection");
80  }
81  }
82 
83  $this->helper->getDatabase()->update(
84  'exc_assignment',
85  [
86  'if_rcid' => ['text', $collection_id]
87  ],
88  [
89  'id' => ['integer', $assignment_id],
90  'exc_id' => ['integer', $exec_id]
91  ]
92  );
93  }
$r
+ Here is the call graph for this function:

Field Documentation

◆ $helper

ilResourceStorageMigrationHelper ilExerciseInstructionFilesMigration::$helper
protected

The documentation for this class was generated from the following file: