forked from ponlawat-w/moodle-block_hubcourseranking
-
Notifications
You must be signed in to change notification settings - Fork 0
/
api.php
20 lines (15 loc) · 705 Bytes
/
api.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
<?php
define('AJAX_SCRIPT', true);
require_once(__DIR__ . '/../../config.php');
require_once(__DIR__ . '/lib.php');
$blockid = required_param('id', PARAM_INT);
$page = optional_param('page', 1, PARAM_INT);
$hubcourseranking = block_instance_by_id($blockid);
if (!$hubcourseranking || !($hubcourseranking instanceof block_hubcourseranking)) {
throw new moodle_exception('Block ID is not of hubcourseranking block type');
}
$results = block_hubcourseranking_gethubcourselist($hubcourseranking->config, $page);
$results->config = $hubcourseranking->config;
$results->records = array_values($results->records);
$results->more = (count($results->records) < $results->count);
echo json_encode($results);