diff --git a/assets/css/app.scss b/assets/css/app.scss index 71ce011e65..1bcb94c9a7 100644 --- a/assets/css/app.scss +++ b/assets/css/app.scss @@ -843,6 +843,16 @@ form .field { } } +.row { + @apply flex flex-wrap -mx-4; +} +.col-md-4 { + @apply w-full md:w-1/3 px-4; +} +.col-md-6 { + @apply w-full md:w-1/2 px-4; +} + //@import 'primevue-md-light-indigo/theme.css'; //@import '~primevue/resources/primevue.min.css'; //@import '~primeflex/primeflex.css'; diff --git a/package.json b/package.json index 62e82ae4ef..5347a4f214 100644 --- a/package.json +++ b/package.json @@ -39,7 +39,7 @@ "blueimp-load-image": "^5.16.0", "bootstrap-daterangepicker": "^3.1.0", "bootstrap-select": "^1.13.18", - "chart.js": "^3.9.1", + "chart.js": "^4.0.0", "colorjs.io": "^0.5.0", "cropper": "^4.1.0", "datepair.js": "^0.4.17", diff --git a/public/main/admin/statistics/index.php b/public/main/admin/statistics/index.php index c2b05148dd..6494818663 100644 --- a/public/main/admin/statistics/index.php +++ b/public/main/admin/statistics/index.php @@ -26,7 +26,7 @@ in_array( ['recentlogins', 'tools', 'courses', 'coursebylanguage', 'users', 'users_active', 'session_by_date'] ) ) { - //$htmlHeadXtra[] = api_get_js('chartjs/Chart.min.js'); + $htmlHeadXtra[] = api_get_build_js('libs/chartjs/chart.js'); //$htmlHeadXtra[] = api_get_asset('chartjs-plugin-labels/build/chartjs-plugin-labels.min.js'); // Prepare variables for the JS charts $url = $reportName = $reportType = $reportOptions = ''; @@ -828,7 +828,7 @@ switch ($report) { $contract = false; $legalAccept = $extraFieldValueUser->get_values_by_handler_and_field_variable($userId, 'legal_accept'); - if ($legalAccept && isset($legalAccept['value'])) { + if ($legalAccept && !empty($legalAccept['value'])) { list($legalId, $legalLanguageId, $legalTime) = explode(':', $legalAccept['value']); if ($legalId) { $contract = true; @@ -925,7 +925,8 @@ switch ($report) { $data['chart'], 'pie', $reportOptions1, - 'canvas1' + 'canvas1', + false ); $scoreDisplay = ScoreDisplay::instance(); @@ -1009,7 +1010,8 @@ switch ($report) { $data['chart'], 'pie', $reportOptions2, - 'canvas2' + 'canvas2', + false ); $extraTables .= $data['table']; } @@ -1017,8 +1019,8 @@ switch ($report) { // graph 3 $languages = api_get_languages(); $all = []; - foreach ($languages as $language) { - $conditions = ['language' => $language]; + foreach ($languages as $locale => $language) { + $conditions = ['locale' => $locale]; $key = $language; if ('2' === substr($language, -1)) { $key = str_replace(2, '', $language); @@ -1044,7 +1046,8 @@ switch ($report) { $data['chart'], 'pie', $reportOptions3, - 'canvas3' + 'canvas3', + false ); $extraTables .= $data['table']; @@ -1092,7 +1095,8 @@ switch ($report) { $data['chart'], 'pie', $reportOptions4, - 'canvas4' + 'canvas4', + false ); $extraTables .= $data['table']; } @@ -1160,7 +1164,8 @@ switch ($report) { $data['chart'], 'pie', $reportOptions8, - 'canvas8' + 'canvas8', + false ); $extraTables .= $data['table']; } @@ -1211,7 +1216,8 @@ switch ($report) { $data['chart'], 'pie', $reportOptions5, - 'canvas5' + 'canvas5', + false ); $extraTables .= $data['table']; } @@ -1253,7 +1259,8 @@ switch ($report) { $data['chart'], 'pie', $reportOptions6, - 'canvas6' + 'canvas6', + false ); $extraTables .= $data['table']; } @@ -1294,12 +1301,13 @@ switch ($report) { $data['chart'], 'pie', $reportOptions7, - 'canvas7' + 'canvas7', + false ); $extraTables .= $data['table']; } - $header = Display::page_subheader2(get_lang('TotalNumberOfStudents').': '.$studentCount); + $header = Display::page_subheader2(get_lang('Total number of students').': '.$studentCount); $content = $header.$extraTables.$graph.$content; } @@ -1321,7 +1329,7 @@ switch ($report) { $counts[$minutes] = $row[0]; } } - $content = '
'.get_lang('UsersOnline').'
+ $content = '
'.get_lang('Users online').'
'.api_get_local_time().'

@@ -1333,7 +1341,7 @@ switch ($report) {
-
'.get_lang('UsersOnline').' (3\')
+
'.get_lang('Users online').' (3\')
'.getOnlineUsersCount(3).'
@@ -1346,7 +1354,7 @@ switch ($report) {
-
'.get_lang('UsersOnline').' (5\')
+
'.get_lang('Users online').' (5\')
'.getOnlineUsersCount(5).'
@@ -1372,14 +1380,14 @@ switch ($report) {
-
'.get_lang('UsersOnline').' (120\')
+
'.get_lang('Users online').' (120\')
'.getOnlineUsersCount(120).'
-
'.get_lang('UsersActiveInATest').'
+
'.get_lang('Users active in a test').'

diff --git a/public/main/inc/lib/statistics.lib.php b/public/main/inc/lib/statistics.lib.php index bad69a5ca3..71888fbb32 100644 --- a/public/main/inc/lib/statistics.lib.php +++ b/public/main/inc/lib/statistics.lib.php @@ -1223,14 +1223,14 @@ class Statistics url: "'.$url.'", type: "POST", success: function(data) { - Chart.defaults.global.responsive = true; + Chart.defaults.responsive = true; var ctx = document.getElementById("'.$elementId.'").getContext("2d"); var chart = new Chart(ctx, { type: "'.$type.'", data: data, options: {'.$options.'} }); - var title = chart.options.title.text; + var title = chart.options.plugins.title.text; $("#'.$elementId.'_title").html(title); $("#'.$elementId.'_table").html(data.table); } @@ -1241,14 +1241,18 @@ class Statistics return $chartCode; } - public static function getJSChartTemplateWithData($data, $type = 'pie', $options = '', $elementId = 'canvas') + public static function getJSChartTemplateWithData($data, $type = 'pie', $options = '', $elementId = 'canvas', $responsive = true) { $data = json_encode($data); + $responsiveValue = $responsive ? 'true' : 'false'; + $chartCode = '