Skip to content

Commit

Permalink
temporary fix for exc migration
Browse files Browse the repository at this point in the history
  • Loading branch information
alex40724 committed Oct 10, 2023
1 parent 7922993 commit 5bc3c63
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 6 deletions.
22 changes: 22 additions & 0 deletions Modules/Exercise/Assignment/class.ilExAssignment.php
Original file line number Diff line number Diff line change
Expand Up @@ -722,11 +722,33 @@ protected function initFromDB(array $a_set): void
$this->setRelativeDeadline((int) $a_set["relative_deadline"]);
$this->setRelDeadlineLastSubmission((int) $a_set["rel_deadline_last_subm"]);
$rcid = $a_set["if_rcid"] ?? null;
if ($rcid === "") { // get new id, if we have an empty string here, see migration and #38167
$rcid = $this->createInstructionFilesIrssId()->serialize();
}
if ($rcid !== null) {
$this->instruction_file_rcid = $this->irss->collection()->id($rcid);
}
}

/**
* @return ResourceCollectionIdentification
* @throws Exception
*/
protected function createInstructionFilesIrssId(): ResourceCollectionIdentification
{
$rcid = $this->irss->collection()->id();
$this->db->update(
"exc_assignment",
[
"if_rcid" => ["text", $rcid->serialize()]
],
[ // where
"id" => ["integer", $this->getId()]
]
);
return $rcid;
}

/**
* @throws ilDateTimeException
*/
Expand Down
8 changes: 5 additions & 3 deletions Modules/Exercise/Assignment/class.ilExAssignmentEditorGUI.php
Original file line number Diff line number Diff line change
Expand Up @@ -911,9 +911,11 @@ protected function importFormToAssignment(
}

// Create Collection ID
$rcid = $this->irss->collection()->id();
$a_ass->setInstructionFileRCID($rcid);
$a_ass->update();
if ($is_create) {
$rcid = $this->irss->collection()->id();
$a_ass->setInstructionFileRCID($rcid);
$a_ass->update();
}

// id needed for file handling
if ($is_create) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public function step(Environment $environment): void
{
$db = $this->helper->getDatabase();
$r = $this->helper->getDatabase()->query(
"SELECT id, exc_id, owner FROM exc_assignment JOIN object_data ON exc_id = obj_id WHERE if_rcid IS NULL OR if_rcid = '' LIMIT 1;"
"SELECT id, exc_id, owner FROM exc_assignment JOIN object_data ON exc_id = obj_id WHERE if_rcid IS NULL LIMIT 1;"
);
$d = $this->helper->getDatabase()->fetchObject($r);
$exec_id = (int)$d->exc_id;
Expand All @@ -73,7 +73,7 @@ public function step(Environment $environment): void
$this->helper->getDatabase()->update(
'exc_assignment',
[
'if_rcid' => ['text', $collection_id]
'if_rcid' => ['text', (string) $collection_id]
],
[
'id' => ['integer', $assignment_id],
Expand All @@ -85,7 +85,7 @@ public function step(Environment $environment): void
public function getRemainingAmountOfSteps(): int
{
$r = $this->helper->getDatabase()->query(
"SELECT count(id) AS amount FROM exc_assignment WHERE if_rcid IS NULL OR if_rcid = ''"
"SELECT count(id) AS amount FROM exc_assignment WHERE if_rcid IS NULL "
);
$d = $this->helper->getDatabase()->fetchObject($r);

Expand Down

0 comments on commit 5bc3c63

Please sign in to comment.