Skip to content

Commit

Permalink
ARLO-22 max retries error page boilerplate code
Browse files Browse the repository at this point in the history
  • Loading branch information
nathan-hunt-moodle committed Nov 30, 2023
1 parent dae81b2 commit 43a875b
Show file tree
Hide file tree
Showing 4 changed files with 108 additions and 0 deletions.
38 changes: 38 additions & 0 deletions admin/apiretries.php
Original file line number Diff line number Diff line change
@@ -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/>.

/**
* API retries error report page
*
* @package enrol_arlo
* @copyright 2023 Moodle US
* @author Nathan Hunt {nathan.hunt@moodle.com}
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/

use enrol_arlo\local\tablesql\apiretries;

require_once(__DIR__ . '/../../../config.php');
require_once($CFG->libdir . '/adminlib.php');
require_once($CFG->libdir . '/tablelib.php');

admin_externalpage_setup('enrolsettingsarloapiretries');

$report = new apiretries('enrolsettingsarloapiretries');
echo $OUTPUT->header();
echo $OUTPUT->heading(get_string('apiretries', 'enrol_arlo'));
$report->out(apiretries::PAGINATION_MAX_LIMIT, false);
echo $OUTPUT->footer();
64 changes: 64 additions & 0 deletions classes/local/tablesql/apiretries.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
<?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/>.

/**
* API retries error report table
*
* @package enrol_arlo
* @copyright 2023 Moodle US
* @author Nathan Hunt {nathan.hunt@moodle.com}
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/

namespace enrol_arlo\local\tablesql;

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

use table_sql;

class apiretries extends table_sql {
const PAGINATION_MAX_LIMIT = 50;
public function __construct($uniqueid) {
parent::__construct($uniqueid);
$columns = array();
$headers = array();
$columns[] = 'timelogged';
$headers[] = get_string('timelogged', 'enrol_arlo');
$columns[] = 'platform';
$headers[] = get_string('platform', 'enrol_arlo');
$columns[] = 'uri';
$headers[] = get_string('uri', 'enrol_arlo');
$columns[] = 'status';
$headers[] = get_string('status');
$columns[] = 'extra';
$headers[] = get_string('extra', 'enrol_arlo');
$this->define_columns($columns);
$this->define_headers($headers);
$this->define_baseurl("/enrol/arlo/admin/apirequests.php");
$this->is_collapsible = false;
$this->sort_default_column = 'timelogged';
$this->sort_default_order = SORT_DESC;
$this->set_count_sql('SELECT COUNT(*) FROM {enrol_arlo_requestlog}', array());
$this->set_sql('*', "{enrol_arlo_requestlog}", 'timelogged <> 0');
$this->no_sorting('platform');
$this->no_sorting('uri');
$this->no_sorting('extra');
$this->pageable(true);
}
public function col_timelogged($values) {
return userdate($values->timelogged);
}
}
1 change: 1 addition & 0 deletions lang/en/enrol_arlo.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
$string['allowportalintegration_text'] = 'Allow integration with Arlo portal.';
$string['allowportalintegration_help'] = 'Will push course homepage and enrolment instance URL\'s to Arlo for use in portal.';
$string['apirequests'] = 'API requests';
$string['apiretries'] = 'API retries';
$string['apistatusok'] = 'OK, last request was {$a}';
$string['apistatusclienterror'] = 'Client connection error!';
$string['apistatusservererror'] = 'Service currently unavailable';
Expand Down
5 changes: 5 additions & 0 deletions settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,11 @@
$ADMIN->add('enrolsettingsarlomanage', new admin_externalpage('enrolsettingsarloapirequests',
$name = get_string('apirequests', 'enrol_arlo'),
new moodle_url('/enrol/arlo/admin/apirequests.php')));

// Max retries error page
$ADMIN->add('enrolsettingsarlomanage', new admin_externalpage('enrolsettingsarloapiretries',
$name = get_string('apiretries', 'enrol_arlo'),
new moodle_url('/enrol/arlo/admin/apiretries.php')));

$ADMIN->add('enrolsettingsarlomanage', new admin_externalpage('enrolsettingsarlocommunications',
$name = get_string('communications', 'enrol_arlo'),
Expand Down

0 comments on commit 43a875b

Please sign in to comment.