|
|
@ -1705,7 +1705,6 @@ class SessionManager |
|
|
|
$session_visibility = intval($session_visibility); |
|
|
|
$session_visibility = intval($session_visibility); |
|
|
|
|
|
|
|
|
|
|
|
$nbr_users = 0; |
|
|
|
$nbr_users = 0; |
|
|
|
|
|
|
|
|
|
|
|
foreach ($user_list as $enreg_user) { |
|
|
|
foreach ($user_list as $enreg_user) { |
|
|
|
$enreg_user = intval($enreg_user); |
|
|
|
$enreg_user = intval($enreg_user); |
|
|
|
// Checking if user exists in session - course - user table. |
|
|
|
// Checking if user exists in session - course - user table. |
|
|
@ -3352,7 +3351,8 @@ class SessionManager |
|
|
|
$fieldsToAvoidUpdate = array(), |
|
|
|
$fieldsToAvoidUpdate = array(), |
|
|
|
$deleteUsersNotInList = false, |
|
|
|
$deleteUsersNotInList = false, |
|
|
|
$updateCourseCoaches = false, |
|
|
|
$updateCourseCoaches = false, |
|
|
|
$sessionWithCoursesModifier = false |
|
|
|
$sessionWithCoursesModifier = false, |
|
|
|
|
|
|
|
$addOriginalCourseTeachersAsCourseSessionCoaches = true |
|
|
|
) { |
|
|
|
) { |
|
|
|
$content = file($file); |
|
|
|
$content = file($file); |
|
|
|
|
|
|
|
|
|
|
@ -3402,7 +3402,10 @@ class SessionManager |
|
|
|
foreach ($enreg as $tag_name) { |
|
|
|
foreach ($enreg as $tag_name) { |
|
|
|
$tag_names[] = api_preg_replace('/[^a-zA-Z0-9_\-]/', '', $tag_name); |
|
|
|
$tag_names[] = api_preg_replace('/[^a-zA-Z0-9_\-]/', '', $tag_name); |
|
|
|
} |
|
|
|
} |
|
|
|
if (!in_array('SessionName', $tag_names) || !in_array('DateStart', $tag_names) || !in_array('DateEnd', $tag_names)) { |
|
|
|
if (!in_array('SessionName', $tag_names) || |
|
|
|
|
|
|
|
!in_array('DateStart', $tag_names) || |
|
|
|
|
|
|
|
!in_array('DateEnd', $tag_names) |
|
|
|
|
|
|
|
) { |
|
|
|
$error_message = get_lang('NoNeededData'); |
|
|
|
$error_message = get_lang('NoNeededData'); |
|
|
|
break; |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
@ -3422,6 +3425,23 @@ class SessionManager |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
$session_name = Database::escape_string($enreg['SessionName']); |
|
|
|
$session_name = Database::escape_string($enreg['SessionName']); |
|
|
|
|
|
|
|
// Default visibility |
|
|
|
|
|
|
|
$visibilityAfterExpirationPerSession = $sessionVisibility; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (isset($enreg['VisibilityAfterExpiration'])) { |
|
|
|
|
|
|
|
$visibility = $enreg['VisibilityAfterExpiration']; |
|
|
|
|
|
|
|
switch ($visibility) { |
|
|
|
|
|
|
|
case 'read_only': |
|
|
|
|
|
|
|
$visibilityAfterExpirationPerSession = SESSION_VISIBLE_READ_ONLY; |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
case 'accessible': |
|
|
|
|
|
|
|
$visibilityAfterExpirationPerSession = SESSION_VISIBLE; |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
case 'not_accessible': |
|
|
|
|
|
|
|
$visibilityAfterExpirationPerSession = SESSION_INVISIBLE; |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (empty($session_name)) { |
|
|
|
if (empty($session_name)) { |
|
|
|
continue; |
|
|
|
continue; |
|
|
@ -3429,7 +3449,6 @@ class SessionManager |
|
|
|
|
|
|
|
|
|
|
|
$date_start = $enreg['DateStart']; |
|
|
|
$date_start = $enreg['DateStart']; |
|
|
|
$date_end = $enreg['DateEnd']; |
|
|
|
$date_end = $enreg['DateEnd']; |
|
|
|
$visibility = isset($enreg['Visibility']) ? $enreg['Visibility'] : $sessionVisibility; |
|
|
|
|
|
|
|
$session_category_id = isset($enreg['SessionCategory']) ? $enreg['SessionCategory'] : null; |
|
|
|
$session_category_id = isset($enreg['SessionCategory']) ? $enreg['SessionCategory'] : null; |
|
|
|
$sessionDescription = isset($enreg['SessionDescription']) ? $enreg['SessionDescription'] : null; |
|
|
|
$sessionDescription = isset($enreg['SessionDescription']) ? $enreg['SessionDescription'] : null; |
|
|
|
|
|
|
|
|
|
|
@ -3476,7 +3495,7 @@ class SessionManager |
|
|
|
id_coach = '$coach_id', |
|
|
|
id_coach = '$coach_id', |
|
|
|
date_start = '$date_start', |
|
|
|
date_start = '$date_start', |
|
|
|
date_end = '$date_end', |
|
|
|
date_end = '$date_end', |
|
|
|
visibility = '$visibility', |
|
|
|
visibility = '$visibilityAfterExpirationPerSession', |
|
|
|
session_category_id = '$session_category_id', |
|
|
|
session_category_id = '$session_category_id', |
|
|
|
session_admin_id = " . intval($defaultUserId) . $extraParameters . $extraSessionParameters; |
|
|
|
session_admin_id = " . intval($defaultUserId) . $extraParameters . $extraSessionParameters; |
|
|
|
Database::query($sql); |
|
|
|
Database::query($sql); |
|
|
@ -3527,20 +3546,15 @@ class SessionManager |
|
|
|
$session_id = $my_session_result['id']; |
|
|
|
$session_id = $my_session_result['id']; |
|
|
|
|
|
|
|
|
|
|
|
if ($session_id) { |
|
|
|
if ($session_id) { |
|
|
|
if ($session_id) { |
|
|
|
|
|
|
|
foreach ($enreg as $key => $value) { |
|
|
|
foreach ($enreg as $key => $value) { |
|
|
|
if (substr($key, 0, 6) == 'extra_') { //an extra field |
|
|
|
if (substr($key, 0, 6) == 'extra_') { //an extra field |
|
|
|
self::update_session_extra_field_value($session_id, substr($key, 6), $value); |
|
|
|
self::update_session_extra_field_value($session_id, substr($key, 6), $value); |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if ($debug) { |
|
|
|
|
|
|
|
$logger->addInfo("Sessions - #$session_id created: $session_name"); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
if ($debug) { |
|
|
|
|
|
|
|
$logger->addError("Sessions - Session NOT created: $session_name"); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
if ($debug) { |
|
|
|
|
|
|
|
$logger->addInfo("Sessions - #$session_id created: $session_name"); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// Delete session-user relation only for students |
|
|
|
// Delete session-user relation only for students |
|
|
|
$sql = "DELETE FROM $tbl_session_user |
|
|
|
$sql = "DELETE FROM $tbl_session_user |
|
|
@ -3561,6 +3575,9 @@ class SessionManager |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
|
|
|
|
if ($debug) { |
|
|
|
|
|
|
|
$logger->addError("Sessions - Session to be updated: $session_name"); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// Updating the session. |
|
|
|
// Updating the session. |
|
|
|
$params = array( |
|
|
|
$params = array( |
|
|
@ -3592,7 +3609,6 @@ class SessionManager |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if ($session_id) { |
|
|
|
if ($session_id) { |
|
|
|
|
|
|
|
|
|
|
|
foreach ($enreg as $key => $value) { |
|
|
|
foreach ($enreg as $key => $value) { |
|
|
|
if (substr($key, 0, 6) == 'extra_') { //an extra field |
|
|
|
if (substr($key, 0, 6) == 'extra_') { //an extra field |
|
|
|
self::update_session_extra_field_value($session_id, substr($key, 6), $value); |
|
|
|
self::update_session_extra_field_value($session_id, substr($key, 6), $value); |
|
|
@ -3627,6 +3643,7 @@ class SessionManager |
|
|
|
|
|
|
|
|
|
|
|
// Adding the relationship "Session - User" for students |
|
|
|
// Adding the relationship "Session - User" for students |
|
|
|
$userList = array(); |
|
|
|
$userList = array(); |
|
|
|
|
|
|
|
|
|
|
|
if (is_array($users)) { |
|
|
|
if (is_array($users)) { |
|
|
|
foreach ($users as $user) { |
|
|
|
foreach ($users as $user) { |
|
|
|
$user_id = UserManager::get_user_id_from_username($user); |
|
|
|
$user_id = UserManager::get_user_id_from_username($user); |
|
|
@ -3671,7 +3688,6 @@ class SessionManager |
|
|
|
$removeAllTeachersFromCourse = false; |
|
|
|
$removeAllTeachersFromCourse = false; |
|
|
|
|
|
|
|
|
|
|
|
if ($sessionWithCoursesModifier) { |
|
|
|
if ($sessionWithCoursesModifier) { |
|
|
|
|
|
|
|
|
|
|
|
if (count($courses) >= 2) { |
|
|
|
if (count($courses) >= 2) { |
|
|
|
// Only first teacher in course session; |
|
|
|
// Only first teacher in course session; |
|
|
|
$onlyAddFirstCoachOrTeacher = true; |
|
|
|
$onlyAddFirstCoachOrTeacher = true; |
|
|
@ -3719,7 +3735,11 @@ class SessionManager |
|
|
|
// If any user provided for a course, use the users array. |
|
|
|
// If any user provided for a course, use the users array. |
|
|
|
if (empty($course_users)) { |
|
|
|
if (empty($course_users)) { |
|
|
|
if (!empty($userList)) { |
|
|
|
if (!empty($userList)) { |
|
|
|
SessionManager::subscribe_users_to_session_course($userList, $session_id, $course_code); |
|
|
|
SessionManager::subscribe_users_to_session_course( |
|
|
|
|
|
|
|
$userList, |
|
|
|
|
|
|
|
$session_id, |
|
|
|
|
|
|
|
$course_code |
|
|
|
|
|
|
|
); |
|
|
|
if ($debug) { |
|
|
|
if ($debug) { |
|
|
|
$msg = "Sessions - Adding student list ".implode(', #', $userList)." to course: '$course_code' and session #$session_id"; |
|
|
|
$msg = "Sessions - Adding student list ".implode(', #', $userList)." to course: '$course_code' and session #$session_id"; |
|
|
|
$logger->addInfo($msg); |
|
|
|
$logger->addInfo($msg); |
|
|
@ -3732,16 +3752,25 @@ class SessionManager |
|
|
|
$savedCoaches = array(); |
|
|
|
$savedCoaches = array(); |
|
|
|
// only edit if add_teachers_to_sessions_courses is set. |
|
|
|
// only edit if add_teachers_to_sessions_courses is set. |
|
|
|
if ($addTeachersToSession) { |
|
|
|
if ($addTeachersToSession) { |
|
|
|
// Adding course teachers as course session teachers. |
|
|
|
|
|
|
|
$alreadyAddedTeachers = CourseManager::get_teacher_list_from_course_code($course_code); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!empty($alreadyAddedTeachers)) { |
|
|
|
if ($addOriginalCourseTeachersAsCourseSessionCoaches) { |
|
|
|
$teachersToAdd = array(); |
|
|
|
// Adding course teachers as course session teachers. |
|
|
|
foreach ($alreadyAddedTeachers as $user) { |
|
|
|
$alreadyAddedTeachers = CourseManager::get_teacher_list_from_course_code( |
|
|
|
$teachersToAdd[] = $user['username']; |
|
|
|
$course_code |
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!empty($alreadyAddedTeachers)) { |
|
|
|
|
|
|
|
$teachersToAdd = array(); |
|
|
|
|
|
|
|
foreach ($alreadyAddedTeachers as $user) { |
|
|
|
|
|
|
|
$teachersToAdd[] = $user['username']; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
$course_coaches = array_merge( |
|
|
|
|
|
|
|
$course_coaches, |
|
|
|
|
|
|
|
$teachersToAdd |
|
|
|
|
|
|
|
); |
|
|
|
} |
|
|
|
} |
|
|
|
$course_coaches = array_merge($course_coaches, $teachersToAdd); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
foreach ($course_coaches as $course_coach) { |
|
|
|
foreach ($course_coaches as $course_coach) { |
|
|
|
$coach_id = UserManager::get_user_id_from_username($course_coach); |
|
|
|
$coach_id = UserManager::get_user_id_from_username($course_coach); |
|
|
|
if ($coach_id !== false) { |
|
|
|
if ($coach_id !== false) { |
|
|
|