Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 50 additions & 0 deletions classes/task/insert_missing_helptable_entries.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.

namespace local_lsf_unification\task;


use coding_exception;
use core\task\scheduled_task;
use local_lsf_unification\pg_lite;

/**
* Scheduled task that updates the helptables by inserting missing entries.
*
* @package local_lsf_unification
* @copyright 2026 Tamaro Walter
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class insert_missing_helptable_entries extends scheduled_task {
#[\Override]
public function get_name(): string {
return get_string('task_missing_helptable_entries', 'local_lsf_unification');
}

#[\Override]
public function execute(): void {
global $pgdb, $CFG;
include_once($CFG->dirroot . '/local/lsf_unification/class_pg_lite.php');
include_once($CFG->dirroot . '/local/lsf_unification/lib_features.php');
$pgdb = new pg_lite();
$connected = $pgdb->connect();
$recourceid = pg_connection_status($pgdb->connection);
mtrace('! = unknown category found, ? = unknown linkage found;' . 'Verbindung: ' .
($connected ? 'ja' : 'nein') . ' (' . $recourceid . ')');
insert_missing_helptable_entries(true);
$pgdb->dispose();
}
}
39 changes: 39 additions & 0 deletions db/tasks.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.

/**
* Definition of lsf_unification scheduled tasks.
*
* @package local_lsf_unification
* @copyright 2026 Tamaro Walter
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/

defined('MOODLE_INTERNAL') || die();

$tasks = [

// Cron to update the helptable.
[
'classname' => 'local_lsf_unification\task\insert_missing_helptable_entries',
'blocking' => 0,
'minute' => '0',
'hour' => '0',
'day' => '*',
'month' => '*',
'dayofweek' => '*',
],
];
1 change: 1 addition & 0 deletions lang/de/local_lsf_unification.php
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@
$string['sub_category'] = 'Unterkategorie';
$string['subcategories'] = 'Unterkategorien freischalten';
$string['subcategories_description'] = 'Erlaubt das einordnen nicht zugeordneter Unterkategorien zu Oberkategorien';
$string['task_missing_helptable_entries'] = 'Tabellen der LSF-Veranstaltungsüberschriften aktualisieren.';
$string['template_from_course'] = 'Alternative {$a}: Fortfahren mit den Inhalten eines existierenden Kurses...';
$string['update_helptable'] = 'Hilfstabelle automatisch aktualisieren';
$string['warning_cannot_enrol_nologin'] = "Person wurde nicht hinzugef&uuml;gt (kein Benutzername gefunden)";
Expand Down
1 change: 1 addition & 0 deletions lang/en/local_lsf_unification.php
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,7 @@
$string['sub_category'] = 'Subcategory';
$string['subcategories'] = 'Unlock Subcategories';
$string['subcategories_description'] = 'Enable choosing not mapped subcategories of mapped categories';
$string['task_missing_helptable_entries'] = 'Update table of LSF categories.';
$string['template_from_course'] = 'Alternative {$a}: Include contents from an existing course ...';
$string['update_helptable'] = 'Update Helptable With HIS-LSF data';
$string['warning_cannot_enrol_nologin'] = "person wasn't enrolled (no username found)";
Expand Down
26 changes: 0 additions & 26 deletions lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -405,29 +405,3 @@ function add_path_description(array $choices): array {
}
return $result;
}

/**
* Function to be run periodically according to the scheduled task.
*
* LEARNWEB-TODO: Since 2.7.2 this function is run by scheduled task rather
* than standard cron.
* @return void
*/
function local_lsf_unification_cron(): void {
global $CFG, $pgdb;
include_once(dirname(__FILE__) . '/class_pg_lite.php');
include_once(dirname(__FILE__) . '/lib_features.php');

$pgdb = new pg_lite();
$connected = $pgdb->connect();
$recourceid = $pgdb->connection;

mtrace(
'! = unknown category found, ? = unknown linkage found;' . 'Verbindung: ' .
($connected ? 'ja' : 'nein') . ' (' . $recourceid . ')'
);

insert_missing_helptable_entries(true, false);

$pgdb->dispose();
}
5 changes: 2 additions & 3 deletions version.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,8 @@

defined('MOODLE_INTERNAL') || die;

$plugin->version = 2025123100;
$plugin->version = 2025123101;
$plugin->component = 'local_lsf_unification';
$plugin->cron = 86400; // Once a day.
$plugin->requires = 2024100700; // Require Moodle 4.5.
$plugin->supports = [405, 501];
$plugin->supported = [405, 501];
$plugin->maturity = MATURITY_ALPHA;
Loading