Added pages simple info to studyplan simple info

This commit is contained in:
PMKuipers 2023-07-27 12:28:04 +02:00
parent dcc9b5bcd6
commit 1c63ad83c2
2 changed files with 14 additions and 7 deletions

View File

@ -45,11 +45,11 @@ export default {
computed: {
timing(){
const now = new Date().getTime();
const startdate = new Date(this.value.startdate).getTime();
const enddate = new Date(this.value.enddate).getTime();
const startdate = new Date(this.value.pages[0].startdate).getTime();
const enddate = new Date(this.value.pages[0].enddate).getTime();
let timing = 'future';
if(startdate < now){
if(this.value.enddate && now > enddate) {
if(this.value.pages[0].enddate && now > enddate) {
timing = 'past';
} else {
timing = 'present';
@ -61,14 +61,14 @@ export default {
const opts = {
year: 'numeric', month: 'short', day: 'numeric'
};
return new Date(this.value.startdate).toLocaleDateString(document.documentElement.lang,opts);
return new Date(this.value.pages[0].startdate).toLocaleDateString(document.documentElement.lang,opts);
},
enddate(){
if(this.value.enddate){
const opts = {
year: 'numeric', month: 'short', day: 'numeric'
};
return new Date(this.value.enddate).toLocaleDateString(document.documentElement.lang,opts);
return new Date(this.value.pages[0].enddate).toLocaleDateString(document.documentElement.lang,opts);
}
else {
return this.text.noenddate;

View File

@ -88,19 +88,26 @@ class studyplan {
"aggregation" => new \external_value(PARAM_TEXT, 'selected aggregator'),
"aggregation_config" => new \external_value(PARAM_TEXT, 'config string for aggregator'),
"aggregation_info" => aggregator::basic_structure(),
"pages" => new \external_multiple_structure(studyplanpage::simple_structure(),'pages'),
],'Basic studyplan info',$value);
}
public function simple_model(){
$pages = [];
foreach($this->pages() as $p){
$pages[] = $p->simple_model();
}
return [
'id' => $this->r->id,
'name' => $this->r->name,
'shortname' => $this->r->shortname,
'context_id' => $this->context()->id,
'description' => $this->r->description,
"aggregation" => $this->r->aggregation,
"aggregation_config" => $this->aggregator->config_string(),
'aggregation' => $this->r->aggregation,
'aggregation_config' => $this->aggregator->config_string(),
'aggregation_info' => $this->aggregator->basic_model(),
'pages' => $pages,
];
}