diff --git a/index.php b/index.php index 59ed570ce6..37f4010699 100755 --- a/index.php +++ b/index.php @@ -150,6 +150,10 @@ $controller->tpl->assign('navigation_course_links', $controller->return_navigati $controller->tpl->assign('notice_block', $controller->return_notice()); //$controller->tpl->assign('main_navigation_block', $controller->return_navigation_links()); $controller->tpl->assign('help_block', $controller->return_help()); +$controller->tpl->assign('total_users', UserManager::getCountActiveUsers()); +$controller->tpl->assign('total_courses', CourseManager::getCountOpenCourses()); +$controller->tpl->assign('total_exercises', CourseManager::getCountExercisesFromOpenCourse()); + if (api_is_platform_admin() || api_is_drh()) { $controller->tpl->assign('skills_block', $controller->return_skills_links()); diff --git a/main/inc/lib/course.lib.php b/main/inc/lib/course.lib.php index dc610b6f08..d41cec2e2a 100755 --- a/main/inc/lib/course.lib.php +++ b/main/inc/lib/course.lib.php @@ -2481,7 +2481,7 @@ class CourseManager public static function course_exists($course_code) { $sql = 'SELECT 1 FROM ' . Database::get_main_table(TABLE_MAIN_COURSE) . ' - WHERE code="' . Database::escape_string($course_code) . '"'; + WHERE code="' . Database::escape_string($course_code) . '"'; return Database::num_rows(Database::query($sql)); } @@ -6190,4 +6190,48 @@ class CourseManager $courseFieldValue = new ExtraFieldValue('course'); $courseFieldValue->saveFieldValues($params); } + + /** + * @return int + */ + public static function getCountOpenCourses() + { + $visibility = [ + COURSE_VISIBILITY_REGISTERED, + COURSE_VISIBILITY_OPEN_PLATFORM, + COURSE_VISIBILITY_OPEN_WORLD + ]; + + $table = Database::get_main_table(TABLE_MAIN_COURSE); + $sql = "SELECT count(id) count + FROM $table + WHERE visibility IN (".implode(',', $visibility).")"; + $result = Database::query($sql); + $row = Database::fetch_array($result); + + return $row['count']; + } + + /** + * @return int + */ + public static function getCountExercisesFromOpenCourse() + { + $visibility = [ + COURSE_VISIBILITY_REGISTERED, + COURSE_VISIBILITY_OPEN_PLATFORM, + COURSE_VISIBILITY_OPEN_WORLD + ]; + + $table = Database::get_main_table(TABLE_MAIN_COURSE); + $tableExercise = Database::get_course_table(TABLE_QUIZ_TEST); + $sql = "SELECT count(e.iid) count + FROM $table c INNER JOIN $tableExercise e + ON (c.id = e.c_id) + WHERE visibility IN (".implode(',', $visibility).")"; + $result = Database::query($sql); + $row = Database::fetch_array($result); + + return $row['count']; + } } diff --git a/main/inc/lib/usermanager.lib.php b/main/inc/lib/usermanager.lib.php index 451184335f..4c1b6945fc 100755 --- a/main/inc/lib/usermanager.lib.php +++ b/main/inc/lib/usermanager.lib.php @@ -5557,4 +5557,17 @@ SQL; return Display::tabsOnlyLink($headers, $optionSelected); } } + + /** + * @return int + */ + public static function getCountActiveUsers() + { + $table = Database::get_main_table(TABLE_MAIN_USER); + $sql = "SELECT count(id) count FROM $table WHERE active = 1"; + $result = Database::query($sql); + $row = Database::fetch_array($result); + + return $row['count']; + } } diff --git a/main/template/rainbow/layout/layout_2_col.tpl b/main/template/rainbow/layout/layout_2_col.tpl index e8dce4c749..d2407e4720 100755 --- a/main/template/rainbow/layout/layout_2_col.tpl +++ b/main/template/rainbow/layout/layout_2_col.tpl @@ -42,7 +42,7 @@
{{ "RegisteredUsers"|get_lang }}
{{ "OpenCourses"|get_lang }}
{{ "Certificates"|get_lang }}