diff --git a/main/gradebook/lib/gradebook_data_generator.class.php b/main/gradebook/lib/gradebook_data_generator.class.php index 50309e71ab..873a1c35a9 100644 --- a/main/gradebook/lib/gradebook_data_generator.class.php +++ b/main/gradebook/lib/gradebook_data_generator.class.php @@ -97,7 +97,8 @@ class GradebookDataGenerator $row = array (); $row[] = $item; $row[] = $item->get_name(); - $row[] = $item->get_description(); + // display the 2 first line of description, and all description on mouseover (https://support.chamilo.org/issues/6588) + $row[] = ''.api_get_short_text_from_html($item->get_description(), 160).''; $row[] = $item->get_weight(); /*if (api_is_allowed_to_edit(null, true)) { $row[] = $this->build_date_column($item); diff --git a/main/inc/lib/main_api.lib.php b/main/inc/lib/main_api.lib.php index f36734686e..814201d857 100644 --- a/main/inc/lib/main_api.lib.php +++ b/main/inc/lib/main_api.lib.php @@ -6551,3 +6551,36 @@ function api_get_user_blocked_by_captcha($username) } return false; } + + +/** + * Remove tags from HTML anf return the $in_number_char first non-HTML char + * Postfix the text with "..." if it has been truncated. + * @return string + * @author hubert borderiou + */ +function api_get_short_text_from_html($in_html, $in_number_char) { + $out_res = api_remove_tags_with_space($in_html, false); + $postfix = "..."; + if (strlen($out_res) > $in_number_char) { + $out_res = substr($out_res, 0, $in_number_char).$postfix; + } + return $out_res; +} + +/** + * Replace tags with a space in a text. + * If $in_double_quote_replace, replace " with '' (for HTML attribute purpose, for exemple) + * @return string + * @author hubert borderiou + */ +function api_remove_tags_with_space($in_html, $in_double_quote_replace = true) { + $out_res = $in_html; + if ($in_double_quote_replace) { + $out_res = str_replace('"', "''", $out_res); + } + // avoid text stuck together when tags are removed, adding a space after > + $out_res = str_replace (">", "> ", $out_res); + $out_res = strip_tags($out_res); + return $out_res; +} \ No newline at end of file