From 1c63ad83c2787e6ce6d9fa353519adc74d70b51c Mon Sep 17 00:00:00 2001 From: PMKuipers Date: Thu, 27 Jul 2023 12:28:04 +0200 Subject: [PATCH] Added pages simple info to studyplan simple info --- amd/src/treestudyplan-components.js | 10 +++++----- classes/studyplan.php | 11 +++++++++-- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/amd/src/treestudyplan-components.js b/amd/src/treestudyplan-components.js index d2f2a12..9674754 100644 --- a/amd/src/treestudyplan-components.js +++ b/amd/src/treestudyplan-components.js @@ -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; diff --git a/classes/studyplan.php b/classes/studyplan.php index 4e0aaf2..0367677 100644 --- a/classes/studyplan.php +++ b/classes/studyplan.php @@ -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, ]; }