Fix company report pagination pb and incoherent calculation -refs BT#20446

pull/4505/head
NicoDucou 3 years ago
parent 8236bd4ba3
commit ba8d1ce3fb
  1. 24
      main/inc/ajax/model.ajax.php
  2. 20
      main/inc/lib/course.lib.php

@ -452,19 +452,14 @@ switch ($action) {
5
);
$userIdList = array_column($userIdList, 'user_id');
$courseCodeList = array_merge(
$courseCodeList,
CourseManager::getAllCoursesCode()
);
//get students session courses
if ($sessionId == -1) {
$sessionList = SessionManager::get_sessions_list();
$sessionIdList = array_column($sessionList, 'id');
$courseCodeList = [];
foreach ($sessionList as $session) {
$courses = SessionManager::get_course_list_by_session_id($session['id']);
$courseCodeList = array_merge(
$courseCodeList,
array_column($courses, 'code')
);
}
}
$searchByGroups = true;
}
@ -513,7 +508,15 @@ switch ($action) {
}
if ($action === 'get_user_course_report') {
$count = CourseManager::get_count_user_list_from_course_code(
$countCourse = CourseManager::get_count_user_list_from_course_code(
false,
null,
$courseCodeList,
$userIdList,
null,
['where' => $whereCondition, 'extra' => $extra_fields]
);
$countCourseSession = CourseManager::get_count_user_list_from_course_code(
false,
null,
$courseCodeList,
@ -521,6 +524,7 @@ switch ($action) {
$sessionIdList,
['where' => $whereCondition, 'extra' => $extra_fields]
);
$count = $countCourse + $countCourseSession;
} else {
$count = CourseManager::get_count_user_list_from_course_code(
true,

@ -7300,6 +7300,26 @@ class CourseManager
return $data;
}
/**
* returns an array with all the courses codes of the plateform
* @return array
*/
public static function getAllCoursesCode()
{
$sql = "select id, code from course";
$result = Database::query($sql);
$num_rows = Database::num_rows($result);
$coursesCode = [];
$coursesList = [];
if ($num_rows > 0) {
while ($row = Database::fetch_array($result, 'ASSOC')) {
$coursesList[$row['id']] = $row;
}
$coursesCode = array_column($coursesList, 'code');
}
return $coursesCode;
}
/**
* Check if a specific access-url-related setting is a problem or not.
*

Loading…
Cancel
Save