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

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

Definition at line 27 of file class.ilExerciseSampleSolutionMigration.php.

Member Function Documentation

◆ buildAbsolutPath()

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

Definition at line 96 of file class.ilExerciseSampleSolutionMigration.php.

References CLIENT_DATA_DIR, and ilFileSystemAbstractionStorage\createPathFromId().

96  : string
97  {
98  return CLIENT_DATA_DIR
99  . '/ilExercise/'
101  $exec_id,
102  "exc"
103  ) . "/feedb_$assignment_id/0";
104  }
const CLIENT_DATA_DIR
Definition: constants.php:46
static createPathFromId(int $a_container_id, string $a_name)
+ Here is the call graph for this function:

◆ getDefaultAmountOfStepsPerRun()

ilExerciseSampleSolutionMigration::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 36 of file class.ilExerciseSampleSolutionMigration.php.

36  : int
37  {
38  return 1000;
39  }

◆ getLabel()

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

Implements ILIAS\Setup\Migration.

Definition at line 31 of file class.ilExerciseSampleSolutionMigration.php.

31  : string
32  {
33  return "Migration of exercise sample solutions to the resource storage service.";
34  }

◆ getPreconditions()

ilExerciseSampleSolutionMigration::getPreconditions ( Environment  $environment)

Objectives the migration depend on.

Exceptions
UnachievableExceptionif the objective is not achievable
Returns
Objective[]

Implements ILIAS\Setup\Migration.

Definition at line 41 of file class.ilExerciseSampleSolutionMigration.php.

41  : array
42  {
43  return \ilResourceStorageMigrationHelper::getPreconditions();
44  }

◆ getRemainingAmountOfSteps()

ilExerciseSampleSolutionMigration::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 86 of file class.ilExerciseSampleSolutionMigration.php.

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

86  : int
87  {
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"
90  );
91  $d = $this->helper->getDatabase()->fetchObject($r);
92 
93  return (int) $d->amount;
94  }
$r

◆ prepare()

ilExerciseSampleSolutionMigration::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 46 of file class.ilExerciseSampleSolutionMigration.php.

46  : void
47  {
48  $this->helper = new \ilResourceStorageMigrationHelper(
50  $environment
51  );
52  }

◆ step()

ilExerciseSampleSolutionMigration::step ( Environment  $environment)

Run one step of the migration.

Implements ILIAS\Setup\Migration.

Definition at line 54 of file class.ilExerciseSampleSolutionMigration.php.

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

54  : void
55  {
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;"
59  );
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';
66  $rid = "";
67  if (is_dir($base_path)) {
68  $rid = $this->helper->moveFirstFileOfPatternToStorage(
69  $base_path,
70  $pattern,
71  $resource_owner_id
72  );
73  }
74  $this->helper->getDatabase()->update(
75  'exc_assignment',
76  [
77  'solution_rid' => ['text', (string) $rid]
78  ],
79  [
80  'id' => ['integer', $assignment_id],
81  'exc_id' => ['integer', $exec_id]
82  ]
83  );
84  }
$r
+ Here is the call graph for this function:

Field Documentation

◆ $helper

ilResourceStorageMigrationHelper ilExerciseSampleSolutionMigration::$helper
protected

Definition at line 29 of file class.ilExerciseSampleSolutionMigration.php.


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