From 15063a719269d097ed613ea959f07905c02e96b7 Mon Sep 17 00:00:00 2001
From: Moritz Strohm <strohm@data-quest.de>
Date: Mon, 13 Feb 2023 11:50:34 +0000
Subject: [PATCH] fixed setting lecturers in course/timesrooms/saveDate, closes
 #1812

Closes #1812

Merge request studip/studip!1364
---
 app/controllers/course/timesrooms.php | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/app/controllers/course/timesrooms.php b/app/controllers/course/timesrooms.php
index 887ab112a7c..f21685c84b0 100644
--- a/app/controllers/course/timesrooms.php
+++ b/app/controllers/course/timesrooms.php
@@ -410,9 +410,14 @@ class Course_TimesroomsController extends AuthenticatedController
         // Set assigned teachers
         $assigned_teachers = Request::optionArray('assigned_teachers');
         $dozenten          = $this->course->getMembers();
-        $this->dozenten = [];
-        if(count($dozenten) !== count($assigned_teachers)) {
-            $this->dozenten = User::findMany($assigned_teachers);
+        if (count($assigned_teachers) === count($dozenten) || empty($assigned_teachers)) {
+            //The amount of lecturers of the course date is the same as the amount of lecturers of the course
+            //or no lecturers are assigned to the course date.
+            $termin->dozenten = [];
+        } else {
+            //The assigned lecturers (amount or persons) have been changed in the form.
+            //In those cases, the lecturers of the course date have to be set.
+            $termin->dozenten = User::findMany($assigned_teachers);
         }
 
         // Set assigned groups
-- 
GitLab