2023-05-17 21:19:14 +02:00
|
|
|
/*eslint no-var: "error" */
|
|
|
|
/*eslint no-unused-vars: "off" */
|
|
|
|
/*eslint linebreak-style: "off" */
|
|
|
|
/*eslint no-trailing-spaces: "off" */
|
|
|
|
/*eslint no-console: "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';
|
2023-08-19 17:54:40 +02:00
|
|
|
|
2023-08-22 23:12:33 +02:00
|
|
|
import Vue from './vue/vue';
|
2023-08-19 17:54:40 +02:00
|
|
|
|
2023-05-17 21:19:14 +02:00
|
|
|
import RVComponents from './report-viewer-components';
|
2023-08-19 17:54:40 +02:00
|
|
|
Vue.use(RVComponents);
|
|
|
|
|
2023-05-17 21:19:14 +02:00
|
|
|
import TSComponents from './treestudyplan-components';
|
2023-08-19 17:54:40 +02:00
|
|
|
import Debugger from './util/debugger';
|
2023-05-17 21:19:14 +02:00
|
|
|
|
2023-07-18 13:19:36 +02:00
|
|
|
import {ProcessStudyplans} from './studyplan-processor';
|
2023-05-17 21:19:14 +02:00
|
|
|
|
|
|
|
|
2023-08-19 17:54:40 +02:00
|
|
|
import PortalVue from './portal-vue/portal-vue.esm';
|
2023-05-17 21:19:14 +02:00
|
|
|
Vue.use(PortalVue);
|
2023-08-19 17:54:40 +02:00
|
|
|
import BootstrapVue from './bootstrap-vue/bootstrap-vue.esm';
|
2023-05-17 21:19:14 +02:00
|
|
|
Vue.use(BootstrapVue);
|
|
|
|
|
|
|
|
let debug = new Debugger("treestudyplan-report");
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Initialize the Page
|
|
|
|
* @param {string} type Type of page to show
|
|
|
|
* @param {Object} arg Arguments passed
|
|
|
|
*/
|
|
|
|
export function init(type="myreport",arg) {
|
|
|
|
let app = new Vue({
|
|
|
|
el: '#root',
|
|
|
|
data: {
|
|
|
|
"studyplans": [],
|
|
|
|
},
|
|
|
|
mounted() {
|
|
|
|
let call_method;
|
|
|
|
let call_args;
|
|
|
|
if(type == "invited"){
|
|
|
|
call_method = 'local_treestudyplan_get_invited_studyplan';
|
|
|
|
call_args = {"invitekey": arg};
|
|
|
|
}
|
|
|
|
else if(type == "other"){
|
|
|
|
call_method = 'local_treestudyplan_get_user_studyplans';
|
|
|
|
call_args = {"userid": arg};
|
|
|
|
}
|
|
|
|
else if(type == "teaching"){
|
|
|
|
call_method = 'local_treestudyplan_get_teaching_studyplans';
|
|
|
|
call_args = {};
|
|
|
|
}
|
|
|
|
else{
|
|
|
|
call_method = 'local_treestudyplan_get_own_studyplan';
|
|
|
|
call_args = {};
|
|
|
|
}
|
|
|
|
call([{
|
|
|
|
methodname: call_method,
|
|
|
|
args: call_args
|
|
|
|
}])[0].done(function(response){
|
|
|
|
debug.info("Studyplans:",response);
|
|
|
|
const timingval = { future: 0, present: 1, past: 2, };
|
|
|
|
response.sort((a,b) => {
|
|
|
|
const timinga = TSComponents.studyplanTiming(a);
|
|
|
|
const timingb = TSComponents.studyplanTiming(b);
|
|
|
|
|
|
|
|
let t = timingval[timinga] - timingval[timingb];
|
|
|
|
if(t == 0){
|
|
|
|
// sort by start date if timing is equal
|
|
|
|
t = new Date(b.startdate).getTime() - new Date(a.startdate).getTime();
|
|
|
|
|
|
|
|
if (t == 0) {
|
|
|
|
// sort by name if timing is equal
|
|
|
|
t = a.name.localeCompare(b.name);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return t;
|
|
|
|
});
|
|
|
|
app.studyplans = ProcessStudyplans(response);
|
|
|
|
}).fail(notification.exception);
|
|
|
|
|
|
|
|
},
|
2023-07-18 16:12:31 +02:00
|
|
|
|
2023-05-17 21:19:14 +02:00
|
|
|
methods: {
|
|
|
|
|
|
|
|
},
|
|
|
|
});
|
|
|
|
|
|
|
|
}
|
|
|
|
|