Added foundation for overview report

This commit is contained in:
PMKuipers 2024-02-09 14:48:15 +01:00
parent e42323a2e4
commit a717acf4e4
9 changed files with 325 additions and 1 deletions

View File

@ -0,0 +1,3 @@
define("local_treestudyplan/page-studyplan-report",["exports","core/ajax","core/notification","./vue/vue","./util/debugger","./util/string-helper","./studyplan-processor","./util/date-helper","./treestudyplan-components","./modedit-modal","./portal-vue/portal-vue.esm","./bootstrap-vue/bootstrap-vue"],(function(_exports,_ajax,_notification,_vue,_debugger,_stringHelper,_studyplanProcessor,_dateHelper,_treestudyplanComponents,_modeditModal,_portalVue,_bootstrapVue){function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj}}Object.defineProperty(_exports,"__esModule",{value:!0}),_exports.init=function(studyplanid,period){studyplanid=void 0!==studyplanid&&Number.isInteger(Number(studyplanid))?Number(studyplanid):0;new _vue.default({el:"#root",data:{},async mounted(){},computed:{},methods:{}})},_notification=_interopRequireDefault(_notification),_vue=_interopRequireDefault(_vue),_debugger=_interopRequireDefault(_debugger),_treestudyplanComponents=_interopRequireDefault(_treestudyplanComponents),_modeditModal=_interopRequireDefault(_modeditModal),_portalVue=_interopRequireDefault(_portalVue),_bootstrapVue=_interopRequireDefault(_bootstrapVue),_vue.default.use(_modeditModal.default),_vue.default.use(_portalVue.default),_vue.default.use(_bootstrapVue.default);new _debugger.default("treestudyplanviewer"),(0,_stringHelper.load_strings)({studyplan:{studyplan_select_placeholder:"studyplan_select_placeholder"}})}));
//# sourceMappingURL=page-studyplan-report.min.js.map

View File

@ -0,0 +1 @@
{"version":3,"file":"page-studyplan-report.min.js","sources":["../src/page-studyplan-report.js"],"sourcesContent":["/*eslint no-var: \"error\" */\n/*eslint no-unused-vars: \"off\" */\n/*eslint linebreak-style: \"off\" */\n/*eslint no-trailing-spaces: \"off\" */\n/*eslint-env es6*/\n// Put this file in path/to/plugin/amd/src\n// You can call it anything you like\n\nimport {call} from 'core/ajax';\nimport notification from 'core/notification';\n\nimport Vue from './vue/vue';\n\nimport Debugger from './util/debugger';\nimport {load_strings} from './util/string-helper';\nimport {ProcessStudyplan} from './studyplan-processor';\nimport {studyplanTiming} from './util/date-helper';\n\nimport TSComponents from './treestudyplan-components';\nimport ModalComponents from './modedit-modal';\nVue.use(ModalComponents);\n\nimport PortalVue from './portal-vue/portal-vue.esm';\nVue.use(PortalVue);\nimport BootstrapVue from './bootstrap-vue/bootstrap-vue';\nVue.use(BootstrapVue);\n\n\nlet debug = new Debugger(\"treestudyplanviewer\");\n\nlet strings = load_strings({\n studyplan: {\n studyplan_select_placeholder: 'studyplan_select_placeholder',\n },\n});\n\n/**\n * Initialize the Page\n * @param {Number} studyplanid The id of the studyplan we need to view \n * @param {Number} period The id of the studyplan we need to view \n */\nexport function init(studyplanid,period) {\n // Make sure the id's are numeric and integer\n if (undefined === studyplanid || !Number.isInteger(Number(studyplanid)) ){ \n studyplanid = 0;\n } else {\n studyplanid = Number(studyplanid);\n } // ensure a numeric value instead of string.\n\n const app = new Vue({\n el: '#root',\n data: {\n\n },\n async mounted() {\n \n },\n computed: {\n \n },\n methods: {\n \n },\n });\n}\n"],"names":["studyplanid","period","undefined","Number","isInteger","Vue","el","data","computed","methods","use","ModalComponents","PortalVue","BootstrapVue","Debugger","studyplan","studyplan_select_placeholder"],"mappings":"onBAyCqBA,YAAYC,QAKzBD,iBAHAE,IAAcF,aAAgBG,OAAOC,UAAUD,OAAOH,cAGxCG,OAAOH,aAFP,EAKN,IAAIK,aAAI,CAChBC,GAAI,QACJC,KAAM,qBAMNC,SAAU,GAGVC,QAAS,qXAxCbC,IAAIC,oCAGJD,IAAIE,iCAEJF,IAAIG,uBAGI,IAAIC,kBAAS,wBAEX,8BAAa,CACvBC,UAAW,CACPC,6BAA8B"}

