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

View file

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