| @@ 2509-2539 (lines=31) @@ | ||
| 2506 | ||
| 2507 | ||
| 2508 | $students = isset($data['students']) ? explode(',', $data['students']) : []; |
|
| 2509 | if (!empty($students)) { |
|
| 2510 | $studentUserIdList = array(); |
|
| 2511 | foreach ($students as $student) { |
|
| 2512 | $userInfo = api_get_user_info_from_username($student); |
|
| 2513 | ||
| 2514 | if (!$userInfo) { |
|
| 2515 | continue; |
|
| 2516 | } |
|
| 2517 | ||
| 2518 | if ( |
|
| 2519 | !CourseManager::is_user_subscribed_in_course( |
|
| 2520 | $userInfo['user_id'], |
|
| 2521 | $courseCode, |
|
| 2522 | !empty($sessionId), |
|
| 2523 | $sessionId |
|
| 2524 | ) |
|
| 2525 | ) { |
|
| 2526 | Display::addFlash( |
|
| 2527 | Display::return_message( |
|
| 2528 | sprintf(get_lang('StudentXIsNotSubscribedToCourse'), $userInfo['complete_name']), |
|
| 2529 | 'warning' |
|
| 2530 | ) |
|
| 2531 | ); |
|
| 2532 | ||
| 2533 | continue; |
|
| 2534 | } |
|
| 2535 | ||
| 2536 | $studentUserIdList[] = $userInfo['user_id']; |
|
| 2537 | } |
|
| 2538 | self::subscribe_users($studentUserIdList, $groupInfo); |
|
| 2539 | } |
|
| 2540 | ||
| 2541 | $tutors = isset($data['tutors']) ? explode(',', $data['tutors']) : []; |
|
| 2542 | if (!empty($tutors)) { |
|
| @@ 2542-2572 (lines=31) @@ | ||
| 2539 | } |
|
| 2540 | ||
| 2541 | $tutors = isset($data['tutors']) ? explode(',', $data['tutors']) : []; |
|
| 2542 | if (!empty($tutors)) { |
|
| 2543 | $tutorIdList = array(); |
|
| 2544 | foreach ($tutors as $tutor) { |
|
| 2545 | $userInfo = api_get_user_info_from_username($tutor); |
|
| 2546 | ||
| 2547 | if (!$userInfo) { |
|
| 2548 | continue; |
|
| 2549 | } |
|
| 2550 | ||
| 2551 | if ( |
|
| 2552 | !CourseManager::is_user_subscribed_in_course( |
|
| 2553 | $userInfo['user_id'], |
|
| 2554 | $courseCode, |
|
| 2555 | !empty($sessionId), |
|
| 2556 | $sessionId |
|
| 2557 | ) |
|
| 2558 | ) { |
|
| 2559 | Display::addFlash( |
|
| 2560 | Display::return_message( |
|
| 2561 | sprintf(get_lang('TutorXIsNotSubscribedToCourse'), $userInfo['complete_name']), |
|
| 2562 | 'warning' |
|
| 2563 | ) |
|
| 2564 | ); |
|
| 2565 | ||
| 2566 | continue; |
|
| 2567 | } |
|
| 2568 | ||
| 2569 | $tutorIdList[] = $userInfo['user_id']; |
|
| 2570 | } |
|
| 2571 | self::subscribe_tutors($tutorIdList, $groupInfo); |
|
| 2572 | } |
|
| 2573 | ||
| 2574 | $elementsFound['groups'][] = $groupId; |
|
| 2575 | } |
|