diff --git a/main/inc/ajax/model.ajax.php b/main/inc/ajax/model.ajax.php index 091f397a7d..03626b8b1d 100755 --- a/main/inc/ajax/model.ajax.php +++ b/main/inc/ajax/model.ajax.php @@ -145,6 +145,7 @@ if (!$sidx) { switch ($action) { case 'get_user_course_report': case 'get_user_course_report_resumed': + $userId = api_get_user_id(); if (!(api_is_platform_admin(false, true))) { //exit; } @@ -186,7 +187,38 @@ switch ($action) { if (empty($userIdList) || empty($courseCodeList)) { exit; } + } elseif (api_is_student_boss()) { + $users = UserManager::getUsersFollowedByStudentBoss($userId); + + $userIdList = array_keys($users); + } + + $groups = GroupPortalManager::get_groups_by_user(api_get_user_id(), GROUP_USER_PERMISSION_ADMIN); + + $groupsId = array_keys($groups); + + if (is_array($groupsId)) { + foreach ($groupsId as $groupId) { + $groupUsers = GroupPortalManager::get_users_by_group($groupId); + + if (!is_array($groupUsers)) { + continue; + } + + foreach ($groupUsers as $memberId => $member) { + if ($member['user_id'] == $userId ) { + continue; + } + + $userIdList[] = intval($member['user_id']); + } + } + } + + if (is_array($userIdList)) { + $userIdList = array_unique($userIdList); } + if ($action == 'get_user_course_report') { $count = CourseManager::get_count_user_list_from_course_code(false, null, $courseCodeList, $userIdList); } else { diff --git a/main/mySpace/company_reports.php b/main/mySpace/company_reports.php index dc8fcd9f02..2e0b3f4c2f 100755 --- a/main/mySpace/company_reports.php +++ b/main/mySpace/company_reports.php @@ -12,8 +12,10 @@ $language_file = array('admin', 'gradebook', 'tracking'); $cidReset = true; require_once '../inc/global.inc.php'; -if (!(api_is_platform_admin(false, true))) { - api_not_allowed(); +$userNotAllowed = !api_is_student_boss() && !api_is_platform_admin(false, true); + +if ($userNotAllowed) { + api_not_allowed(true); } $interbreadcrumb[] = array ('url' => 'index.php', 'name' => get_lang('MySpace')); @@ -88,7 +90,43 @@ $(function() { }); }); '; -$content = Display::grid_html('user_course_report'); + +$actions = null; + +if (api_is_student_boss()) { + $actions .= Display::url( + Display::return_icon('stats.png', get_lang('MyStats'), '', ICON_SIZE_MEDIUM), + api_get_path(WEB_CODE_PATH) . "auth/my_progress.php" + ); + $actions .= Display::url( + Display::return_icon('user.png', get_lang('Students'), array(), ICON_SIZE_MEDIUM), + api_get_path(WEB_CODE_PATH) . "mySpace/student.php" + ); + $actions .= Display::url( + Display::return_icon("statistics.png", get_lang("CompanyReport"), array(), ICON_SIZE_MEDIUM), + "#" + ); +} + +$content = '
'; + +if (!empty($actions)) { + $content .= $actions; +} + +$content .= '
'; +$content .= Display::url( + get_lang("CompanyReportResumed"), + api_get_path(WEB_CODE_PATH) . "mySpace/company_reports_resumed.php", + array( + 'class' => 'btn btn-info' + ) +); + +$content .= '
'; +$content .= '
'; +$content .= '

' . get_lang('CompanyReport') . '

'; +$content .= Display::grid_html('user_course_report'); $tpl = new Template($tool_name); $tpl->assign('content', $content); diff --git a/main/mySpace/company_reports_resumed.php b/main/mySpace/company_reports_resumed.php index c1af3c6d74..73aa0f8dd0 100755 --- a/main/mySpace/company_reports_resumed.php +++ b/main/mySpace/company_reports_resumed.php @@ -12,8 +12,10 @@ $cidReset = true; require_once '../inc/global.inc.php'; -if (!(api_is_platform_admin(false, true))) { - api_not_allowed(); +$userNotAllowed = !api_is_student_boss() && !api_is_platform_admin(false, true); + +if ($userNotAllowed) { + api_not_allowed(true); } $interbreadcrumb[] = array('url' => 'index.php', 'name' => get_lang('MySpace')); @@ -83,7 +85,45 @@ $(function() { }); }); '; -$content = Display::grid_html('user_course_report'); + +$actions = null; + +if (api_is_student_boss()) { + $actions .= Display::url( + Display::return_icon('stats.png', get_lang('MyStats'), '', ICON_SIZE_MEDIUM), + api_get_path(WEB_CODE_PATH) . "auth/my_progress.php" + ); + $actions .= Display::url( + Display::return_icon('user.png', get_lang('Students'), array(), ICON_SIZE_MEDIUM), + api_get_path(WEB_CODE_PATH) . "mySpace/student.php" + ); + $actions .= Display::url( + Display::return_icon("statistics.png", get_lang("CompanyReport"), array(), ICON_SIZE_MEDIUM), + api_get_path(WEB_CODE_PATH) . "mySpace/company_reports.php" + ); +} + +$content = '
'; + +if (!empty($actions)) { + $content .= $actions; +} + +if (!api_is_student_boss()) { + $content .= '
'; + $content .= Display::url( + get_lang("CompanyReport"), + api_get_path(WEB_CODE_PATH) . "mySpace/company_reports.php", + array( + 'class' => 'btn btn-info' + ) + ); + $content .= '
'; +} + +$content .= '
'; +$content .= '

' . get_lang('CompanyReportResumed') . '

'; +$content .= Display::grid_html('user_course_report'); $tpl = new Template($tool_name); $tpl->assign('content', $content); diff --git a/main/mySpace/student.php b/main/mySpace/student.php index 1ab100dbba..03d8de4791 100755 --- a/main/mySpace/student.php +++ b/main/mySpace/student.php @@ -212,6 +212,10 @@ if (api_is_drh()) { Display::return_icon('user_na.png', get_lang('Students'), array(), ICON_SIZE_MEDIUM), '#' ); + $actions .= Display::url( + Display::return_icon("statistics.png", get_lang("CompanyReport"), array(), ICON_SIZE_MEDIUM), + api_get_path(WEB_CODE_PATH) . "mySpace/company_reports.php" + ); } $actions .= '';