Add courses list for platform admins (other than course teachers) in certificates report - refs BT#9442

1.10.x
Yannick Warnier 11 years ago
parent 2a7851f488
commit a9c6bea3a7
  1. 2
      main/gradebook/certificate_report.php
  2. 14
      main/inc/lib/course.lib.php

@ -60,7 +60,7 @@ if ($selectedSession > 0) {
if (api_is_student_boss()) {
$coursesList = CourseManager::getCoursesFollowedByGroupAdmin($userId);
} else {
$coursesList = CourseManager::get_courses_list_by_user_id($userId);
$coursesList = CourseManager::get_courses_list_by_user_id($userId, false, true);
if (is_array($coursesList)) {
foreach ($coursesList as &$course) {

@ -2571,10 +2571,11 @@ class CourseManager
* Get list of courses for a given user
* @param int $user_id
* @param boolean $include_sessions Whether to include courses from session or not
* @return array List of codes and db names
* @param boolean $adminGetsAllCourses If the user is platform admin, whether he gets all the courses or just his. Note: This does *not* include all sessions
* @return array List of codes and db name
* @author isaac flores paz
*/
public static function get_courses_list_by_user_id($user_id, $include_sessions = false)
public static function get_courses_list_by_user_id($user_id, $include_sessions = false, $adminGetsAllCourses = false)
{
$user_id = intval($user_id);
$course_list = array();
@ -2584,6 +2585,13 @@ class CourseManager
$tbl_user_course_category = Database::get_main_table(TABLE_USER_COURSE_CATEGORY);
$special_course_list = self::get_special_course_list();
if ($adminGetsAllCourses && UserManager::is_admin($user_id)) {
// get the whole courses list
$sql = "SELECT DISTINCT(course.code), course.id as real_id
FROM $tbl_course course";
} else {
$with_special_courses = $without_special_courses = '';
if (!empty($special_course_list)) {
$sc_string = '"' . implode('","', $special_course_list) . '"';
@ -2617,7 +2625,7 @@ class CourseManager
FROM $tbl_course course
INNER JOIN $tbl_course_user cru ON course.id = cru.c_id
WHERE cru.user_id='$user_id' $without_special_courses";
}
$result = Database::query($sql);
if (Database::num_rows($result)) {

Loading…
Cancel
Save