chamilo/chamilo-lms

View on GitHub
src/CoreBundle/Controller/OnlineController.php

Summary

Maintainability
A
0 mins
Test Coverage
<?php

declare(strict_types=1);

/* For licensing terms, see /license.txt */

namespace Chamilo\CoreBundle\Controller;

use SocialManager;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Attribute\Route;

/**
 * @author Julio Montoya <gugli100@gmail.com>.
 */
#[Route('/online')]
class OnlineController extends BaseController
{
    #[Route(path: '/', name: 'users_online', methods: ['GET'], options: ['expose' => true])]
    public function index(): Response
    {
        // @todo don't use legacy code
        $users = who_is_online(0, MAX_ONLINE_USERS);
        $users = SocialManager::display_user_list($users);

        return $this->render(
            '@ChamiloCore/Online/index.html.twig',
            [
                'whoisonline' => $users,
            ]
        );
    }

    #[Route(path: '/in_course/{cidReq}', name: 'online_users_in_course', methods: ['GET', 'POST'], options: ['expose' => true])]
    public function onlineUsersInCourses(string $cidReq): Response
    {
        // @todo don't use legacy code
        $users = who_is_online_in_this_course(
            0,
            MAX_ONLINE_USERS,
            api_get_user_id(),
            api_get_setting('time_limit_whosonline'),
            $cidReq
        );

        $users = SocialManager::display_user_list($users);

        return $this->render(
            '@ChamiloCore/Online/index.html.twig',
            [
                'whoisonline' => $users,
            ]
        );
    }

    #[Route(path: '/in_sessions', name: 'online_users_in_session', methods: ['GET', 'POST'], options: ['expose' => true])]
    public function onlineUsersInCoursesSession(int $id = 0): Response
    {
        $users = who_is_online_in_this_course(
            0,
            MAX_ONLINE_USERS,
            api_get_user_id(),
            api_get_setting('time_limit_whosonline'),
            $_GET['cidReq']
        );

        $users = SocialManager::display_user_list($users);

        return $this->render(
            '@ChamiloCore/Online/index.html.twig',
            [
                'whoisonline' => $users,
            ]
        );
    }
}