Internal: Fix SQL query error in user language report and address missing graphs issue - refs BT#21957

pull/5750/head
christianbeeznst 3 months ago
parent fc4761c643
commit 240dcfc690
  1. 10
      assets/css/app.scss
  2. 2
      package.json
  3. 44
      public/main/admin/statistics/index.php
  4. 12
      public/main/inc/lib/statistics.lib.php
  5. 2
      public/main/inc/lib/usermanager.lib.php
  6. 26
      webpack.config.js

@ -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-md-light-indigo/theme.css';
//@import '~primevue/resources/primevue.min.css'; //@import '~primevue/resources/primevue.min.css';
//@import '~primeflex/primeflex.css'; //@import '~primeflex/primeflex.css';

@ -39,7 +39,7 @@
"blueimp-load-image": "^5.16.0", "blueimp-load-image": "^5.16.0",
"bootstrap-daterangepicker": "^3.1.0", "bootstrap-daterangepicker": "^3.1.0",
"bootstrap-select": "^1.13.18", "bootstrap-select": "^1.13.18",
"chart.js": "^3.9.1", "chart.js": "^4.0.0",
"colorjs.io": "^0.5.0", "colorjs.io": "^0.5.0",
"cropper": "^4.1.0", "cropper": "^4.1.0",
"datepair.js": "^0.4.17", "datepair.js": "^0.4.17",

