Skip to content

Commit

Permalink
Delete test skill data when deleting competences
Browse files Browse the repository at this point in the history
  • Loading branch information
tfamula committed Oct 17, 2023
1 parent 1854549 commit 60fb151
Show file tree
Hide file tree
Showing 15 changed files with 516 additions and 6 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?php

declare(strict_types=1);

/**
* This file is part of ILIAS, a powerful learning management system
* published by ILIAS open source e-Learning e.V.
*
* ILIAS is licensed with the GPL-3.0,
* see https://www.gnu.org/licenses/gpl-3.0.en.html
* You should have received a copy of said license along with the
* source code, too.
*
* If this is not the case or you just want to try ILIAS, you'll find
* us at:
* https://www.ilias.de
* https://github.com/ILIAS-eLearning
*
********************************************************************
*/

namespace ILIAS\Test\Skills;

/**
* @author Thomas Famula <[email protected]>
*/
class SkillInternalManagerService
{
public function getSkillDeletionManager(): TestSkillDeletionManager
{
return new TestSkillDeletionManager();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?php

declare(strict_types=1);

/**
* This file is part of ILIAS, a powerful learning management system
* published by ILIAS open source e-Learning e.V.
*
* ILIAS is licensed with the GPL-3.0,
* see https://www.gnu.org/licenses/gpl-3.0.en.html
* You should have received a copy of said license along with the
* source code, too.
*
* If this is not the case or you just want to try ILIAS, you'll find
* us at:
* https://www.ilias.de
* https://github.com/ILIAS-eLearning
*
********************************************************************
*/

namespace ILIAS\Test\Skills;

/**
* @author Thomas Famula <[email protected]>
*/
class SkillInternalRepoService
{
public function getTestSkillRepo(): TestSkillDBRepository
{
return new TestSkillDBRepository();
}
}
42 changes: 42 additions & 0 deletions Modules/Test/classes/Skills/Service/class.SkillInternalService.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<?php

declare(strict_types=1);

/**
* This file is part of ILIAS, a powerful learning management system
* published by ILIAS open source e-Learning e.V.
*
* ILIAS is licensed with the GPL-3.0,
* see https://www.gnu.org/licenses/gpl-3.0.en.html
* You should have received a copy of said license along with the
* source code, too.
*
* If this is not the case or you just want to try ILIAS, you'll find
* us at:
* https://www.ilias.de
* https://github.com/ILIAS-eLearning
*
********************************************************************
*/

namespace ILIAS\Test\Skills;

/**
* @author Thomas Famula <[email protected]>
*/
class SkillInternalService
{
public function __construct()
{
}

public function repo(): SkillInternalRepoService
{
return new SkillInternalRepoService();
}

public function manager(): SkillInternalManagerService
{
return new SkillInternalManagerService();
}
}
49 changes: 49 additions & 0 deletions Modules/Test/classes/Skills/class.TestSkillDBRepository.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
<?php

declare(strict_types=1);

/**
* This file is part of ILIAS, a powerful learning management system
* published by ILIAS open source e-Learning e.V.
*
* ILIAS is licensed with the GPL-3.0,
* see https://www.gnu.org/licenses/gpl-3.0.en.html
* You should have received a copy of said license along with the
* source code, too.
*
* If this is not the case or you just want to try ILIAS, you'll find
* us at:
* https://www.ilias.de
* https://github.com/ILIAS-eLearning
*
********************************************************************
*/

namespace ILIAS\Test\Skills;

/**
* @author Thomas Famula <[email protected]>
*/
class TestSkillDBRepository
{
protected \ilDBInterface $db;

public function __construct(
\ilDBInterface $db = null
) {
global $DIC;

$this->db = ($db) ?: $DIC->database();
}

public function removeForSkill(int $skill_node_id, bool $is_reference): void
{
if (!$is_reference) {
$this->db->manipulate("DELETE FROM tst_skl_thresholds " .
" WHERE skill_base_fi = " . $this->db->quote($skill_node_id, "integer"));
} else {
$this->db->manipulate("DELETE FROM tst_skl_thresholds " .
" WHERE skill_tref_fi = " . $this->db->quote($skill_node_id, "integer"));
}
}
}
44 changes: 44 additions & 0 deletions Modules/Test/classes/Skills/class.TestSkillDeletionManager.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<?php

declare(strict_types=1);

/**
* This file is part of ILIAS, a powerful learning management system
* published by ILIAS open source e-Learning e.V.
*
* ILIAS is licensed with the GPL-3.0,
* see https://www.gnu.org/licenses/gpl-3.0.en.html
* You should have received a copy of said license along with the
* source code, too.
*
* If this is not the case or you just want to try ILIAS, you'll find
* us at:
* https://www.ilias.de
* https://github.com/ILIAS-eLearning
*
********************************************************************
*/

namespace ILIAS\Test\Skills;

/**
* @author Thomas Famula <[email protected]>
*/
class TestSkillDeletionManager
{
protected TestSkillDBRepository $test_skill_repo;

public function __construct(
TestSkillDBRepository $test_skill_repo = null
) {
global $DIC;

$this->test_skill_repo = ($test_skill_repo)
?: $DIC->skills()->internalTest()->repo()->getTestSkillRepo();
}

public function removeTestSkillsForSkill(int $skill_node_id, bool $is_reference = false): void
{
$this->test_skill_repo->removeForSkill($skill_node_id, $is_reference);
}
}
49 changes: 49 additions & 0 deletions Modules/Test/classes/class.ilTestAppEventListener.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
<?php

declare(strict_types=1);

/**
* This file is part of ILIAS, a powerful learning management system
* published by ILIAS open source e-Learning e.V.
*
* ILIAS is licensed with the GPL-3.0,
* see https://www.gnu.org/licenses/gpl-3.0.en.html
* You should have received a copy of said license along with the
* source code, too.
*
* If this is not the case or you just want to try ILIAS, you'll find
* us at:
* https://www.ilias.de
* https://github.com/ILIAS-eLearning
*
********************************************************************
*/

/**
* @author Thomas Famula <[email protected]>
*/
class ilTestAppEventListener implements ilAppEventListener
{
/**
* @inheritDoc
*/
public static function handleEvent(string $a_component, string $a_event, array $a_parameter): void
{
global $DIC;

$test_skill_deletion_manager = $DIC->skills()->internalTest()->manager()->getSkillDeletionManager();

switch ($a_component) {
case "Services/Skill":
switch ($a_event) {
case "deleteSkill":
$test_skill_deletion_manager->removeTestSkillsForSkill(
$a_parameter["node_id"],
$a_parameter["is_reference"]
);
break;
}
break;
}
}
}
3 changes: 3 additions & 0 deletions Modules/Test/module.xml
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,7 @@
<copage>
<pageobject parent_type="tst" class_name="ilTestPage" directory="classes/PageEditor"/>
</copage>
<events>
<event type="listen" id="Services/Skill" />
</events>
</module>
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?php

declare(strict_types=1);

/**
* This file is part of ILIAS, a powerful learning management system
* published by ILIAS open source e-Learning e.V.
*
* ILIAS is licensed with the GPL-3.0,
* see https://www.gnu.org/licenses/gpl-3.0.en.html
* You should have received a copy of said license along with the
* source code, too.
*
* If this is not the case or you just want to try ILIAS, you'll find
* us at:
* https://www.ilias.de
* https://github.com/ILIAS-eLearning
*
********************************************************************
*/

namespace ILIAS\TestQuestionPool\Skills;

/**
* @author Thomas Famula <[email protected]>
*/
class SkillInternalManagerService
{
public function getSkillDeletionManager(): TestQuestionPoolSkillDeletionManager
{
return new TestQuestionPoolSkillDeletionManager();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?php

declare(strict_types=1);

/**
* This file is part of ILIAS, a powerful learning management system
* published by ILIAS open source e-Learning e.V.
*
* ILIAS is licensed with the GPL-3.0,
* see https://www.gnu.org/licenses/gpl-3.0.en.html
* You should have received a copy of said license along with the
* source code, too.
*
* If this is not the case or you just want to try ILIAS, you'll find
* us at:
* https://www.ilias.de
* https://github.com/ILIAS-eLearning
*
********************************************************************
*/

namespace ILIAS\TestQuestionPool\Skills;

/**
* @author Thomas Famula <[email protected]>
*/
class SkillInternalRepoService
{
public function getTestQuestionPoolSkillRepo(): TestQuestionPoolSkillDBRepository
{
return new TestQuestionPoolSkillDBRepository();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<?php

declare(strict_types=1);

/**
* This file is part of ILIAS, a powerful learning management system
* published by ILIAS open source e-Learning e.V.
*
* ILIAS is licensed with the GPL-3.0,
* see https://www.gnu.org/licenses/gpl-3.0.en.html
* You should have received a copy of said license along with the
* source code, too.
*
* If this is not the case or you just want to try ILIAS, you'll find
* us at:
* https://www.ilias.de
* https://github.com/ILIAS-eLearning
*
********************************************************************
*/

namespace ILIAS\TestQuestionPool\Skills;

/**
* @author Thomas Famula <[email protected]>
*/
class SkillInternalService
{
public function __construct()
{
}

public function repo(): SkillInternalRepoService
{
return new SkillInternalRepoService();
}

public function manager(): SkillInternalManagerService
{
return new SkillInternalManagerService();
}
}
Loading

0 comments on commit 60fb151

Please sign in to comment.