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

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, int $user_id)
 

Protected Attributes

ilResourceStorageMigrationHelper $helper
 

Additional Inherited Members

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

Detailed Description

Definition at line 24 of file class.ilExerciseSubmissionMigration.php.

Member Function Documentation

◆ buildAbsolutPath()

ilExerciseSubmissionMigration::buildAbsolutPath ( int  $exec_id,
int  $assignment_id,
int  $user_id 
)
protected

Definition at line 97 of file class.ilExerciseSubmissionMigration.php.

References $user_id, CLIENT_DATA_DIR, and ilFileSystemAbstractionStorage\createPathFromId().

Referenced by step().

97  : string
98  {
99  // ilExercise/X/exc_*EXC_ID*/subm_*ASS_ID*/*USER_ID*/*TIMESTAMP*_filename.pdf
100  return CLIENT_DATA_DIR
101  . '/ilExercise/'
103  $exec_id,
104  "exc"
105  ) . "/subm_$assignment_id/" . $user_id;
106  }
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:
+ Here is the caller graph for this function:

◆ getDefaultAmountOfStepsPerRun()

ilExerciseSubmissionMigration::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 33 of file class.ilExerciseSubmissionMigration.php.

33  : int
34  {
35  return 1000;
36  }

◆ getLabel()

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

Implements ILIAS\Setup\Migration.

Definition at line 28 of file class.ilExerciseSubmissionMigration.php.

28  : string
29  {
30  return "Migration of exercise submission to the resource storage service.";
31  }

◆ getPreconditions()

ilExerciseSubmissionMigration::getPreconditions ( Environment  $environment)

Objectives the migration depend on.

Exceptions
UnachievableExceptionif the objective is not achievable
Returns
Objective[]

Implements ILIAS\Setup\Migration.

Definition at line 38 of file class.ilExerciseSubmissionMigration.php.

38  : array
39  {
40  return \ilResourceStorageMigrationHelper::getPreconditions();
41  }

◆ getRemainingAmountOfSteps()

ilExerciseSubmissionMigration::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 87 of file class.ilExerciseSubmissionMigration.php.

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

87  : int
88  {
89  $r = $this->helper->getDatabase()->query(
90  "SELECT count(er.returned_id) as amount FROM exc_returned er JOIN object_data od ON er.obj_id = od.obj_id WHERE er.rid IS NULL;"
91  );
92  $d = $this->helper->getDatabase()->fetchObject($r);
93 
94  return (int) $d->amount;
95  }
$r

◆ prepare()

ilExerciseSubmissionMigration::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 43 of file class.ilExerciseSubmissionMigration.php.

43  : void
44  {
45  $this->helper = new \ilResourceStorageMigrationHelper(
47  $environment
48  );
49  }

◆ step()

ilExerciseSubmissionMigration::step ( Environment  $environment)

Run one step of the migration.

Implements ILIAS\Setup\Migration.

Definition at line 51 of file class.ilExerciseSubmissionMigration.php.

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

51  : void
52  {
53  $db = $this->helper->getDatabase();
54  $r = $db->query(
55  "SELECT er.returned_id, er.obj_id, er.ass_id, od.owner, er.user_id, er.team_id FROM exc_returned er JOIN object_data od ON er.obj_id = od.obj_id WHERE er.rid IS NULL LIMIT 1;"
56  );
57  $d = $this->helper->getDatabase()->fetchObject($r);
58  $exec_id = (int) $d->obj_id;
59  $assignment_id = (int) $d->ass_id;
60  $returned_id = (int) $d->returned_id;
61  $resource_owner_id = (int) $d->owner;
62  $user_id = ((int) $d->team_id) > 0
63  ? (int) $d->team_id
64  : (int) $d->user_id;
65  $base_path = $this->buildAbsolutPath($exec_id, $assignment_id, $user_id);
66  $pattern = '/[^\.].*/m';
67  $rid = "";
68  if (is_dir($base_path)) {
69  $rid = $this->helper->moveFirstFileOfPatternToStorage(
70  $base_path,
71  $pattern,
72  $resource_owner_id
73  );
74  }
75  $this->helper->getDatabase()->update(
76  'exc_returned',
77  [
78  'rid' => ['text', (string) $rid]
79  ],
80  [
81  'ass_id' => ['integer', $assignment_id],
82  'returned_id' => ['integer', $returned_id]
83  ]
84  );
85  }
buildAbsolutPath(int $exec_id, int $assignment_id, int $user_id)
$r
+ Here is the call graph for this function:

Field Documentation

◆ $helper

ilResourceStorageMigrationHelper ilExerciseSubmissionMigration::$helper
protected

Definition at line 26 of file class.ilExerciseSubmissionMigration.php.


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