Browse Source

Avoid edit question categories in session course

Angel Fernando Quiroz Campos 6 years ago
parent
commit
eb4d446bff
1 changed files with 11 additions and 5 deletions
  1. 11 5
      main/exercise/TestCategory.php

+ 11 - 5
main/exercise/TestCategory.php

@@ -1254,6 +1254,7 @@ class TestCategory
      */
     public function displayCategories($courseId, $sessionId = 0)
     {
+        $sessionId = (int) $sessionId;
         $categories = $this->getCategories($courseId, $sessionId);
         $html = '';
         foreach ($categories as $category) {
@@ -1266,11 +1267,16 @@ class TestCategory
             $content .= '<div class="sectioncomment">';
             $content .= $category['description'];
             $content .= '</div>';
-            $links = '<a href="'.api_get_self().'?action=editcategory&category_id='.$category['id'].'&'.api_get_cidreq().'">'.
-                Display::return_icon('edit.png', get_lang('Edit'), [], ICON_SIZE_SMALL).'</a>';
-            $links .= ' <a href="'.api_get_self().'?'.api_get_cidreq().'&action=deletecategory&category_id='.$category['id'].'" ';
-            $links .= 'onclick="return confirmDelete(\''.self::protectJSDialogQuote(get_lang('DeleteCategoryAreYouSure').'['.$rowname).'] ?\', \'id_cat'.$category['id'].'\');">';
-            $links .= Display::return_icon('delete.png', get_lang('Delete'), [], ICON_SIZE_SMALL).'</a>';
+            $links = '';
+
+            if (!$sessionId) {
+                $links .= '<a href="'.api_get_self().'?action=editcategory&category_id='.$category['id'].'&'.api_get_cidreq().'">'.
+                    Display::return_icon('edit.png', get_lang('Edit'), [], ICON_SIZE_SMALL).'</a>';
+                $links .= ' <a href="'.api_get_self().'?'.api_get_cidreq().'&action=deletecategory&category_id='.$category['id'].'" ';
+                $links .= 'onclick="return confirmDelete(\''.self::protectJSDialogQuote(get_lang('DeleteCategoryAreYouSure').'['.$rowname).'] ?\', \'id_cat'.$category['id'].'\');">';
+                $links .= Display::return_icon('delete.png', get_lang('Delete'), [], ICON_SIZE_SMALL).'</a>';
+            }
+
             $html .= Display::panel($content, $category['title'].$links);
         }