Fixed to backend

This commit is contained in:
PMKuipers 2023-07-23 16:47:02 +02:00
parent 3687461585
commit 24fe99b72b
3 changed files with 51 additions and 3 deletions

View file

@ -195,7 +195,7 @@ class gradeinfo {
"required" => $this->is_required(), "required" => $this->is_required(),
]; ];
// Unfortunately, lazy loading of the completion data is off, since we need the data to show study item completion... // Unfortunately, lazy loading of the completion data is off, since we need the data to show study item completion...
if($studyitem !== null && $this->is_selected() && has_capability('local/treestudyplan:viewuserreports',$studyitem->getStudyline()->studyplan()->context()) if($studyitem !== null && $this->is_selected() && has_capability('local/treestudyplan:viewuserreports',$studyitem->studyline()->studyplan()->context())
&& $this->gradingscanner->is_available()){ && $this->gradingscanner->is_available()){
$model['grading'] = $this->gradingscanner->model(); $model['grading'] = $this->gradingscanner->model();
} }

View file

@ -178,7 +178,31 @@ class studyplan {
} }
} }
$id = $DB->insert_record(self::TABLE, $info); $id = $DB->insert_record(self::TABLE, $info);
return self::findById($id); // make sure the new studyplan is immediately cached $plan = self::findById($id); // make sure the new studyplan is immediately cached
// Start temporary skräpp code
// Add a single page and copy the names.This keeps the data sane until the upgrade to
// real page management is done
// TODO: Remove this when proper page management is implemented
$pageaddable = ['name','shortname','description','slots','startdate','enddate'];
$pageinfo = ['studyplan_id' => $id];
foreach($pageaddable as $f){
if(array_key_exists($f,$fields)){
if($f == "name"){
$pageinfo["fullname"] = $fields[$f];
} else if ($f == "slots") {
$pageinfo["periods"] = $fields[$f];
}else {
$pageinfo[$f] = $fields[$f];
}
}
}
$page = studyplanpage::add($pageinfo);
$plan->page_cache = [$page];
// End temporary skräpp code
return $plan;
} }
public function edit($fields){ public function edit($fields){
@ -199,6 +223,30 @@ class studyplan {
$this->context(); $this->context();
// reload aggregator // reload aggregator
$this->aggregator = aggregator::createOrDefault($this->r->aggregation, $this->r->aggregation_config); $this->aggregator = aggregator::createOrDefault($this->r->aggregation, $this->r->aggregation_config);
// Start temporary skräpp code
// TODO: Until proper page editing is implemented, copy data from studyplan to it's first page
// This keeps the data sane until the upgrade is done.
if(count($this->pages()) == 1){
// update the info to the page as well
$page = $this->pages()[0];
$pageeditable = ['name','shortname','description','slots','startdate','enddate'];
$pageinfo = [];
foreach($pageeditable as $f){
if(array_key_exists($f,$fields)){
if($f == "name"){
$pageinfo["fullname"] = $fields[$f];
} else if ($f == "slots") {
$pageinfo["periods"] = $fields[$f];
}else {
$pageinfo[$f] = $fields[$f];
}
}
}
$page->edit($pageinfo);
}
// End temporary skräpp code
return $this; return $this;
} }

View file

@ -1,6 +1,6 @@
<?php <?php
$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 = 2023071900; // YYYYMMDDHH (year, month, day, iteration) $plugin->version = 2023072300; // 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->dependencies = [ $plugin->dependencies = [