3
amd/build/page-view-plan copy.min.js vendored Normal file

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,65 @@
/*eslint no-var: "error" */
/*eslint no-unused-vars: "off" */
/*eslint linebreak-style: "off" */
/*eslint no-trailing-spaces: "off" */
/*eslint-env es6*/
// Put this file in path/to/plugin/amd/src
// You can call it anything you like
import {call} from 'core/ajax';
import notification from 'core/notification';
import Vue from './vue/vue';
import Debugger from './util/debugger';
import {load_strings} from './util/string-helper';
import {ProcessStudyplan} from './studyplan-processor';
import {studyplanTiming} from './util/date-helper';
import TSComponents from './treestudyplan-components';
import ModalComponents from './modedit-modal';
Vue.use(ModalComponents);
import PortalVue from './portal-vue/portal-vue.esm';
Vue.use(PortalVue);
import BootstrapVue from './bootstrap-vue/bootstrap-vue';
Vue.use(BootstrapVue);
let debug = new Debugger("treestudyplanviewer");
let strings = load_strings({
studyplan: {
studyplan_select_placeholder: 'studyplan_select_placeholder',
},
});
/**
* Initialize the Page
* @param {Number} studyplanid The id of the studyplan we need to view
* @param {Number} period The id of the studyplan we need to view
*/
export function init(studyplanid,period) {
// Make sure the id's are numeric and integer
if (undefined === studyplanid || !Number.isInteger(Number(studyplanid)) ){
studyplanid = 0;
} else {
studyplanid = Number(studyplanid);
} // ensure a numeric value instead of string.
const app = new Vue({
el: '#root',
data: {
},
async mounted() {
},
computed: {
},
methods: {
},
});
}

125
classes/reportservice.php Normal file
View File

@ -0,0 +1,125 @@
<?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) {
}
}

View File

@ -314,6 +314,9 @@ $functions = [
'capabilities' => 'local/treestudyplan:editstudyplan', 'capabilities' => 'local/treestudyplan:editstudyplan',
'loginrequired' => true, 'loginrequired' => true,
], ],
/***************************
* Category mapping
***************************/
'local_treestudyplan_map_categories' => [ // Web service function name. 'local_treestudyplan_map_categories' => [ // Web service function name.
'classname' => '\local_treestudyplan\courseservice', // Class containing the external function. 'classname' => '\local_treestudyplan\courseservice', // Class containing the external function.
'methodname' => 'map_categories', // External function name. 'methodname' => 'map_categories', // External function name.
@ -368,6 +371,9 @@ $functions = [
'capabilities' => 'local/treestudyplan:viewuserreports', 'capabilities' => 'local/treestudyplan:viewuserreports',
'loginrequired' => true, 'loginrequired' => true,
], ],
/***************************
* Studyplan functions
***************************/
'local_treestudyplan_list_aggregators' => [ // Web service function name. 'local_treestudyplan_list_aggregators' => [ // Web service function name.
'classname' => '\local_treestudyplan\studyplanservice', // Class containing the external function. 'classname' => '\local_treestudyplan\studyplanservice', // Class containing the external function.
'methodname' => 'list_aggregators', // External function name. 'methodname' => 'list_aggregators', // External function name.
@ -674,4 +680,34 @@ $functions = [
'capabilities' => '', 'capabilities' => '',
'loginrequired' => true, 'loginrequired' => true,
], ],
/***************************
* Studyplan report functions
***************************/
'local_treestudyplan_get_report_structure' => [ // Web service function name.
'classname' => '\local_treestudyplan\reportservice', // Class containing the external function.
'methodname' => 'get_report_structure', // External function name.
'description' => 'Retrieve studyplan report structure',
'type' => 'read', // Database rights of the web service function (read, write).
'ajax' => true,
'capabilities' => 'local/treestudyplan:viewuserreports',
'loginrequired' => true,
],
'local_treestudyplan_get_report_data' => [ // Web service function name.
'classname' => '\local_treestudyplan\reportservice', // Class containing the external function.
'methodname' => 'get_report_data', // External function name.
'description' => 'Retrieve studyplan report data for student ',
'type' => 'read', // Database rights of the web service function (read, write).
'ajax' => true,
'capabilities' => 'local/treestudyplan:viewuserreports',
'loginrequired' => true,
],
'local_treestudyplan_get_report_details' => [ // Web service function name.
'classname' => '\local_treestudyplan\reportservice', // Class containing the external function.
'methodname' => 'get_report_details', // External function name.
'description' => 'Retrieve studyplan report details for student ',
'type' => 'read', // Database rights of the web service function (read, write).
'ajax' => true,
'capabilities' => 'local/treestudyplan:viewuserreports',
'loginrequired' => true,
],
]; ];

