Fixed to backend
This commit is contained in:
parent
3687461585
commit
24fe99b72b
|
@ -195,7 +195,7 @@ class gradeinfo {
|
|||
"required" => $this->is_required(),
|
||||
];
|
||||
// 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()){
|
||||
$model['grading'] = $this->gradingscanner->model();
|
||||
}
|
||||
|
|
|
@ -178,7 +178,31 @@ class studyplan {
|
|||
}
|
||||
}
|
||||
$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){
|
||||
|
@ -199,6 +223,30 @@ class studyplan {
|
|||
$this->context();
|
||||
// reload aggregator
|
||||
$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;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
$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->dependencies = [
|
||||
|
|
Loading…
Reference in New Issue
Block a user