From 99278624740908dac08ccf1bb05c2d2b97a5b997 Mon Sep 17 00:00:00 2001 From: Angel Fernando Quiroz Campos Date: Tue, 9 Jan 2018 11:57:58 -0500 Subject: [PATCH] Improve code to show test question category #2160 --- main/exercise/TestCategory.php | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) 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' + ); } /**