Skip to content

Commit 240dcfc

Browse files
Internal: Fix SQL query error in user language report and address missing graphs issue - refs BT#21957
1 parent fc4761c commit 240dcfc

File tree

6 files changed

+50
-46
lines changed

6 files changed

+50
-46
lines changed

assets/css/app.scss

+10
Original file line numberDiff line numberDiff line change
@@ -843,6 +843,16 @@ form .field {
843843
}
844844
}
845845

846+
.row {
847+
@apply flex flex-wrap -mx-4;
848+
}
849+
.col-md-4 {
850+
@apply w-full md:w-1/3 px-4;
851+
}
852+
.col-md-6 {
853+
@apply w-full md:w-1/2 px-4;
854+
}
855+
846856
//@import 'primevue-md-light-indigo/theme.css';
847857
//@import '~primevue/resources/primevue.min.css';
848858
//@import '~primeflex/primeflex.css';

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
"blueimp-load-image": "^5.16.0",
4040
"bootstrap-daterangepicker": "^3.1.0",
4141
"bootstrap-select": "^1.13.18",
42-
"chart.js": "^3.9.1",
42+
"chart.js": "^4.0.0",
4343
"colorjs.io": "^0.5.0",
4444
"cropper": "^4.1.0",
4545
"datepair.js": "^0.4.17",

public/main/admin/statistics/index.php

+26-18
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
['recentlogins', 'tools', 'courses', 'coursebylanguage', 'users', 'users_active', 'session_by_date']
2727
)
2828
) {
29-
//$htmlHeadXtra[] = api_get_js('chartjs/Chart.min.js');
29+
$htmlHeadXtra[] = api_get_build_js('libs/chartjs/chart.js');
3030
//$htmlHeadXtra[] = api_get_asset('chartjs-plugin-labels/build/chartjs-plugin-labels.min.js');
3131
// Prepare variables for the JS charts
3232
$url = $reportName = $reportType = $reportOptions = '';
@@ -828,7 +828,7 @@
828828

829829
$contract = false;
830830
$legalAccept = $extraFieldValueUser->get_values_by_handler_and_field_variable($userId, 'legal_accept');
831-
if ($legalAccept && isset($legalAccept['value'])) {
831+
if ($legalAccept && !empty($legalAccept['value'])) {
832832
list($legalId, $legalLanguageId, $legalTime) = explode(':', $legalAccept['value']);
833833
if ($legalId) {
834834
$contract = true;
@@ -925,7 +925,8 @@
925925
$data['chart'],
926926
'pie',
927927
$reportOptions1,
928-
'canvas1'
928+
'canvas1',
929+
false
929930
);
930931

931932
$scoreDisplay = ScoreDisplay::instance();
@@ -1009,16 +1010,17 @@
10091010
$data['chart'],
10101011
'pie',
10111012
$reportOptions2,
1012-
'canvas2'
1013+
'canvas2',
1014+
false
10131015
);
10141016
$extraTables .= $data['table'];
10151017
}
10161018

10171019
// graph 3
10181020
$languages = api_get_languages();
10191021
$all = [];
1020-
foreach ($languages as $language) {
1021-
$conditions = ['language' => $language];
1022+
foreach ($languages as $locale => $language) {
1023+
$conditions = ['locale' => $locale];
10221024
$key = $language;
10231025
if ('2' === substr($language, -1)) {
10241026
$key = str_replace(2, '', $language);
@@ -1044,7 +1046,8 @@
10441046
$data['chart'],
10451047
'pie',
10461048
$reportOptions3,
1047-
'canvas3'
1049+
'canvas3',
1050+
false
10481051
);
10491052
$extraTables .= $data['table'];
10501053

@@ -1092,7 +1095,8 @@
10921095
$data['chart'],
10931096
'pie',
10941097
$reportOptions4,
1095-
'canvas4'
1098+
'canvas4',
1099+
false
10961100
);
10971101
$extraTables .= $data['table'];
10981102
}
@@ -1160,7 +1164,8 @@
11601164
$data['chart'],
11611165
'pie',
11621166
$reportOptions8,
1163-
'canvas8'
1167+
'canvas8',
1168+
false
11641169
);
11651170
$extraTables .= $data['table'];
11661171
}
@@ -1211,7 +1216,8 @@
12111216
$data['chart'],
12121217
'pie',
12131218
$reportOptions5,
1214-
'canvas5'
1219+
'canvas5',
1220+
false
12151221
);
12161222
$extraTables .= $data['table'];
12171223
}
@@ -1253,7 +1259,8 @@
12531259
$data['chart'],
12541260
'pie',
12551261
$reportOptions6,
1256-
'canvas6'
1262+
'canvas6',
1263+
false
12571264
);
12581265
$extraTables .= $data['table'];
12591266
}
@@ -1294,12 +1301,13 @@
12941301
$data['chart'],
12951302
'pie',
12961303
$reportOptions7,
1297-
'canvas7'
1304+
'canvas7',
1305+
false
12981306
);
12991307
$extraTables .= $data['table'];
13001308
}
13011309

