Courses: Fix order by + fix PHP warning BT#18724

pull/3860/head
Julio Montoya 5 years ago
parent 358bd293f9
commit 98aaea581f
  1. 2
      main/admin/add_courses_to_usergroup.php
  2. 2
      main/admin/course_export.php
  3. 2
      main/inc/ajax/course.ajax.php
  4. 15
      main/inc/lib/course.lib.php
  5. 17
      main/inc/lib/myspace.lib.php

@ -142,7 +142,7 @@ function search($needle, $type)
$list = CourseManager::get_courses_list(
0,
0,
2,
'title',
'ASC',
-1,
$needle

@ -20,7 +20,7 @@ set_time_limit(0);
$course_list = CourseManager::get_courses_list(
0,
0,
1,
'title',
'ASC',
-1,
'',

@ -158,7 +158,7 @@ switch ($action) {
$courseList = CourseManager::get_courses_list(
0,
0,
1,
'title',
'ASC',
-1,
$_GET['q'],

@ -164,7 +164,7 @@ class CourseManager
public static function get_courses_list(
$from = 0,
$howmany = 0,
$orderby = 1,
$orderby = 'title',
$orderdirection = 'ASC',
$visibility = -1,
$startwith = '',
@ -238,16 +238,21 @@ class CourseManager
}
}
if (!empty($orderby)) {
$sql .= " ORDER BY `".Database::escape_string($orderby)."` ";
if (empty($orderby)) {
$sql .= ' ORDER BY title ';
} else {
$sql .= ' ORDER BY 1 ';
if (in_array($orderby, ['title'])) {
$sql .= " ORDER BY `".Database::escape_string($orderby)."` ";
} else {
$sql .= ' ORDER BY title ';
}
}
$orderdirection = strtoupper($orderdirection);
if (!in_array($orderdirection, ['ASC', 'DESC'])) {
$sql .= 'ASC';
} else {
$sql .= ($orderdirection === 'ASC' ? 'ASC' : 'DESC');
$sql .= $orderdirection === 'ASC' ? 'ASC' : 'DESC';
}
if (!empty($howmany) && is_int($howmany) and $howmany > 0) {

@ -2027,6 +2027,14 @@ class MySpace
$column,
$direction
) {
switch ($column) {
default:
case 1:
$column = 'title';
break;
}
$courses = CourseManager::get_courses_list(
$from,
$numberItems,
@ -2101,8 +2109,11 @@ class MySpace
null,
true
);
$progress += $progress_tmp[0];
$nb_progress_lp += $progress_tmp[1];
if ($progress_tmp) {
$progress += $progress_tmp[0];
$nb_progress_lp += $progress_tmp[1];
}
$score_tmp = Tracking::get_avg_student_score(
$row->user_id,
$course_code,
@ -3520,7 +3531,7 @@ class MySpace
$sql_select = "SELECT COUNT(user_id) as nbUsers FROM $tbl_session_rel_course_rel_user
WHERE session_id='$id_session' AND c_id='$enreg_course'";
$rs = Database::query($sql_select);
list($nbr_users) = Database::fetch_array($rs);
[$nbr_users] = Database::fetch_array($rs);
$sql_update = "UPDATE $tbl_session_rel_course SET nbr_users=$nbr_users
WHERE session_id='$id_session' AND c_id='$enreg_course'";
Database::query($sql_update);

Loading…
Cancel
Save