Skip to content

Commit

Permalink
WR422914 CI Updates
Browse files Browse the repository at this point in the history
CI check updates and a fwe minor changes.
  • Loading branch information
SimonThornett committed Jan 7, 2025
1 parent 0de6d99 commit ef5b2c6
Show file tree
Hide file tree
Showing 95 changed files with 1,608 additions and 1,286 deletions.
4 changes: 2 additions & 2 deletions classes/event/event_processed.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ protected function init() {
*
* @return string
*/
public static function get_name() : string {
public static function get_name(): string {
return get_string('eventeventprocessed', 'local_assessfreq');
}

Expand All @@ -57,7 +57,7 @@ public static function get_name() : string {
*
* @return string
*/
public function get_description() : string {
public function get_description(): string {
return get_string('eventeven_processed_desc', 'local_assessfreq');
}
}
41 changes: 23 additions & 18 deletions classes/external.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,13 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class local_assessfreq_external extends external_api {

/**
* Returns description of method parameters.
*
* @return external_function_parameters
*/
public static function get_courses_parameters() : external_function_parameters {
public static function get_courses_parameters(): external_function_parameters {
return new external_function_parameters([
'query' => new external_value(PARAM_TEXT, 'The query to find'),
]);
Expand All @@ -55,7 +56,7 @@ public static function get_courses_parameters() : external_function_parameters {
* @param string $query The search query.
* @return string JSON response.
*/
public static function get_courses(string $query) : string {
public static function get_courses(string $query): string {
global $DB, $SITE, $COURSE;
manager::write_close(); // Close session early this is a read op.

Expand All @@ -66,22 +67,26 @@ public static function get_courses(string $query) : string {
);

// Execute API call.
$sql = 'SELECT id, fullname, category FROM {course} WHERE ' . $DB->sql_like('fullname', ':fullname', false) . ' AND id <> 1';
$sql = 'SELECT id, fullname, category
FROM {course}
WHERE ' . $DB->sql_like('fullname', ':fullname', false) . '
AND id <> 1';
$params = ['fullname' => '%' . $DB->sql_like_escape($query) . '%'];
$courses = $DB->get_records_sql($sql, $params, 0, 30);

$data = [];
if (has_capability('local/assessfreq:view', context_system::instance())) {
$data[SITEID] = [
"id" => $SITE->id,
"fullname" => external_format_string($SITE->fullname, true, ["escape" => false])
"fullname" => external_format_string($SITE->fullname, true, ["escape" => false]),
];
}
$categories = \core_course_category::make_categories_list();
$categories = core_course_category::make_categories_list();
foreach ($courses as $course) {
$fullname = external_format_string($course->fullname, true, ["escape" => false]);
$data[$course->id] = [
"id" => $course->id,
"fullname" => $categories[$course->category] . ' / ' . external_format_string($course->fullname, true, ["escape" => false])
"fullname" => $categories[$course->category] . ' / ' . $fullname,
];
}

Expand All @@ -96,7 +101,7 @@ public static function get_courses(string $query) : string {
* Returns description of method result value
* @return external_value
*/
public static function get_courses_returns() : external_value {
public static function get_courses_returns(): external_value {
return new external_value(PARAM_RAW, 'Course result JSON');
}

Expand All @@ -105,7 +110,7 @@ public static function get_courses_returns() : external_value {
*
* @return external_function_parameters
*/
public static function get_activities_parameters() : external_function_parameters {
public static function get_activities_parameters(): external_function_parameters {
return new external_function_parameters([
'courseid' => new external_value(PARAM_INT, 'The courseid to find'),
]);
Expand All @@ -117,7 +122,7 @@ public static function get_activities_parameters() : external_function_parameter
* @param $courseid
* @return string JSON response.
*/
public static function get_activities($courseid) : string {
public static function get_activities($courseid): string {
global $DB;
manager::write_close(); // Close session early this is a read op.

Expand All @@ -130,7 +135,7 @@ public static function get_activities($courseid) : string {
// Execute API call.
$modules = $DB->get_records('course_modules', ['course' => $courseid]);

$sources = get_sources();
$sources = local_assessfreq_get_sources();

$data = [];
foreach ($modules as $module) {
Expand All @@ -144,7 +149,7 @@ public static function get_activities($courseid) : string {

$data[$module->id] = [
"id" => $module->id,
"name" => $cm->get_module_type_name() . " - " . $cm->get_name()
"name" => $cm->get_module_type_name() . " - " . $cm->get_name(),
];
}

Expand All @@ -157,7 +162,7 @@ public static function get_activities($courseid) : string {
* Returns description of method result value
* @return external_value
*/
public static function get_activities_returns() : external_value {
public static function get_activities_returns(): external_value {
return new external_value(PARAM_RAW, 'Result JSON');
}

Expand All @@ -167,7 +172,7 @@ public static function get_activities_returns() : external_value {
*
* @return external_function_parameters
*/
public static function set_table_preference_parameters() : external_function_parameters {
public static function set_table_preference_parameters(): external_function_parameters {
return new external_function_parameters([
'tableid' => new external_value(PARAM_ALPHANUMEXT, 'The table id to set the preference for'),
'preference' => new external_value(PARAM_ALPHAEXT, 'The table preference to set'),
Expand All @@ -183,7 +188,7 @@ public static function set_table_preference_parameters() : external_function_par
* @param string $values The values to set for the preference, encoded as JSON.
* @return string JSON response.
*/
public static function set_table_preference(string $tableid, string $preference, string $values) : string {
public static function set_table_preference(string $tableid, string $preference, string $values): string {
global $SESSION, $PAGE;

// Parameter validation.
Expand Down Expand Up @@ -233,7 +238,7 @@ public static function set_table_preference_returns() {
*
* @return external_function_parameters
*/
public static function process_override_form_parameters() : external_function_parameters {
public static function process_override_form_parameters(): external_function_parameters {
return new external_function_parameters(
[
'jsonformdata' => new external_value(PARAM_RAW, 'The data from the create copy form, encoded as a json array'),
Expand All @@ -251,7 +256,7 @@ public static function process_override_form_parameters() : external_function_pa
* @param int $activityid The activity id to add an override for.
* @return string
*/
public static function process_override_form(string $jsonformdata, string $activitytype, int $activityid) : string {
public static function process_override_form(string $jsonformdata, string $activitytype, int $activityid): string {
global $DB;

// Release session lock.
Expand All @@ -269,9 +274,9 @@ public static function process_override_form(string $jsonformdata, string $activ
parse_str($formdata, $submitteddata);

$processid = 0;
$sources = get_sources();
$sources = local_assessfreq_get_sources();
$source = $sources[$activitytype];
/* @var $source source_base */
/* @var $source source_base for accessing the source class */
if (method_exists($source, 'process_override_form')) {
$processid = $source->process_override_form($activityid, $submitteddata);
}
Expand Down
20 changes: 11 additions & 9 deletions classes/frequency.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,12 +60,14 @@ class frequency {
/**
* Size of batch to insert records into database.
*
* @var integer $batchsize
* @var int $batchsize
*/
private int $batchsize = 100;

/**
* Cache of event users.
*
* @var array $eventuserscache
*/
private array $eventuserscache = [];

Expand All @@ -77,7 +79,7 @@ class frequency {
* @return array Capabilities relating to the module.
*/
public function get_module_capabilities(string $module): array {
$sources = get_sources(true);
$sources = local_assessfreq_get_sources(true);
return $sources[$module]->get_user_capabilities();
}

Expand All @@ -91,11 +93,11 @@ public function get_module_capabilities(string $module): array {
* @return array $modules Lis of modules to process.
*/
public function get_process_modules(): array {
$sources = get_sources();
$sources = local_assessfreq_get_sources();
$modules = [];

if (!empty($sources)) {
/* @var $source source_base */
/* @var $source source_base for accessing the source class */
foreach ($sources as $source) {
$modules[] = $source->get_module();
}
Expand Down Expand Up @@ -253,14 +255,14 @@ private function process_module_events(moodle_recordset $recordset): int {
*/
public function process_site_events(int $duedate): int {
$recordsprocessed = 0;
$sources = get_sources(true);
$sources = local_assessfreq_get_sources(true);
$includehiddencourses = get_config('local_assessfreq', 'hiddencourses');

if (!empty($sources)) {
// Itterate through sources.
foreach ($sources as $source) {

/* @var $source source_base */
/* @var $source source_base for accessing the source class */
$sql = $this->get_sql_query(
$source->get_module_table(),
$source->get_close_field(),
Expand Down Expand Up @@ -1037,7 +1039,7 @@ public function get_events_due_by_activity(int $year, int $month = 0, bool $cach
$params = [];
$sql = 'SELECT s.module, COUNT(s.id) as count
FROM {local_assessfreq_site} s
LEFT JOIN {course} c ON s.courseid = c.id
LEFT JOIN {course} c ON s.courseid = c.id
WHERE 1=1';

$includehiddencourses = get_config('local_assessfreq', 'hiddencourses');
Expand Down Expand Up @@ -1151,7 +1153,7 @@ public function get_day_events(int $courseid, string $date, array $modules): arr
}
}

$sources = get_sources();
$sources = local_assessfreq_get_sources();

// Get additional information and format the event data.
foreach ($events as $event) {
Expand All @@ -1166,7 +1168,7 @@ public function get_day_events(int $courseid, string $date, array $modules): arr
($event->timelimit == 0) ? '-' : round(($event->timelimit / 60));
$event->dashurl = '';

/* @var $source source_base */
/* @var $source source_base for accessing the source class */
$source = $sources[$event->module];
if (method_exists($source, 'get_activity_dashboard')) {
$dashurl = new \moodle_url('/local/assessfreq/', ['activityid' => $context->instanceid], 'activity_dashboard');
Expand Down
17 changes: 12 additions & 5 deletions classes/output/renderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,21 +25,28 @@

namespace local_assessfreq\output;

use local_assessfreq\form\course_search;
use local_assessfreq\report_base;
use plugin_renderer_base;

/**
* Renderer.
*
* @package local_assessfreq
* @author Simon Thornett <[email protected]>
* @copyright Catalyst IT, 2024
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class renderer extends plugin_renderer_base {
/**
* Render each of the assessfreqreport subplugins as tabs to display.
*
* @return void
*/
public function render_reports() : void {
$reports = get_reports();
public function render_reports(): void {
$reports = local_assessfreq_get_reports();
$reportoutputs = [];
foreach ($reports as $report) {
/* @var $report report_base */
/* @var $report report_base for accessing the report class */
$reportoutputs[] = [
'tablink' => $report->get_tablink(), // Plugin name.
'tabname' => $report->get_name(), // Display name.
Expand All @@ -55,7 +62,7 @@ public function render_reports() : void {
$output .= $this->render_from_template(
'local_assessfreq/index',
[
'reports' => $reportoutputs
'reports' => $reportoutputs,
]
);
$output .= $this->output->footer();
Expand Down
Loading

0 comments on commit ef5b2c6

Please sign in to comment.