Skip to content

Commit

Permalink
41968: Data (-fragments) left when deleting Exercise
Browse files Browse the repository at this point in the history
  • Loading branch information
alex40724 committed Sep 30, 2024
1 parent 59cf387 commit b31f40e
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 25 deletions.
37 changes: 33 additions & 4 deletions Modules/Exercise/Assignment/class.ilExAssignment.php
Original file line number Diff line number Diff line change
Expand Up @@ -815,12 +815,42 @@ public function update(): void
*/
public function delete(
ilObjExercise $exc,
bool $update_status = true): void
{
bool $update_status = true
): void {
$ilDB = $this->db;

// delete submissions
$exc_members = new ilExerciseMembers($exc);
foreach ($exc_members->getMembers() as $mem) {
$submission = new ilExSubmission($this, $mem);
$submission->deleteAllFiles();
}

$ilDB->manipulateF(
"DELETE FROM exc_usr_tutor " .
"WHERE ass_id = %s",
array("integer"),
array($this->getId())
);

$this->deleteGlobalFeedbackFile();

// remove peer review data
if ($this->getPeerReview()) {
$peer_review = new ilExPeerReview($this);
$peer_review->resetPeerReviews();
}

$ilDB->manipulate(
"DELETE FROM exc_ass_file_order" .
" WHERE assignment_id = " . $ilDB->quote($this->getId(), 'integer')
);

$ilDB->manipulate(
"DELETE FROM exc_mem_ass_status" .
" WHERE ass_id = " . $ilDB->quote($this->getId(), 'integer')
);

$ilDB->manipulate(
"DELETE FROM exc_assignment WHERE " .
" id = " . $ilDB->quote($this->getId(), "integer")
Expand Down Expand Up @@ -1549,8 +1579,7 @@ public function saveMultiFeedbackFiles(
protected function handleCalendarEntries(
string $a_event,
ilObjExercise $exc
): void
{
): void {
$ilAppEventHandler = $this->app_event_handler;

$dl_id = $this->getId() . "0";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -204,20 +204,6 @@ public function delete(): void
" WHERE id = " . $ilDB->quote($this->id, "integer"));
}

public static function deleteByParent(int $a_parent_id): void
{
global $DIC;

$ilDB = $DIC->database();

if ($a_parent_id <= 0) {
return;
}

$ilDB->manipulate("DELETE FROM exc_crit" .
" WHERE parent = " . $ilDB->quote($a_parent_id, "integer"));
}

public function cloneObject(int $a_target_parent_id): int
{
$new_obj = new self();
Expand Down
20 changes: 13 additions & 7 deletions Modules/Exercise/classes/class.ilObjExercise.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,12 @@ class ilObjExercise extends ilObject
protected ilFileDataMail $file_obj;
public ?ilExerciseMembers $members_obj = null;
protected int $timestamp = 0;
protected int $hour = 0;
protected int $minutes = 0;
protected int $day = 0;
protected int $month = 0;
protected int $year = 0;
protected string $instruction = "";
protected int $hour = 0;
protected int $minutes = 0;
protected int $day = 0;
protected int $month = 0;
protected int $year = 0;
protected string $instruction = "";
protected int $certificate_visibility = 0;
protected int $tutor_feedback = 7; // [int]
protected int $nr_random_mand = 0; // number of mandatory assignments in random pass mode
Expand Down Expand Up @@ -328,11 +328,17 @@ public function delete(): bool
$ass->delete($this, false);
}

// members
$members = new ilExerciseMembers($this);
$members->delete();

// put here course specific stuff
$ilDB->manipulate("DELETE FROM exc_data " .
"WHERE obj_id = " . $ilDB->quote($this->getId(), "integer"));

ilExcCriteriaCatalogue::deleteByParent($this->getId());
foreach (\ilExcCriteriaCatalogue::getInstancesByParentId($this->getId()) as $crit_cat) {
$crit_cat->delete();
}

// remove all notifications
ilNotification::removeForObject(ilNotification::TYPE_EXERCISE_SUBMISSION, $this->getId());
Expand Down

0 comments on commit b31f40e

Please sign in to comment.