Skip to content
Snippets Groups Projects
Commit 2a697c4b authored by Jan-Hendrik Willms's avatar Jan-Hendrik Willms Committed by David Siegfried
Browse files

fix responsible institute assignment for modules, fixes #2434

Closes #2434

Merge request studip/studip!1625
parent 78e742eb
No related branches found
No related tags found
No related merge requests found
...@@ -397,15 +397,21 @@ class Modul extends ModuleManagementModelTreeItem ...@@ -397,15 +397,21 @@ class Modul extends ModuleManagementModelTreeItem
if (!$institute) { if (!$institute) {
return false; return false;
} }
if ($this->responsible_institute && $this->responsible_institute->institut_id != $institut_id) {
$this->responsible_institute && $this->responsible_institute->delete(); if (!$this->responsible_institute || $this->responsible_institute->institut_id !== $institut_id) {
$resp_institute = new ModulInst(); if ($this->responsible_institute) {
$resp_institute->institut_id = $institute->id; $this->responsible_institute->delete();
$resp_institute->modul_id = $this->id; }
$resp_institute->gruppe = 'hauptverantwortlich';
$this->responsible_institute = $resp_institute; $this->responsible_institute = ModulInst::build([
'institut_id' => $institute->id,
'modul_id' => $this->id,
'gruppe' => 'hauptverantwortlich',
]);
} }
$this->assigned_institutes->unsetBy('institut_id', $institute->id); $this->assigned_institutes->unsetBy('institut_id', $institute->id);
return true; return true;
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment