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

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

Member Function Documentation

◆ buildAbsolutPath()

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

Definition at line 101 of file class.ilExerciseTutorTeamFeedbackFileMigration.php.

References CLIENT_DATA_DIR, and ilFileSystemAbstractionStorage\createPathFromId().

Referenced by step().

101  : string
102  {
103  return CLIENT_DATA_DIR
104  . '/ilExercise/'
106  $exec_id,
107  "exc"
108  ) . "/feedb_$assignment_id/$user_id";
109  }
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()

ilExerciseTutorTeamFeedbackFileMigration::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 37 of file class.ilExerciseTutorTeamFeedbackFileMigration.php.

37  : int
38  {
39  return 1000;
40  }

◆ getLabel()

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

Implements ILIAS\Setup\Migration.

Definition at line 32 of file class.ilExerciseTutorTeamFeedbackFileMigration.php.

32  : string
33  {
34  return "Migration of tutor team feedback files to the resource storage service.";
35  }

◆ getPreconditions()

ilExerciseTutorTeamFeedbackFileMigration::getPreconditions ( Environment  $environment)

Objectives the migration depend on.

Exceptions
UnachievableExceptionif the objective is not achievable
Returns
Objective[]

Implements ILIAS\Setup\Migration.

Definition at line 42 of file class.ilExerciseTutorTeamFeedbackFileMigration.php.

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

◆ getRemainingAmountOfSteps()

ilExerciseTutorTeamFeedbackFileMigration::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 91 of file class.ilExerciseTutorTeamFeedbackFileMigration.php.

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

91  : int
92  {
93  $r = $this->helper->getDatabase()->query(
94  "SELECT count(*) AS amount FROM exc_assignment ass JOIN object_data ob ON ass.exc_id = ob.obj_id JOIN il_exc_team te ON te.ass_id = ass.id JOIN exc_team_data td ON te.id = td.id WHERE td.feedback_rcid IS NULL OR td.feedback_rcid = ''"
95  );
96  $d = $this->helper->getDatabase()->fetchObject($r);
97 
98  return (int) $d->amount;
99  }
$r

◆ prepare()

ilExerciseTutorTeamFeedbackFileMigration::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 47 of file class.ilExerciseTutorTeamFeedbackFileMigration.php.

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

◆ step()

ilExerciseTutorTeamFeedbackFileMigration::step ( Environment  $environment)

Run one step of the migration.

Implements ILIAS\Setup\Migration.

Definition at line 55 of file class.ilExerciseTutorTeamFeedbackFileMigration.php.

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

55  : void
56  {
57  $db = $this->helper->getDatabase();
58  $r = $this->helper->getDatabase()->query(
59  "SELECT ass.id, ass.exc_id, ob.owner, te.id team_id FROM exc_assignment ass JOIN object_data ob ON ass.exc_id = ob.obj_id JOIN il_exc_team te ON te.ass_id = ass.id JOIN exc_team_data td ON te.id = td.id WHERE td.feedback_rcid IS NULL OR td.feedback_rcid = '' LIMIT 1;"
60  );
61  $d = $this->helper->getDatabase()->fetchObject($r);
62  $exec_id = (int) $d->exc_id;
63  $assignment_id = (int) $d->id;
64  $resource_owner_id = (int) $d->owner;
65  $team_id = (int) $d->team_id;
66  $base_path = $this->buildAbsolutPath($exec_id, $assignment_id, $team_id);
67  if (is_dir($base_path)) {
68  $collection_id = $this->helper->moveFilesOfPathToCollection(
69  $base_path,
70  $resource_owner_id
71  );
72  } else {
73  $collection = $this->helper->getCollectionBuilder()->new($resource_owner_id);
74  if ($this->helper->getCollectionBuilder()->store($collection)) {
75  $collection_id = $collection->getIdentification()->serialize();
76  } else {
77  throw new ilException("Could not build collection");
78  }
79  }
80  $this->helper->getDatabase()->update(
81  'exc_team_data',
82  [
83  'feedback_rcid' => ['text', $collection_id]
84  ],
85  [
86  'id' => ['integer', $team_id]
87  ]
88  );
89  }
buildAbsolutPath(int $exec_id, int $assignment_id, int $user_id)
$r
+ Here is the call graph for this function:

Field Documentation

◆ $helper

ilResourceStorageMigrationHelper ilExerciseTutorTeamFeedbackFileMigration::$helper
protected

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