@ -26,7 +26,7 @@ in_array(
['recentlogins', 'tools', 'courses', 'coursebylanguage', 'users', 'users_active', 'session_by_date'] ['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'); //$htmlHeadXtra[] = api_get_asset('chartjs-plugin-labels/build/chartjs-plugin-labels.min.js');
// Prepare variables for the JS charts // Prepare variables for the JS charts
$url = $reportName = $reportType = $reportOptions = ''; $url = $reportName = $reportType = $reportOptions = '';
@ -828,7 +828,7 @@ switch ($report) {
$contract = false; $contract = false;
$legalAccept = $extraFieldValueUser->get_values_by_handler_and_field_variable($userId, 'legal_accept'); $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']); list($legalId, $legalLanguageId, $legalTime) = explode(':', $legalAccept['value']);
if ($legalId) { if ($legalId) {
$contract = true; $contract = true;
@ -925,7 +925,8 @@ switch ($report) {
$data['chart'], $data['chart'],
'pie', 'pie',
$reportOptions1, $reportOptions1,
'canvas1' 'canvas1',
false
); );
$scoreDisplay = ScoreDisplay::instance(); $scoreDisplay = ScoreDisplay::instance();
@ -1009,7 +1010,8 @@ switch ($report) {
$data['chart'], $data['chart'],
'pie', 'pie',
$reportOptions2, $reportOptions2,
'canvas2' 'canvas2',
false
); );
$extraTables .= $data['table']; $extraTables .= $data['table'];
} }
@ -1017,8 +1019,8 @@ switch ($report) {
// graph 3 // graph 3
$languages = api_get_languages(); $languages = api_get_languages();
$all = []; $all = [];
foreach ($languages as $language) { foreach ($languages as $locale => $language) {
$conditions = ['language' => $language]; $conditions = ['locale' => $locale];
$key = $language; $key = $language;
if ('2' === substr($language, -1)) { if ('2' === substr($language, -1)) {
$key = str_replace(2, '', $language); $key = str_replace(2, '', $language);
@ -1044,7 +1046,8 @@ switch ($report) {
$data['chart'], $data['chart'],
'pie', 'pie',
$reportOptions3, $reportOptions3,
'canvas3' 'canvas3',
false
); );
$extraTables .= $data['table']; $extraTables .= $data['table'];
@ -1092,7 +1095,8 @@ switch ($report) {
$data['chart'], $data['chart'],
'pie', 'pie',
$reportOptions4, $reportOptions4,
'canvas4' 'canvas4',
false
); );
$extraTables .= $data['table']; $extraTables .= $data['table'];
} }
@ -1160,7 +1164,8 @@ switch ($report) {
$data['chart'], $data['chart'],
'pie', 'pie',
$reportOptions8, $reportOptions8,
'canvas8' 'canvas8',
false
); );
$extraTables .= $data['table']; $extraTables .= $data['table'];
} }
@ -1211,7 +1216,8 @@ switch ($report) {
$data['chart'], $data['chart'],
'pie', 'pie',
$reportOptions5, $reportOptions5,
'canvas5' 'canvas5',
false
); );
$extraTables .= $data['table']; $extraTables .= $data['table'];
} }
@ -1253,7 +1259,8 @@ switch ($report) {
$data['chart'], $data['chart'],
'pie', 'pie',
$reportOptions6, $reportOptions6,
'canvas6' 'canvas6',
false
); );
$extraTables .= $data['table']; $extraTables .= $data['table'];
} }
@ -1294,12 +1301,13 @@ switch ($report) {
$data['chart'], $data['chart'],
'pie', 'pie',
$reportOptions7, $reportOptions7,
'canvas7' 'canvas7',
false
); );
$extraTables .= $data['table']; $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; $content = $header.$extraTables.$graph.$content;
} }
@ -1321,7 +1329,7 @@ switch ($report) {
$counts[$minutes] = $row[0]; $counts[$minutes] = $row[0];
} }
} }
$content = '<div class="pull-left">'.get_lang('UsersOnline').'</div> $content = '<div class="pull-left">'.get_lang('Users online').'</div>
<div class="pull-right">'.api_get_local_time().'</div> <div class="pull-right">'.api_get_local_time().'</div>
<hr /> <hr />
<div class="tracking-course-summary"> <div class="tracking-course-summary">
@ -1333,7 +1341,7 @@ switch ($report) {
<i class="fa fa-thermometer-4" aria-hidden="true"></i> <i class="fa fa-thermometer-4" aria-hidden="true"></i>
</span> </span>
<div class="tracking-info"> <div class="tracking-info">
<div class="tracking-text">'.get_lang('UsersOnline').' (3\')</div> <div class="tracking-text">'.get_lang('Users online').' (3\')</div>
<div class="tracking-number">'.getOnlineUsersCount(3).'</div> <div class="tracking-number">'.getOnlineUsersCount(3).'</div>
</div> </div>
</div> </div>
@ -1346,7 +1354,7 @@ switch ($report) {
<i class="fa fa-thermometer-3" aria-hidden="true"></i> <i class="fa fa-thermometer-3" aria-hidden="true"></i>
</span> </span>
<div class="tracking-info"> <div class="tracking-info">
<div class="tracking-text">'.get_lang('UsersOnline').' (5\')</div> <div class="tracking-text">'.get_lang('Users online').' (5\')</div>
<div class="tracking-number">'.getOnlineUsersCount(5).'</div> <div class="tracking-number">'.getOnlineUsersCount(5).'</div>
</div> </div>
</div> </div>
@ -1372,14 +1380,14 @@ switch ($report) {
<i class="fa fa-thermometer-1" aria-hidden="true"></i> <i class="fa fa-thermometer-1" aria-hidden="true"></i>
</span> </span>
<div class="tracking-info"> <div class="tracking-info">
<div class="tracking-text">'.get_lang('UsersOnline').' (120\')</div> <div class="tracking-text">'.get_lang('Users online').' (120\')</div>
<div class="tracking-number">'.getOnlineUsersCount(120).'</div> <div class="tracking-number">'.getOnlineUsersCount(120).'</div>
</div> </div>
</div> </div>
</div> </div>
</div> </div>
</div> </div>
<div class="pull-left">'.get_lang('UsersActiveInATest').'</div> <div class="pull-left">'.get_lang('Users active in a test').'</div>
<hr /> <hr />
<div class="row"> <div class="row">
<div class="col-lg-3 col-sm-3"> <div class="col-lg-3 col-sm-3">

@ -1223,14 +1223,14 @@ class Statistics
url: "'.$url.'", url: "'.$url.'",
type: "POST", type: "POST",
success: function(data) { success: function(data) {
Chart.defaults.global.responsive = true; Chart.defaults.responsive = true;
var ctx = document.getElementById("'.$elementId.'").getContext("2d"); var ctx = document.getElementById("'.$elementId.'").getContext("2d");
var chart = new Chart(ctx, { var chart = new Chart(ctx, {
type: "'.$type.'", type: "'.$type.'",
data: data, data: data,
options: {'.$options.'} options: {'.$options.'}
}); });
var title = chart.options.title.text; var title = chart.options.plugins.title.text;
$("#'.$elementId.'_title").html(title); $("#'.$elementId.'_title").html(title);
$("#'.$elementId.'_table").html(data.table); $("#'.$elementId.'_table").html(data.table);
} }
@ -1241,14 +1241,18 @@ class Statistics
return $chartCode; 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); $data = json_encode($data);
$responsiveValue = $responsive ? 'true' : 'false';
$chartCode = ' $chartCode = '
<script> <script>
$(function() { $(function() {
Chart.defaults.global.responsive = true; Chart.defaults.responsive = '.$responsiveValue.';
var ctx = document.getElementById("'.$elementId.'").getContext("2d"); var ctx = document.getElementById("'.$elementId.'").getContext("2d");
ctx.canvas.width = 400;
ctx.canvas.height = 400;
var chart = new Chart(ctx, { var chart = new Chart(ctx, {
type: "'.$type.'", type: "'.$type.'",
data: '.$data.', data: '.$data.',

@ -1447,7 +1447,7 @@ class UserManager
$urlId = api_get_current_access_url_id(); $urlId = api_get_current_access_url_id();
} }
$sql .= " INNER JOIN $userUrlTable url_user $sql .= " INNER JOIN $userUrlTable url_user
ON (user.user_id = url_user.user_id) ON (user.id = url_user.user_id)
WHERE url_user.access_url_id = $urlId"; WHERE url_user.access_url_id = $urlId";
} else { } else {
$sql .= " WHERE 1=1 "; $sql .= " WHERE 1=1 ";

@ -49,8 +49,6 @@ Encore.setOutputPath("public/build/")
.enableSassLoader() .enableSassLoader()
.enableTypeScriptLoader(function (tsConfig) { .enableTypeScriptLoader(function (tsConfig) {
tsConfig.transpileOnly = true tsConfig.transpileOnly = true
//tsConfig.configFile = './tsconfig.json';
//tsConfig.exclude = ['/node_modules(?!\\/vuex-composition-helpers)/'];
}) })
.enableVueLoader(() => {}, { version: 3, runtimeCompilerBuild: false }) .enableVueLoader(() => {}, { version: 3, runtimeCompilerBuild: false })
.autoProvidejQuery() .autoProvidejQuery()
@ -97,12 +95,11 @@ Encore.setOutputPath("public/build/")
from: "./node_modules/flatpickr/dist/l10n", from: "./node_modules/flatpickr/dist/l10n",
to: "flatpickr/l10n/[name].[ext]", to: "flatpickr/l10n/[name].[ext]",
}, },
/*,
{ {
from: './node_modules/mathjax/', from: "./node_modules/chart.js/dist/",
pattern: /(MathJax.js)$/, to: "libs/chartjs/[name].[ext]",
to: 'libs/mathjax/MathJax.js' pattern: /\.(js|css)$/,
},*/ }
]) ])
.addPlugin( .addPlugin(
new webpack.DefinePlugin({ new webpack.DefinePlugin({
@ -138,21 +135,6 @@ Encore.copyFiles({
to: "libs/select2/js/[name].[ext]", to: "libs/select2/js/[name].[ext]",
}) })
// Fix free-jqgrid languages files
// Encore.addPlugin(new FileManagerPlugin({
// onEnd: {
// move: [
// {
// source: './public/public/build/free-jqgrid/',
// destination: './public/build/free-jqgrid/'
// }
// ],
// delete: [
// './public/public/'
// ]
// }
// }));
const config = Encore.getWebpackConfig() const config = Encore.getWebpackConfig()
module.exports = config module.exports = config

Loading…
Cancel
Save