diff --git a/main/gradebook/lib/GradebookUtils.php b/main/gradebook/lib/GradebookUtils.php index a5eda107e7..d02b7ad6ad 100644 --- a/main/gradebook/lib/GradebookUtils.php +++ b/main/gradebook/lib/GradebookUtils.php @@ -707,9 +707,12 @@ class GradebookUtils $date_certificate ) { $table = Database::get_main_table(TABLE_MAIN_GRADEBOOK_CERTIFICATE); - $sql = 'SELECT COUNT(id) as count - FROM '.$table.' gc - WHERE gc.cat_id="'.intval($cat_id).'" AND user_id="'.intval($user_id).'" '; + $cat_id = (int) $cat_id; + $user_id = (int) $user_id; + + $sql = "SELECT COUNT(id) as count + FROM $table gc + WHERE gc.cat_id = $cat_id AND user_id = $user_id "; $rs_exist = Database::query($sql); $row = Database::fetch_array($rs_exist); if ($row['count'] == 0) { @@ -734,8 +737,11 @@ class GradebookUtils public static function get_certificate_by_user_id($cat_id, $user_id) { $table = Database::get_main_table(TABLE_MAIN_GRADEBOOK_CERTIFICATE); - $sql = 'SELECT * FROM '.$table.' - WHERE cat_id="'.intval($cat_id).'" AND user_id="'.intval($user_id).'"'; + $cat_id = (int) $cat_id; + $user_id = (int) $user_id; + + $sql = "SELECT * FROM $table + WHERE cat_id = $cat_id AND user_id = $user_id "; $result = Database::query($sql); $row = Database::fetch_array($result, 'ASSOC'); @@ -792,12 +798,12 @@ class GradebookUtils ) { $user_id = (int) $user_id; $table_certificate = Database::get_main_table(TABLE_MAIN_GRADEBOOK_CERTIFICATE); - $sql = 'SELECT - gc.score_certificate, - gc.created_at, - gc.path_certificate, - gc.cat_id, - gc.user_id, + $sql = 'SELECT + gc.score_certificate, + gc.created_at, + gc.path_certificate, + gc.cat_id, + gc.user_id, gc.id FROM '.$table_certificate.' gc WHERE gc.user_id = "'.$user_id.'" '; @@ -849,9 +855,9 @@ class GradebookUtils //add print header if (!$hide_print_button) { - $print = '