1302-
$header = Display::page_subheader2(get_lang('TotalNumberOfStudents').': '.$studentCount);
1310+
$header = Display::page_subheader2(get_lang('Total number of students').': '.$studentCount);
13031311
$content = $header.$extraTables.$graph.$content;
13041312
}
13051313

@@ -1321,7 +1329,7 @@
13211329
$counts[$minutes] = $row[0];
13221330
}
13231331
}
1324-
$content = '<div class="pull-left">'.get_lang('UsersOnline').'</div>
1332+
$content = '<div class="pull-left">'.get_lang('Users online').'</div>
13251333
<div class="pull-right">'.api_get_local_time().'</div>
13261334
<hr />
13271335
<div class="tracking-course-summary">
@@ -1333,7 +1341,7 @@
13331341
<i class="fa fa-thermometer-4" aria-hidden="true"></i>
13341342
</span>
13351343
<div class="tracking-info">
1336-
<div class="tracking-text">'.get_lang('UsersOnline').' (3\')</div>
1344+
<div class="tracking-text">'.get_lang('Users online').' (3\')</div>
13371345
<div class="tracking-number">'.getOnlineUsersCount(3).'</div>
13381346
</div>
13391347
</div>
@@ -1346,7 +1354,7 @@
13461354
<i class="fa fa-thermometer-3" aria-hidden="true"></i>
13471355
</span>
13481356
<div class="tracking-info">
1349-
<div class="tracking-text">'.get_lang('UsersOnline').' (5\')</div>
1357+
<div class="tracking-text">'.get_lang('Users online').' (5\')</div>
13501358
<div class="tracking-number">'.getOnlineUsersCount(5).'</div>
13511359
</div>
13521360
</div>
@@ -1372,14 +1380,14 @@
13721380
<i class="fa fa-thermometer-1" aria-hidden="true"></i>
13731381
</span>
13741382
<div class="tracking-info">
1375-
<div class="tracking-text">'.get_lang('UsersOnline').' (120\')</div>
1383+
<div class="tracking-text">'.get_lang('Users online').' (120\')</div>
13761384
<div class="tracking-number">'.getOnlineUsersCount(120).'</div>
13771385
</div>
13781386
</div>
13791387
</div>
13801388
</div>
13811389
</div>
1382-
<div class="pull-left">'.get_lang('UsersActiveInATest').'</div>
1390+
<div class="pull-left">'.get_lang('Users active in a test').'</div>
13831391
<hr />
13841392
<div class="row">
13851393
<div class="col-lg-3 col-sm-3">

public/main/inc/lib/statistics.lib.php

+8-4
Original file line numberDiff line numberDiff line change
@@ -1223,14 +1223,14 @@ public static function getJSChartTemplate($url, $type = 'pie', $options = '', $e
12231223
url: "'.$url.'",
12241224
type: "POST",
12251225
success: function(data) {
1226-
Chart.defaults.global.responsive = true;
1226+
Chart.defaults.responsive = true;
12271227
var ctx = document.getElementById("'.$elementId.'").getContext("2d");
12281228
var chart = new Chart(ctx, {
12291229
type: "'.$type.'",
12301230
data: data,
12311231
options: {'.$options.'}
12321232
});
1233-
var title = chart.options.title.text;
1233+
var title = chart.options.plugins.title.text;
12341234
$("#'.$elementId.'_title").html(title);
12351235
$("#'.$elementId.'_table").html(data.table);
12361236
}
@@ -1241,14 +1241,18 @@ public static function getJSChartTemplate($url, $type = 'pie', $options = '', $e
12411241
return $chartCode;
12421242
}
12431243

1244-
public static function getJSChartTemplateWithData($data, $type = 'pie', $options = '', $elementId = 'canvas')
1244+
public static function getJSChartTemplateWithData($data, $type = 'pie', $options = '', $elementId = 'canvas', $responsive = true)
12451245
{
12461246
$data = json_encode($data);
1247+
$responsiveValue = $responsive ? 'true' : 'false';
1248+
12471249
$chartCode = '
12481250
<script>
12491251
$(function() {
1250-
Chart.defaults.global.responsive = true;
1252+
Chart.defaults.responsive = '.$responsiveValue.';
12511253
var ctx = document.getElementById("'.$elementId.'").getContext("2d");
1254+
ctx.canvas.width = 400;
1255+
ctx.canvas.height = 400;
12521256
var chart = new Chart(ctx, {
12531257
type: "'.$type.'",
12541258
data: '.$data.',

public/main/inc/lib/usermanager.lib.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -1447,7 +1447,7 @@ public static function getUserListExtraConditions(
14471447
$urlId = api_get_current_access_url_id();
14481448
}
14491449
$sql .= " INNER JOIN $userUrlTable url_user
1450-
ON (user.user_id = url_user.user_id)
1450+
ON (user.id = url_user.user_id)
14511451
WHERE url_user.access_url_id = $urlId";
14521452
} else {
14531453
$sql .= " WHERE 1=1 ";

webpack.config.js

+4-22
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,6 @@ Encore.setOutputPath("public/build/")
4949
.enableSassLoader()
5050
.enableTypeScriptLoader(function (tsConfig) {
5151
tsConfig.transpileOnly = true
52-
//tsConfig.configFile = './tsconfig.json';
53-
//tsConfig.exclude = ['/node_modules(?!\\/vuex-composition-helpers)/'];
5452
})
5553
.enableVueLoader(() => {}, { version: 3, runtimeCompilerBuild: false })
5654
.autoProvidejQuery()
@@ -97,12 +95,11 @@ Encore.setOutputPath("public/build/")
9795
from: "./node_modules/flatpickr/dist/l10n",
9896
to: "flatpickr/l10n/[name].[ext]",
9997
},
100-
/*,
10198
{
102-
from: './node_modules/mathjax/',
103-
pattern: /(MathJax.js)$/,
104-
to: 'libs/mathjax/MathJax.js'
105-
},*/
99+
from: "./node_modules/chart.js/dist/",
100+
to: "libs/chartjs/[name].[ext]",
101+
pattern: /\.(js|css)$/,
102+
}
106103
])
107104
.addPlugin(
108105
new webpack.DefinePlugin({
@@ -138,21 +135,6 @@ Encore.copyFiles({
138135
to: "libs/select2/js/[name].[ext]",
139136
})
140137

141-
// Fix free-jqgrid languages files
142-
// Encore.addPlugin(new FileManagerPlugin({
143-
// onEnd: {
144-
// move: [
145-
// {
146-
// source: './public/public/build/free-jqgrid/',
147-
// destination: './public/build/free-jqgrid/'
148-
// }
149-
// ],
150-
// delete: [
151-
// './public/public/'
152-
// ]
153-
// }
154-
// }));
155-
156138
const config = Encore.getWebpackConfig()
157139

158140
module.exports = config

0 commit comments

Comments
 (0)