moodle_local_treestudyplan/classes/reportservice.php
2024-02-09 14:48:15 +01:00

125 lines
4.4 KiB
PHP

<?php
// This file is part of the Studyplan plugin for Moodle
//
// 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 <https://www.gnu.org/licenses/>.
/**
* Webservice class for handling studyplan reports
* @package local_treestudyplan
* @copyright 2023 P.M. Kuipers
* @license https://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace local_treestudyplan;
defined('MOODLE_INTERNAL') || die();
use local_treestudyplan\local\helpers\webservicehelper;
require_once($CFG->libdir.'/externallib.php');
/**
* Webservice class for handling studyplan reports
*/
class reportservice extends \external_api {
/**
* Capability required to view studyplans (for other users)
* @var string
*/
const CAP_VIEW = "local/treestudyplan:viewuserreports";
public static function get_report_structure_parameters() : \external_function_parameters {
return new \external_function_parameters([
"pageid" => new \external_value(PARAM_INT, 'id of studyplan page'),
"firstperiod" => new \external_value(PARAM_INT, 'first period to include in report',VALUE_DEFAULT),
"lastperiod" => new \external_value(PARAM_INT, 'last perioe to include in report',VALUE_DEFAULT),
]);
}
/**
* Return value description for webservice function list_user_studyplans
*/
public static function get_report_structure_returns() : \external_description {
return new \external_single_structure([
]);
}
/**
* Get studyplan page structure for a report
* @param int $pageid ID of user to check specific info for
* @param int|null $firstperiod First period to include in report
* @param int|null $lastperiod Last period to include in report
* @return object
*/
public static function get_report_structure($pageid,$firstperiod=null,$lastperiod=null) {
}
public static function get_report_data_parameters() : \external_function_parameters {
return new \external_function_parameters([
"pageid" => new \external_value(PARAM_INT, 'id of studyplan page'),
"userid" => new \external_value(PARAM_INT, 'id of user'),
"firstperiod" => new \external_value(PARAM_INT, 'first period to include in report',VALUE_DEFAULT),
"lastperiod" => new \external_value(PARAM_INT, 'last period to include in report',VALUE_DEFAULT),
]);
}
/**
* Return value description for webservice function list_user_studyplans
*/
public static function get_report_data_returns() : \external_description {
return new \external_single_structure([
]);
}
/**
* Get studyplan page structure for a report
* @param int $pageid ID of user to check specific info for
* @param int $userid ID of user to check specific info for
* @param int|null $firstperiod First period to include in report
* @param int|null $lastperiod Last period to include in report
* @return object
*/
public static function get_report_data($pageid,$userid,$firstperiod=null,$lastperiod=null) {
}
public static function get_report_details_parameters() : \external_function_parameters {
return new \external_function_parameters([
"itemid" => new \external_value(PARAM_INT, 'id of studyitem'),
"userid" => new \external_value(PARAM_INT, 'id of user'),
]);
}
/**
* Return value description for webservice function list_user_studyplans
*/
public static function get_report_details_returns() : \external_description {
return new \external_single_structure([
]);
}
/**
* Get study item details for a user
* @param int $itemid ID of study item
* @param int $userid ID of user to check specific info for
* @return array
*/
public static function get_report_details($itemid,$userid) {
}
}