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

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 $peer_id, int $giver_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.ilExercisePeerFeedbackMigration.php.

Member Function Documentation

◆ buildAbsolutPath()

ilExercisePeerFeedbackMigration::buildAbsolutPath ( int  $exec_id,
int  $assignment_id,
int  $peer_id,
int  $giver_id 
)
protected

Definition at line 121 of file class.ilExercisePeerFeedbackMigration.php.

References CLIENT_DATA_DIR, and ilFileSystemAbstractionStorage\createPathFromId().

121  : string
122  {
123  // ilExercise/X/exc_*EXC_ID*/peer_up_*ASS_ID*/*TAKER_ID*/*GIVER_ID*/*CRIT_ID*/
124  return CLIENT_DATA_DIR
125  . '/ilExercise/'
127  $exec_id,
128  "exc"
129  ) . "/peer_up_$assignment_id/" . $peer_id . "/" . $giver_id;
130  }
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()

ilExercisePeerFeedbackMigration::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.ilExercisePeerFeedbackMigration.php.

33  : int
34  {
35  return 1000;
36  }

◆ getLabel()

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

Implements ILIAS\Setup\Migration.

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

28  : string
29  {
30  return "Migration of peer feedback files to the resource storage service.";
31  }

◆ getPreconditions()

ilExercisePeerFeedbackMigration::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.ilExercisePeerFeedbackMigration.php.

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

◆ getRemainingAmountOfSteps()

ilExercisePeerFeedbackMigration::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 111 of file class.ilExercisePeerFeedbackMigration.php.

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

111  : int
112  {
113  $r = $this->helper->getDatabase()->query(
114  "SELECT count(pe.id) as amount FROM exc_assignment_peer pe JOIN exc_assignment ass ON pe.ass_id = ass.id JOIN object_data od ON ass.exc_id = od.obj_id WHERE pe.migrated = 0"
115  );
116  $d = $this->helper->getDatabase()->fetchObject($r);
117 
118  return (int) $d->amount;
119  }
$r

◆ prepare()

ilExercisePeerFeedbackMigration::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.ilExercisePeerFeedbackMigration.php.

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

◆ step()

ilExercisePeerFeedbackMigration::step ( Environment  $environment)

Run one step of the migration.

Implements ILIAS\Setup\Migration.

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

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

51  : void
52  {
53  $db = $this->helper->getDatabase();
54  $r = $db->query(
55  "SELECT pe.ass_id, pe.giver_id, pe.ass_id, pe.peer_id, od.owner, od.obj_id FROM exc_assignment_peer pe JOIN exc_assignment ass ON pe.ass_id = ass.id JOIN object_data od ON ass.exc_id = od.obj_id WHERE pe.migrated = 0 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  $giver_id = (int) $d->giver_id;
61  $peer_id = (int) $d->peer_id;
62  $resource_owner_id = (int) $d->owner;
63  $base_path = $this->buildAbsolutPath($exec_id, $assignment_id, $peer_id, $giver_id);
64 
65  if (is_dir($base_path)) {
66  if ($dh = opendir($base_path)) {
67  while (($file = readdir($dh)) !== false) {
68  if ($file != '.' && $file != '..' && is_dir($base_path . '/' . $file)) {
69  if (is_numeric($file)) {
70  $crit_id = (int) $file;
71  $fb_dir = $base_path . "/" . $file;
72 
73  $pattern = '/[^\.].*/m';
74  $rid = "";
75  if (is_dir($fb_dir)) {
76  $rid = $this->helper->moveFirstFileOfPatternToStorage(
77  $fb_dir,
78  $pattern,
79  $resource_owner_id
80  );
81  if (!is_null($rid)) {
82  $db->insert("exc_crit_file", [
83  "ass_id" => ["integer", $assignment_id],
84  "giver_id" => ["integer", $giver_id],
85  "peer_id" => ["integer", $peer_id],
86  "criteria_id" => ["integer", $crit_id],
87  "rid" => ["text", $rid]
88  ]);
89  }
90  }
91  }
92  }
93  }
94  closedir($dh);
95  }
96  }
97 
98  $this->helper->getDatabase()->update(
99  'exc_assignment_peer',
100  [
101  'migrated' => ['integer', 1]
102  ],
103  [
104  'ass_id' => ['integer', $assignment_id],
105  'giver_id' => ['integer', $giver_id],
106  'peer_id' => ['integer', $peer_id]
107  ]
108  );
109  }
$r
+ Here is the call graph for this function:

Field Documentation

◆ $helper

ilResourceStorageMigrationHelper ilExercisePeerFeedbackMigration::$helper
protected

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


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