Bugfix in studyplan period creator
This commit is contained in:
parent
9bd0f2002e
commit
cae51717a9
2
amd/build/studyplan-editor-components.min.js
vendored
2
amd/build/studyplan-editor-components.min.js
vendored
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -1455,7 +1455,7 @@ export default {
|
|||
if(modalresponse){
|
||||
call([{
|
||||
methodname: 'local_treestudyplan_delete_studyplan',
|
||||
args: { 'id': studyplan.id, }
|
||||
args: { 'id': studyplan.id, force: true}
|
||||
}])[0].done(function(response){
|
||||
if(response.success == true){
|
||||
self.$root.$emit("studyplanRemoved",studyplan);
|
||||
|
|
|
@ -195,7 +195,7 @@ class studyplan {
|
|||
// TODO: Remove this when proper page management is implemented
|
||||
if(!$bare){
|
||||
|
||||
$pageaddable = ['name','shortname','description',];
|
||||
$pageaddable = ['name','shortname','description','periods','startdate','enddate'];
|
||||
$pageinfo = ['studyplan_id' => $id];
|
||||
foreach($pageaddable as $f){
|
||||
if(array_key_exists($f,$fields)){
|
||||
|
@ -217,7 +217,7 @@ class studyplan {
|
|||
|
||||
public function edit($fields){
|
||||
global $DB;
|
||||
$editable = ['name','shortname','description','idnumber','context_id','periods','startdate','enddate','aggregation','aggregation_config'];
|
||||
$editable = ['name','shortname','description','idnumber','context_id','aggregation','aggregation_config'];
|
||||
$info = ['id' => $this->id,];
|
||||
foreach($editable as $f){
|
||||
if(array_key_exists($f,$fields)){
|
||||
|
@ -240,7 +240,7 @@ class studyplan {
|
|||
if(count($this->pages()) == 1){
|
||||
// update the info to the page as well
|
||||
$page = $this->pages()[0];
|
||||
$pageeditable = ['name','shortname','description'];
|
||||
$pageeditable = ['name','shortname','description','periods','startdate','enddate'];
|
||||
$pageinfo = [];
|
||||
foreach($pageeditable as $f){
|
||||
if(array_key_exists($f,$fields)){
|
||||
|
|
|
@ -145,6 +145,12 @@ class studyplanpage {
|
|||
$info[$f] = $fields[$f];
|
||||
}
|
||||
}
|
||||
if(!isset($addable['periods'])){
|
||||
$addable['periods'] = 4;
|
||||
} else if($addable['periods'] < 1){
|
||||
$addable['periods'] = 1;
|
||||
}
|
||||
|
||||
$id = $DB->insert_record(self::TABLE, $info);
|
||||
return self::findById($id); // make sure the new page is immediately cached
|
||||
}
|
||||
|
@ -158,6 +164,10 @@ class studyplanpage {
|
|||
$info[$f] = $fields[$f];
|
||||
}
|
||||
}
|
||||
if(isset($info['periods']) && $info['periods'] < 1){
|
||||
$info['periods'] = 1;
|
||||
}
|
||||
|
||||
$DB->update_record(self::TABLE, $info);
|
||||
//reload record after edit
|
||||
$this->r = $DB->get_record(self::TABLE,['id' => $this->id],"*",MUST_EXIST);
|
||||
|
|
Loading…
Reference in New Issue
Block a user