diff --git a/main/exercise/TestCategory.php b/main/exercise/TestCategory.php index d7cde7718f..17beee1fc0 100644 --- a/main/exercise/TestCategory.php +++ b/main/exercise/TestCategory.php @@ -624,25 +624,29 @@ class TestCategory /** * @param int $questionId - * @param int $in_display_category_name + * @param int $showCategoryName * @return null|string */ - public static function returnCategoryAndTitle($questionId, $in_display_category_name = 1) + public static function returnCategoryAndTitle($questionId, $showCategoryName = 1) { $is_student = !(api_is_allowed_to_edit(null, true) || api_is_session_admin()); $objExercise = Session::read('objExercise'); - if (!empty($objExercise)) { - $in_display_category_name = $objExercise->display_category_name; + if (empty($objExercise)) { + return ''; } - $content = null; - if (self::getCategoryNameForQuestion($questionId) != '' && - ($in_display_category_name == 1 || !$is_student) - ) { - $content .= '"; + + $showCategoryName = !!$objExercise->display_category_name; //double negation to get a boolean value + $categoryName = self::getCategoryNameForQuestion($questionId); + + if (empty($categoryName) || (!$showCategoryName && $is_student)) { + return ''; } - return $content; + + return Display::page_header( + get_lang('Category').': '.$categoryName, + null, + 'h4' + ); } /**