19 declare(strict_types=1);
26 protected \ilResourceStorageMigrationHelper
$helper;
30 return "Migration of peer feedback files to the resource storage service.";
40 return \ilResourceStorageMigrationHelper::getPreconditions();
45 $this->helper = new \ilResourceStorageMigrationHelper(
53 $db = $this->helper->getDatabase();
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;" 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);
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;
73 $pattern =
'/[^\.].*/m';
75 if (is_dir($fb_dir)) {
76 $rid = $this->helper->moveFirstFileOfPatternToStorage(
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]
98 $this->helper->getDatabase()->update(
99 'exc_assignment_peer',
101 'migrated' => [
'integer', 1]
104 'ass_id' => [
'integer', $assignment_id],
105 'giver_id' => [
'integer', $giver_id],
106 'peer_id' => [
'integer', $peer_id]
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" 116 $d = $this->helper->getDatabase()->fetchObject(
$r);
118 return (
int)
$d->amount;
121 protected function buildAbsolutPath(
int $exec_id,
int $assignment_id,
int $peer_id,
int $giver_id): string
129 ) .
"/peer_up_$assignment_id/" . $peer_id .
"/" . $giver_id;
getRemainingAmountOfSteps()
Count up how many "things" need to be migrated.
getDefaultAmountOfStepsPerRun()
Tell the default amount of steps to be executed for one run of the migration.
step(Environment $environment)
Run one step of the migration.
A migration is a potentially long lasting operation that can be broken into discrete steps...
buildAbsolutPath(int $exec_id, int $assignment_id, int $peer_id, int $giver_id)
prepare(Environment $environment)
Prepare the migration by means of some environment.
getPreconditions(Environment $environment)
Objectives the migration depend on.
static createPathFromId(int $a_container_id, string $a_name)
An environment holds resources to be used in the setup process.
ilResourceStorageMigrationHelper $helper