SpreadQuiz/cli_actions.php
Epagris e313923ad4 - checking maintenance in each file added
- a few CLI commands added
- ticking and concluding expired tests added
2024-09-26 11:34:02 +02:00

40 lines
950 B
PHP

<?php
require_once "class/TestMgr.php";
$longopts = [
"action:", // execute some CLI action
"tick" // tick timed objects (e.g. timed tests)
];
$options = getopt("", $longopts);
// CLI actions
if (isset($options["action"])) {
$action = $options["action"];
switch ($action) {
case "upgrade_tests":
{
printf("Upgrading tests...");
$testMgr = new TestMgr();
$testMgr->upgradeTests();
printf("OK!\n");
}
break;
case "get_timed_tests":
{
$testMgr = new TestMgr();
printf("Expired timed tests: %s\n", join(", ", $testMgr->extractExpiredTimedTestIds()));
}
break;
}
}
// Tick tests
if (isset($options["tick"])) {
$testMgr = new TestMgr();
$timedTestIDs = $testMgr->extractExpiredTimedTestIds();
$testMgr->upgradeTests($timedTestIDs);
}