Fixing update teachers.

1.9.x
Julio Montoya 11 years ago
parent c6eb4750b8
commit 0167ccfcf4
  1. 22
      main/inc/lib/course.lib.php

@ -4011,6 +4011,8 @@ class CourseManager {
$course_user_table = Database::get_main_table(TABLE_MAIN_COURSE_USER);
$alreadyAddedTeachers = CourseManager::get_teacher_list_from_course_code($course_code);
if ($deleteTeachersNotInList) {
// Delete only teacher relations that doesn't match the selected teachers
@ -4050,23 +4052,23 @@ class CourseManager {
if ($editTeacherInSessions) {
$sessions = SessionManager::get_session_by_course($course_code);
$alreadyAddedTeachers = CourseManager::get_teacher_list_from_course_code($course_code);
if (!empty($sessions)) {
foreach ($sessions as $session) {
// Remove old and add new
if ($deleteSessionTeacherNotInList) {
$coachList = SessionManager::get_users_by_session($session['id'], 2);
// Deleting old coaches
if (!empty($coachList)) {
foreach ($coachList as $coach) {
SessionManager::set_coach_to_course_session($coach['user_id'], $session['id'], $course_code, true);
foreach ($teachers as $userId) {
SessionManager::set_coach_to_course_session($userId, $session['id'], $course_code);
}
$teachersToDelete = array();
if (!empty($alreadyAddedTeachers)) {
$teachersToDelete = array_diff(array_keys($alreadyAddedTeachers), $teachers);
}
// Adding new coaches
foreach ($teachers as $userId) {
SessionManager::set_coach_to_course_session($userId, $session['id'], $course_code);
if (!empty($teachersToDelete)) {
foreach ($teachersToDelete as $userId) {
SessionManager::set_coach_to_course_session($userId, $session['id'], $course_code, true);
}
}
} else {
// Add new

Loading…
Cancel
Save