Skip to content

Commit 4789877

Browse files
committed
Component/Test: contribute cron jobs
1 parent 9f3aae3 commit 4789877

3 files changed

Lines changed: 19 additions & 8 deletions

File tree

components/ILIAS/Test/Test.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,5 +48,11 @@ public function init(
4848
new Component\Resource\ComponentCSS($this, "test_print.css");
4949
$contribute[Component\Resource\PublicAsset::class] = fn() =>
5050
new Component\Resource\ComponentCSS($this, "test_print_hide_content.css");
51+
$contribute[\ILIAS\Cron\CronJob::class] = static fn() =>
52+
new \ilCronFinishUnfinishedTestPasses(
53+
'components\\' . self::class,
54+
$use[\ILIAS\Language\Language::class],
55+
true
56+
);
5157
}
5258
}

components/ILIAS/Test/classes/class.ilCronFinishUnfinishedTestPasses.php

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,6 @@
3131
class ilCronFinishUnfinishedTestPasses extends ilCronJob
3232
{
3333
protected readonly TestLogger $logger;
34-
35-
protected readonly ilLanguage $lng;
3634
protected readonly ilDBInterface $db;
3735
protected readonly ilObjUser $user;
3836
protected readonly ilObjectDataCache $obj_data_cache;
@@ -43,15 +41,25 @@ class ilCronFinishUnfinishedTestPasses extends ilCronJob
4341
protected ilTestProcessLockerFactory $processLockerFactory;
4442
protected TestResultRepository $test_pass_result_repository;
4543

46-
public function __construct()
44+
public function __construct(
45+
string $component,
46+
\ILIAS\Language\Language $lng,
47+
bool $registration = false
48+
) {
49+
parent::__construct($component, $lng);
50+
$this->lng->loadLanguageModule('assessment');
51+
if (!$registration) {
52+
$this->additionalConstruct();
53+
}
54+
}
55+
56+
private function additionalConstruct()
4757
{
4858
/** @var ILIAS\DI\Container $DIC */
4959
global $DIC;
5060

5161
$this->logger = TestDIC::dic()['logging.logger'];
52-
$this->lng = $DIC['lng'];
5362
$this->user = $DIC['ilUser'];
54-
$this->lng->loadLanguageModule('assessment');
5563
$this->db = $DIC->database();
5664
$this->obj_data_cache = $DIC['ilObjDataCache'];
5765
$this->now = time();

components/ILIAS/Test/module.xml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,6 @@
3030
<parent id="wfld">wfld</parent>
3131
</object>
3232
</objects>
33-
<crons>
34-
<cron id="finish_unfinished_passes" class="ilCronFinishUnfinishedTestPasses" />
35-
</crons>
3633
<pluginslots>
3734
<pluginslot id="texp" name="Export" />
3835
</pluginslots>

0 commit comments

Comments
 (0)