Browse Source

Allow DRH to load company reports see: BT#7297

Julio Montoya 11 years ago
parent
commit
b1432168df
1 changed files with 33 additions and 11 deletions
  1. 33 11
      main/inc/ajax/model.ajax.php

+ 33 - 11
main/inc/ajax/model.ajax.php

@@ -142,20 +142,42 @@ if (!$sidx) {
 switch ($action) {
     case 'get_user_course_report':
     case 'get_user_course_report_resumed':
-
         if (!(api_is_platform_admin(false, true))) {
-            exit;
+            //exit;
         }
         $courseCodeList = array();
         $userIdList  = array();
         if (api_is_drh()) {
-            $userList = UserManager::get_users_followed_by_drh(api_get_user_id());
-            if (!empty($userList)) {
-                $userIdList = array_keys($userList);
-            }
-            $courseList = CourseManager::get_courses_followed_by_drh(api_get_user_id());
-            if (!empty($courseList)) {
-                $courseCodeList = array_keys($courseList);
+            if (api_drh_can_access_all_session_content()) {
+                $userList = SessionManager::getAllUsersFromCoursesFromAllSessionFromStatus(
+                    'drh_all',
+                    api_get_user_id()
+                );
+
+                if (!empty($userList)) {
+                    foreach ($userList as $user) {
+                        $userIdList[] = $user['user_id'];
+                    }
+                }
+
+                $courseList = SessionManager::getAllCoursesFollowedByUser(
+                    api_get_user_id(),
+                    null
+                );
+                if (!empty($courseList)) {
+                    foreach ($courseList as $course) {
+                        $courseCodeList[] = $course['code'];
+                    }
+                }
+            } else {
+                $userList = UserManager::get_users_followed_by_drh(api_get_user_id());
+                if (!empty($userList)) {
+                    $userIdList = array_keys($userList);
+                }
+                $courseList = CourseManager::get_courses_followed_by_drh(api_get_user_id());
+                if (!empty($courseList)) {
+                    $courseCodeList = array_keys($courseList);
+                }
             }
 
             if (empty($userIdList) || empty($courseCodeList)) {
@@ -571,9 +593,9 @@ switch ($action) {
         $course = api_get_course_info();
         $documentPath = api_get_path(SYS_COURSE_PATH) . $course['path'] . "/document";
         if (api_is_allowed_to_edit()) {
-            $columns = array('firstname', 'lastname', 'username', 'group_name', 'exe_date',  'score', 'actions');    
+            $columns = array('firstname', 'lastname', 'username', 'group_name', 'exe_date',  'score', 'actions');
         } else {
-            $columns = array('exe_date',  'score', 'actions');    
+            $columns = array('exe_date',  'score', 'actions');
         }
         $result = get_exam_results_hotpotatoes_data($start, $limit, $sidx, $sord, $hotpot_path, $where_condition); //get_exam_results_data($start, $limit, $sidx, $sord, $exercise_id, $where_condition);
         break;