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

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()

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

Definition at line 102 of file class.ilExerciseTutorFeedbackFileMigration.php.

References CLIENT_DATA_DIR, and ilFileSystemAbstractionStorage\createPathFromId().

Referenced by step().

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

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

37  : int
38  {
39  return 1000;
40  }

◆ getLabel()

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

Implements ILIAS\Setup\Migration.

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

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

◆ getPreconditions()

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

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

◆ getRemainingAmountOfSteps()

ilExerciseTutorFeedbackFileMigration::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 92 of file class.ilExerciseTutorFeedbackFileMigration.php.

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

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

◆ prepare()

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

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

◆ step()

ilExerciseTutorFeedbackFileMigration::step ( Environment  $environment)

Run one step of the migration.

Implements ILIAS\Setup\Migration.

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

References Vendor\Package\$d, $r, $user_id, 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, st.usr_id FROM exc_assignment ass JOIN object_data ob ON ass.exc_id = ob.obj_id JOIN exc_mem_ass_status st ON st.ass_id = ass.id WHERE st.feedback_rcid IS NULL OR st.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  $user_id = (int) $d->usr_id;
66  $base_path = $this->buildAbsolutPath($exec_id, $assignment_id, $user_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_mem_ass_status',
82  [
83  'feedback_rcid' => ['text', $collection_id]
84  ],
85  [
86  'ass_id' => ['integer', $assignment_id],
87  'usr_id' => ['integer', $user_id]
88  ]
89  );
90  }
buildAbsolutPath(int $exec_id, int $assignment_id, int $user_id)
$r
+ Here is the call graph for this function:

Field Documentation

◆ $helper

ilResourceStorageMigrationHelper ilExerciseTutorFeedbackFileMigration::$helper
protected

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