Check in
This commit is contained in:
commit
8f1640172f
6 changed files with 167 additions and 0 deletions
72
classes/task/get_issues_task.php
Normal file
72
classes/task/get_issues_task.php
Normal file
|
@ -0,0 +1,72 @@
|
|||
<?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/>.
|
||||
|
||||
/**
|
||||
* A scheduled task for storing issued certificates.
|
||||
*
|
||||
* @package local_certlog
|
||||
* @copyright 2017 Mark Nelson <markn@moodle.com>, 2021 Klaus-Uwe Mitterer <kumitterer@kumi.systems>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
namespace local_certlog\task;
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
/**
|
||||
* A scheduled task for storing issued certificates.
|
||||
*
|
||||
* @package local_certlog
|
||||
* @copyright 2017 Mark Nelson <markn@moodle.com>, 2021 Klaus-Uwe Mitterer <kumitterer@kumi.systems>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
class get_issues_task extends \core\task\scheduled_task {
|
||||
|
||||
/**
|
||||
* Get a descriptive name for this task (shown to admins).
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function get_name() {
|
||||
return get_string('taskgetissues', 'local_certlog');
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute.
|
||||
*/
|
||||
public function execute() {
|
||||
global $DB, $PAGE;
|
||||
|
||||
foreach (array("customcert", "htmlcert") as $module) {
|
||||
$issuetable = $module . '_issues';
|
||||
$certidfield = $module . 'id';
|
||||
$lb = "{";
|
||||
$rb = "}";
|
||||
$cur = $DB->get_field("certlog", "MAX(originid)", array("originname" => $module)) ?: 0;
|
||||
|
||||
$sql = "SELECT i.id AS originid, i.timecreated AS timestamp,
|
||||
m.course AS course, i.userid AS user,
|
||||
\"$module\" AS originname
|
||||
FROM $lb$issuetable$rb i
|
||||
JOIN $lb$module$rb m
|
||||
ON i.$certidfield = m.id
|
||||
WHERE i.id > :id";
|
||||
|
||||
$newer = $DB->get_records_sql($sql, array('id' => $cur));
|
||||
|
||||
$DB->insert_records("certlog", $newer);
|
||||
}
|
||||
}
|
||||
}
|
17
db/access.php
Normal file
17
db/access.php
Normal file
|
@ -0,0 +1,17 @@
|
|||
<?php
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
$capabilities = array(
|
||||
|
||||
'local/certlog:access' => array(
|
||||
'riskbitmask' => RISK_PERSONAL,
|
||||
'captype' => 'read',
|
||||
'contextlevel' => CONTEXT_SYSTEM,
|
||||
'archetypes' => array(
|
||||
'editingteacher' => CAP_ALLOW,
|
||||
'manager' => CAP_ALLOW
|
||||
)
|
||||
)
|
||||
|
||||
);
|
23
db/install.xml
Normal file
23
db/install.xml
Normal file
|
@ -0,0 +1,23 @@
|
|||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<XMLDB PATH="local/certlog/db" VERSION="20210622" COMMENT="XMLDB file for Moodle local/certlog"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:noNamespaceSchemaLocation="../../../lib/xmldb/xmldb.xsd"
|
||||
>
|
||||
<TABLES>
|
||||
<TABLE NAME="certlog" COMMENT="Logs certificate issues for future reference">
|
||||
<FIELDS>
|
||||
<FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" SEQUENCE="true"/>
|
||||
<FIELD NAME="timestamp" TYPE="int" LENGTH="10" NOTNULL="true" DEFAULT="0" SEQUENCE="false"/>
|
||||
<FIELD NAME="course" TYPE="int" LENGTH="10" NOTNULL="true" SEQUENCE="false"/>
|
||||
<FIELD NAME="user" TYPE="int" LENGTH="10" NOTNULL="true" SEQUENCE="false"/>
|
||||
<FIELD NAME="originname" TYPE="char" LENGTH="128" NOTNULL="true" SEQUENCE="false"/>
|
||||
<FIELD NAME="originid" TYPE="int" LENGTH="10" NOTNULL="true" SEQUENCE="false"/>
|
||||
</FIELDS>
|
||||
<KEYS>
|
||||
<KEY NAME="primary" TYPE="primary" FIELDS="id"/>
|
||||
<KEY NAME="user" TYPE="foreign" FIELDS="user" REFTABLE="user" REFFIELDS="id"/>
|
||||
<KEY NAME="course" TYPE="foreign" FIELDS="course" REFTABLE="course" REFFIELDS="id"/>
|
||||
</KEYS>
|
||||
</TABLE>
|
||||
</TABLES>
|
||||
</XMLDB>
|
38
db/tasks.php
Normal file
38
db/tasks.php
Normal file
|
@ -0,0 +1,38 @@
|
|||
<?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 htmlcert scheduled tasks.
|
||||
*
|
||||
* @package mod_htmlcert
|
||||
* @category task
|
||||
* @copyright 2017 Mark Nelson <markn@moodle.com>, 2021 Klaus-Uwe Mitterer <kumitterer@kumi.systems>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
$tasks = array(
|
||||
array(
|
||||
'classname' => 'local_certlog\task\get_issues_task',
|
||||
'blocking' => 0,
|
||||
'minute' => '*/5',
|
||||
'hour' => '*',
|
||||
'day' => '*',
|
||||
'month' => '*',
|
||||
'dayofweek' => '*'
|
||||
)
|
||||
);
|
8
lang/en/local_certlog.php
Normal file
8
lang/en/local_certlog.php
Normal file
|
@ -0,0 +1,8 @@
|
|||
<?php
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
$string['modulename'] = 'Certificate Logging';
|
||||
$string['modulenameplural'] = $string['modulename'];
|
||||
$string['pluginname'] = $string['modulename'];
|
||||
|
9
version.php
Normal file
9
version.php
Normal file
|
@ -0,0 +1,9 @@
|
|||
<?php
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
$plugin->version = "2021120301";
|
||||
$plugin->component = 'local_certlog';
|
||||
$plugin->maturity = MATURITY_ALPHA;
|
||||
$plugin->release = 'v0.0.1';
|
||||
$plugin->requires = '2019111800';
|
Loading…
Reference in a new issue