90
studyplan-report.php Normal file
View File

@ -0,0 +1,90 @@
<?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/>.
/**
* Report
* @package local_treestudyplan
* @copyright 2023 P.M. Kuipers
* @license https://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
require_once("../../config.php");
use local_treestudyplan\contextinfo;
use \local_treestudyplan\courseservice;
use \local_treestudyplan\studyplan;
use \local_treestudyplan\studyplanpage;
require_once($CFG->libdir.'/weblib.php');
$PAGE->set_url("/local/treestudyplan/studyplan-report.php", array());
require_login();
// Figure out the context (category or system, based on either category or context parameter).
$pageid = required_param('page', 0, PARAM_INT); // Category id.
$page = studyplanpage::find_by_id($pageid);
$studyplan = $page->studyplan();
$context = $studyplan->context();
$contexname = (new contextinfo($studyplancontext))->pathstr();
$firstperiod = optional_param('firstperiod', 0, PARAM_INT); // First period to show
$lastperiod = optional_param('lastperiod', 0, PARAM_INT); // Last periode to show
$PAGE->set_pagelayout('base');
//$PAGE->set_context($studyplancontext);
$PAGE->set_title(get_string('studyplan_report', 'local_treestudyplan')." - ".$contextname);
$PAGE->set_heading(get_string('studyplan_report', 'local_treestudyplan')." - ".$contextname);
if(!has_capability('local/treestudyplan:viewuserreports', $studyplancontext)) {
throw new \moodle_exception("error:nostudyplanviewaccess","local_treestudyplan","",$contextname);
}
// Load javascripts and specific css.
$PAGE->requires->css(new moodle_url($CFG->wwwroot.'/local/treestudyplan/css/bootstrap-vue/bootstrap-vue.css'));
if ($CFG->debugdeveloper) {
$PAGE->requires->css(new moodle_url($CFG->wwwroot.'/local/treestudyplan/css/devstyles.css'));
}
$PAGE->requires->js_call_amd('local_treestudyplan/page-studyplan-report', 'init', [$studyplan->id(), $page->id(), $firstperiod, $lastperiod]);
/**
* Shortcut function to provide translations
*
* @param mixed $str Translation key
* @param null|string[] $param Parameters to pass to translation
* @param string $plugin Location to search for translation strings
* @return string Translation of key
*/
function t($str, $param = null, $plugin = 'local_treestudyplan') {
print get_string($str, $plugin, $param);
}
print $OUTPUT->header();
?>
<div id='root'>
<div class='vue-loader' v-show='false'>
<div class="spinner-border text-primary" role="status">
<span class="sr-only">Loading...</span>
</div>
</div>
<div v-cloak>
</div>
</div>
<?php
print $OUTPUT->footer();

View File

@ -22,7 +22,7 @@
defined('MOODLE_INTERNAL') || die(); defined('MOODLE_INTERNAL') || die();
$plugin->component = 'local_treestudyplan'; // Recommended since 2.0.2 (MDL-26035). Required since 3.0 (MDL-48494). $plugin->component = 'local_treestudyplan'; // Recommended since 2.0.2 (MDL-26035). Required since 3.0 (MDL-48494).
$plugin->version = 2024020702; // YYYYMMDDHH (year, month, day, iteration). $plugin->version = 2024020900; // YYYYMMDDHH (year, month, day, iteration).
$plugin->requires = 2021051700; // YYYYMMDDHH (This is the release version for Moodle 3.11). $plugin->requires = 2021051700; // YYYYMMDDHH (This is the release version for Moodle 3.11).
$plugin->release = "1.1.0"; $plugin->release = "1.1.0";