gradebooktable.class.php 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656
  1. <?php
  2. /* For licensing terms, see license.txt */
  3. require_once dirname(__FILE__).'/../../../inc/global.inc.php';
  4. require_once dirname(__FILE__).'/../be.inc.php';
  5. /**
  6. * GradebookTable Class
  7. * Table to display categories, evaluations and links
  8. * @author Stijn Konings
  9. * @author Bert Steppé (refactored, optimised)
  10. * @package chamilo.gradebook
  11. */
  12. class GradebookTable extends SortableTable
  13. {
  14. private $currentcat;
  15. private $datagen;
  16. private $evals_links;
  17. public $cats;
  18. /**
  19. * Constructor
  20. */
  21. public function GradebookTable($currentcat, $cats = array(), $evals = array(), $links = array(), $addparams = null)
  22. {
  23. //$status = CourseManager::get_user_in_course_status(api_get_user_id(), api_get_course_id());
  24. parent :: __construct ('gradebooklist', null, null, (api_is_allowed_to_edit()?1:0));
  25. $this->evals_links = array_merge($evals, $links);
  26. $this->currentcat = $currentcat;
  27. $this->cats = $cats;
  28. $this->datagen = new GradebookDataGenerator($cats, $evals, $links);
  29. if (isset($addparams)) {
  30. $this->set_additional_parameters($addparams);
  31. }
  32. $column= 0;
  33. if (api_is_allowed_to_edit(null, true)) {
  34. $this->set_header($column++,'','','width="25px"');
  35. }
  36. $this->set_header($column++, get_lang('Type'),'','width="35px"');
  37. $this->set_header($column++, get_lang('Name'), false);
  38. $this->set_header($column++, get_lang('Description'), false);
  39. if (api_is_allowed_to_edit(null, true)) {
  40. $this->set_header(
  41. $column++,
  42. get_lang('Weight'),
  43. '',
  44. 'width="100px"'
  45. );
  46. } else {
  47. $this->set_header($column++, get_lang('Weight'), false);
  48. $this->set_header($column++, get_lang('Result'), false);
  49. if (!empty($cats)) {
  50. $this->set_header($column++, get_lang('Actions'), false);
  51. }
  52. }
  53. //Desactivates the odd/even alt rows in order that the +/- buttons work see #4047
  54. $this->odd_even_rows_enabled = false;
  55. //admins get an edit column
  56. if (api_is_allowed_to_edit(null, true)) {
  57. $this->set_header($column++, get_lang('Modify'), false, 'width="195px"');
  58. //actions on multiple selected documents
  59. $this->set_form_actions(array (
  60. 'setvisible' => get_lang('SetVisible'),
  61. 'setinvisible' => get_lang('SetInvisible'),
  62. 'deleted' => get_lang('DeleteSelected')
  63. ));
  64. } else {
  65. if (empty($_GET['selectcat']) && !api_is_allowed_to_edit()) {
  66. $this->set_header($column++, get_lang('Certificates'),false);
  67. //$evals_links = array_merge($evals, $links);
  68. //if (count($evals_links)>0) {
  69. //$this->set_header($column++, get_lang('Results'), false);
  70. //}
  71. }
  72. }
  73. }
  74. /**
  75. * @return GradebookDataGenerator
  76. */
  77. public function get_data()
  78. {
  79. return $this->datagen;
  80. }
  81. /**
  82. * Function used by SortableTable to get total number of items in the table
  83. * @return int
  84. */
  85. public function get_total_number_of_items()
  86. {
  87. return $this->datagen->get_total_items_count();
  88. }
  89. /**
  90. * Function used by SortableTable to generate the data to display
  91. * @param int $from
  92. * @param int $per_page
  93. * @param int $column
  94. * @param string $direction
  95. * @param int $sort
  96. * @return array|mixed
  97. */
  98. public function get_table_data($from = 1, $per_page = null, $column = null, $direction = null, $sort = null)
  99. {
  100. //variables load in index.php
  101. global $my_score_in_gradebook, $certificate_min_score;
  102. $scoretotal = 0;
  103. // determine sorting type
  104. $col_adjust = (api_is_allowed_to_edit() ? 1 : 0);
  105. // By id
  106. $this->column = 5;
  107. switch ($this->column) {
  108. // Type
  109. case (0 + $col_adjust) :
  110. $sorting = GradebookDataGenerator :: GDG_SORT_TYPE;
  111. break;
  112. case (1 + $col_adjust) :
  113. $sorting = GradebookDataGenerator :: GDG_SORT_NAME;
  114. break;
  115. case (2 + $col_adjust) :
  116. $sorting = GradebookDataGenerator :: GDG_SORT_DESCRIPTION;
  117. break;
  118. case (3 + $col_adjust) :
  119. $sorting = GradebookDataGenerator :: GDG_SORT_WEIGHT;
  120. break;
  121. case (4 + $col_adjust) :
  122. $sorting = GradebookDataGenerator :: GDG_SORT_DATE;
  123. case (5 + $col_adjust) :
  124. $sorting = GradebookDataGenerator :: GDG_SORT_ID;
  125. break;
  126. }
  127. if ($this->direction == 'DESC') {
  128. $sorting |= GradebookDataGenerator :: GDG_SORT_DESC;
  129. } else {
  130. $sorting |= GradebookDataGenerator :: GDG_SORT_ASC;
  131. }
  132. //status of user in course
  133. $user_id = api_get_user_id();
  134. $course_code = api_get_course_id();
  135. $courseId = api_get_course_int_id();
  136. $session_id = api_get_session_id();
  137. $status_user = api_get_status_of_user_in_course($user_id, $courseId);
  138. $data_array = $this->datagen->get_data($sorting, $from, $this->per_page);
  139. // generate the data to display
  140. $sortable_data = array();
  141. $weight_total_links = 0;
  142. $main_categories = array();
  143. $main_cat = Category :: load(null, null, $course_code, null, null, $session_id, false);
  144. $total_categories_weight = 0;
  145. $scoredisplay = ScoreDisplay :: instance();
  146. //Categories
  147. foreach ($data_array as $data) {
  148. // list of items inside the gradebook (exercises, lps, forums, etc)
  149. $row = array();
  150. $item = $item_category = $data[0];
  151. $id = $item->get_id();
  152. //if the item is invisible, wrap it in a span with class invisible
  153. $invisibility_span_open = (api_is_allowed_to_edit() && $item->is_visible() == '0') ? '<span class="invisible">' : '';
  154. $invisibility_span_close = (api_is_allowed_to_edit() && $item->is_visible() == '0') ? '</span>' : '';
  155. if (api_is_allowed_to_edit(null, true)) {
  156. //id
  157. $row[] = $this->build_id_column($item);
  158. }
  159. //Type
  160. $row[] = $this->build_type_column($item);
  161. //Name
  162. if (get_class($item) == 'Category') {
  163. $row[] = $invisibility_span_open.'<h3>'.$item->get_name().'</h3>'.$invisibility_span_close;
  164. $main_categories[$item->get_id()]['name'] = $item->get_name();
  165. } else {
  166. $row[] = $invisibility_span_open.$this->build_name_link($item) . $invisibility_span_close;
  167. $main_categories[$item->get_id()]['name'] = $this->build_name_link($item);
  168. }
  169. $main_categories[$item->get_id()]['weight']= $item->get_weight();
  170. $total_categories_weight += $item->get_weight();
  171. //Description
  172. $row[] = $invisibility_span_open.$data[2].$invisibility_span_close;
  173. //Weight
  174. //$row[] = $invisibility_span_open .Display::tag('h4', $data['3'] .' / '.$this->currentcat->get_weight()).$invisibility_span_close;
  175. //$average = $data['3']/$this->currentcat->get_weight()*100;
  176. $average = $scoredisplay->display_score(
  177. array(
  178. $data['3'],
  179. $this->currentcat->get_weight()
  180. ),
  181. SCORE_SIMPLE,
  182. SCORE_BOTH,
  183. true
  184. );
  185. if (api_is_allowed_to_edit(null, true)) {
  186. $row[] = $invisibility_span_open .Display::tag('h4', $average).$invisibility_span_close;
  187. } else {
  188. $row[] = $invisibility_span_open .$average.$invisibility_span_close;
  189. }
  190. $category_weight = $item->get_weight();
  191. if (api_is_allowed_to_edit(null, true)) {
  192. $weight_total_links += $data[3];
  193. } else {
  194. $cattotal = Category :: load($_GET['selectcat']);
  195. $scoretotal = $cattotal[0]->calc_score(api_get_user_id());
  196. $item_value = $scoredisplay->display_score($scoretotal, SCORE_SIMPLE);
  197. }
  198. //Date
  199. //$row[] = $invisibility_span_open.$data[4].$invisibility_span_close;
  200. //Edit (for admins)
  201. if (api_is_allowed_to_edit(null, true)) {
  202. $cat = new Category();
  203. $show_message = $cat->show_message_resource_delete($item->get_course_code());
  204. if ($show_message === false) {
  205. $row[] = $this->build_edit_column($item);
  206. }
  207. } else {
  208. //students get the results and certificates columns
  209. if (count($this->evals_links) > 0 && $status_user != 1) {
  210. $value_data = isset($data[4]) ? $data[4] : null;
  211. if (!is_null($value_data)) {
  212. $row[] = Display::tag('h4', $value_data);
  213. } else {
  214. $row[] = $this->build_edit_column($item);
  215. }
  216. } else {
  217. $score = $item->calc_score(api_get_user_id());
  218. if (!empty($score[1])) {
  219. $complete_score = $scoredisplay->display_score($score, SCORE_DIV_PERCENT);
  220. $score = $score[0]/$score[1]*$item->get_weight();
  221. $score = $scoredisplay->display_score(array($score, null), SCORE_SIMPLE);
  222. $row[] = Display::tip($score, $complete_score);
  223. } else {
  224. $row[] = '-';
  225. }
  226. if (!empty($this->cats)) {
  227. $row[] = $this->build_edit_column($item);
  228. }
  229. }
  230. }
  231. //Category added
  232. $sortable_data[] = $row;
  233. // Loading childrens
  234. if (get_class($item) == 'Category') {
  235. $stud_id = api_get_user_id();
  236. $course_code = api_get_course_id();
  237. $session_id = api_get_session_id();
  238. $parent_id = $item->get_id();
  239. $cats = Category :: load ($parent_id, null, null, null, null, null);
  240. if (isset($cats[0])) {
  241. $allcat = $cats[0]->get_subcategories($stud_id, $course_code, $session_id);
  242. $alleval = $cats[0]->get_evaluations($stud_id);
  243. $alllink = $cats[0]->get_links($stud_id);
  244. $sub_cat_info = new GradebookDataGenerator($allcat, $alleval, $alllink);
  245. $data_array = $sub_cat_info->get_data($sorting, $from, $this->per_page);
  246. $total_weight = 0;
  247. //Links
  248. foreach ($data_array as $data) {
  249. $row = array();
  250. $item = $data[0];
  251. //if the item is invisible, wrap it in a span with class invisible
  252. $invisibility_span_open = (api_is_allowed_to_edit() && $item->is_visible() == '0') ? '<span class="invisible">' : '';
  253. $invisibility_span_close = (api_is_allowed_to_edit() && $item->is_visible() == '0') ? '</span>' : '';
  254. $main_categories[$parent_id]['children'][$item->get_id()]['name'] = $item->get_name();
  255. $main_categories[$parent_id]['children'][$item->get_id()]['weight'] = $item->get_weight();
  256. if (api_is_allowed_to_edit(null, true)) {
  257. $row[] = $this->build_id_column($item);
  258. }
  259. $row[] = $this->build_type_column($item, array('style' => 'padding-left:5px'));
  260. //Name
  261. $row[] = $invisibility_span_open."&nbsp;&nbsp;&nbsp; ".$this->build_name_link($item) . $invisibility_span_close;
  262. //Description
  263. $row[] = $invisibility_span_open.$data[2].$invisibility_span_close;
  264. //Weight
  265. //$weight = $data[3]/$category_weight*$main_cat[0]->get_weight();
  266. $weight = $data[3];
  267. //$extra = " - $data[3] $category_weight -".$main_cat[0]->get_weight();
  268. $total_weight += $weight;
  269. $row[] = $invisibility_span_open.$weight.$invisibility_span_close;
  270. if (api_is_allowed_to_edit(null, true)) {
  271. //$weight_total_links += intval($data[3]);
  272. } else {
  273. $cattotal = Category :: load($_GET['selectcat']);
  274. $scoretotal = $cattotal[0]->calc_score(api_get_user_id());
  275. $item_value = $scoretotal[0];
  276. }
  277. //Date
  278. //$row[] = $invisibility_span_open.$data[4].$invisibility_span_close;
  279. //Admins get an edit column
  280. if (api_is_allowed_to_edit(null, true)) {
  281. $cat = new Category();
  282. $show_message = $cat->show_message_resource_delete($item->get_course_code());
  283. if ($show_message === false) {
  284. $row[] = $this->build_edit_column($item);
  285. }
  286. } else {
  287. //students get the results and certificates columns
  288. $eval_n_links = array_merge($alleval, $alllink);
  289. if (count($eval_n_links)> 0 && $status_user!=1 ) {
  290. $value_data = isset($data[4]) ? $data[4] : null;
  291. if (!is_null($value_data)) {
  292. $score = $item->calc_score(api_get_user_id());
  293. $new_score = $data[3]* $score[0] / $score[1];
  294. $new_score = floatval(number_format($new_score, api_get_setting('gradebook_number_decimals')));
  295. $row[] = Display::tip($new_score, $data[4]);
  296. }
  297. }
  298. if (!empty($cats)) {
  299. $row[] = null;
  300. }
  301. }
  302. $row['child_of'] = $parent_id;
  303. $sortable_data[] = $row;
  304. }
  305. //"Warning row"
  306. if (!empty($data_array)) {
  307. if (api_is_allowed_to_edit()) {
  308. // Compare the category weight to the sum of all weights inside the category
  309. if (intval($total_weight) == $category_weight) {
  310. $label = null;
  311. $total = score_badges(array($total_weight.' / '.$category_weight, '100'));
  312. } else {
  313. $label = Display::return_icon(
  314. 'warning.png',
  315. sprintf(get_lang('TotalWeightMustBeX'), $category_weight)
  316. );
  317. $total = Display::badge($total_weight.' / '.$category_weight, 'warning');
  318. }
  319. $row = array(
  320. null,
  321. null,
  322. "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<h5>".get_lang('SubTotal').'</h5>',
  323. null,
  324. $total.' '.$label,
  325. 'child_of' => $parent_id
  326. );
  327. $sortable_data[] = $row;
  328. }
  329. }
  330. }
  331. } //end looping categories
  332. } //end looping categories
  333. if (api_is_allowed_to_edit()) {
  334. if (count($main_cat) > 1) {
  335. $main_weight = intval($main_cat[0]->get_weight());
  336. if (intval($total_categories_weight) == $main_weight) {
  337. $total = score_badges(array($total_categories_weight.' / '.$main_weight, '100'));
  338. } else {
  339. $total = Display::badge($total_categories_weight.' / '.$main_weight, 'warning');
  340. }
  341. $row = array(null, null, '<h3>'.get_lang('Total').'</h3>', null, $total);
  342. $sortable_data[] = $row;
  343. }
  344. }
  345. // warning messages
  346. $view = isset($_GET['view']) ? $_GET['view']: null;
  347. if (api_is_allowed_to_edit()) {
  348. if (isset($_GET['selectcat']) && $_GET['selectcat'] > 0 && $view <> 'presence') {
  349. $id_cat = intval($_GET['selectcat']);
  350. $category = Category :: load($id_cat);
  351. //$weight_category = intval($this->build_weight($category[0]));
  352. $weight_category = intval($this->build_weight($category[0]));
  353. $course_code = $this->build_course_code($category[0]);
  354. $weight_total_links = round($weight_total_links);
  355. if ($weight_total_links > $weight_category ||
  356. $weight_total_links < $weight_category ||
  357. $weight_total_links > $weight_category
  358. ) {
  359. $warning_message = sprintf(get_lang('TotalWeightMustBeX'), $weight_category);
  360. $modify_icons = '<a class="right_link" href="gradebook_edit_cat.php?editcat='.$id_cat.'&cidReq='.$course_code.'">'.Display::return_icon('edit.png', $warning_message, array(), ICON_SIZE_SMALL).'</a>';
  361. $warning_message .= $modify_icons;
  362. Display::display_warning_message($warning_message,false);
  363. }
  364. $content_html = DocumentManager::replace_user_info_into_html(api_get_user_id(), $course_code);
  365. if (!empty($content_html)) {
  366. $new_content = explode('</head>',$content_html['content']);
  367. }
  368. if (empty($new_content[0])) {
  369. $warning_message = get_lang('ThereIsNotACertificateAvailableByDefault');
  370. $cert_icon = '<a class="right_link" href="../document/document.php?curdirpath=/certificates&'.$course_code.'&origin=gradebook&selectcat=' . $id_cat . '">'.Display::return_icon('certificate.png', get_lang('AttachCertificate'), array(), ICON_SIZE_SMALL).'</a>';
  371. Display::display_warning_message($warning_message.$cert_icon,false);
  372. }
  373. }
  374. if (empty($_GET['selectcat'])) {
  375. $categories = Category :: load();
  376. $weight_categories = $certificate_min_scores = $course_codes = array();
  377. foreach ($categories as $category) {
  378. $course_code_category = $this->build_course_code($category);
  379. if (!empty($course_code)) {
  380. if ($course_code_category == $course_code) {
  381. $weight_categories[] = intval($this->build_weight($category));
  382. $certificate_min_scores[] = intval($this->build_certificate_min_score($category));
  383. $course_codes[] = $course_code;
  384. break;
  385. }
  386. } else {
  387. $weight_categories[] = intval($this->build_weight($category));
  388. $certificate_min_scores[] = intval($this->build_certificate_min_score($category));
  389. $course_codes[] = $course_code_category;
  390. }
  391. }
  392. if (is_array($weight_categories) && is_array($certificate_min_scores) && is_array($course_codes)) {
  393. $warning_message = '';
  394. for ($x = 0; $x<count($weight_categories);$x++) {
  395. $weight_category = intval($weight_categories[$x]);
  396. $certificate_min_score = intval($certificate_min_scores[$x]);
  397. $course_code = $course_codes[$x];
  398. if (empty($certificate_min_score) || ($certificate_min_score > $weight_category)) {
  399. $warning_message .= $course_code .'&nbsp;-&nbsp;'.get_lang('CertificateMinimunScoreIsRequiredAndMustNotBeMoreThan').'&nbsp;'.$weight_category.'<br />';
  400. }
  401. }
  402. if (!empty($warning_message)) {
  403. Display::display_warning_message($warning_message,false);
  404. }
  405. }
  406. }
  407. }
  408. return $sortable_data;
  409. }
  410. // Other functions
  411. /**
  412. * @param $item
  413. * @return mixed
  414. */
  415. private function build_certificate_min_score ($item)
  416. {
  417. return $item->get_certificate_min_score();
  418. }
  419. /**
  420. * @param $item
  421. * @return mixed
  422. */
  423. private function build_weight($item)
  424. {
  425. return $item->get_weight();
  426. }
  427. /**
  428. * @param $item
  429. * @return mixed
  430. */
  431. private function build_course_code ($item)
  432. {
  433. return $item->get_course_code();
  434. }
  435. /**
  436. * @param $item
  437. * @return string
  438. */
  439. private function build_id_column ($item)
  440. {
  441. switch ($item->get_item_type()) {
  442. // category
  443. case 'C' :
  444. return 'CATE' . $item->get_id();
  445. // evaluation
  446. case 'E' :
  447. return 'EVAL' . $item->get_id();
  448. // link
  449. case 'L' :
  450. return 'LINK' . $item->get_id();
  451. }
  452. }
  453. /**
  454. * @param $item
  455. * @param array $attributes
  456. * @return string
  457. */
  458. private function build_type_column ($item, $attributes = array())
  459. {
  460. return build_type_icon_tag($item->get_icon_name(), $attributes);
  461. }
  462. /**
  463. * Generate name column
  464. * @param unknown_type $item
  465. * @return string
  466. */
  467. private function build_name_link ($item)
  468. {
  469. $view = isset($_GET['view']) ? Security::remove_XSS($_GET['view']) : null;
  470. //$session_id = api_get_session_id();
  471. switch ($item->get_item_type()) {
  472. // category
  473. case 'C' :
  474. $prms_uri='?selectcat=' . $item->get_id() . '&amp;view='.Security::remove_XSS($_GET['view']);
  475. if (isset($_GET['isStudentView'])) {
  476. if ( isset($is_student) || ( isset($_SESSION['studentview']) && $_SESSION['studentview']=='studentview') ) {
  477. $prms_uri=$prms_uri.'&amp;isStudentView='.Security::remove_XSS($_GET['isStudentView']);
  478. }
  479. }
  480. $cat = new Category();
  481. $show_message=$cat->show_message_resource_delete($item->get_course_code());
  482. return '&nbsp;<a href="'.Security::remove_XSS($_SESSION['gradebook_dest']).$prms_uri.'">'
  483. . $item->get_name()
  484. . '</a>'
  485. . ($item->is_course() ? ' &nbsp;[' . $item->get_course_code() . ']'.$show_message : '');
  486. // evaluation
  487. case 'E' :
  488. $cat = new Category();
  489. $course_id = CourseManager::get_course_by_category($_GET['selectcat']);
  490. $show_message = $cat->show_message_resource_delete($course_id);
  491. // course/platform admin can go to the view_results page
  492. if (api_is_allowed_to_edit() && $show_message===false) {
  493. if ($item->get_type() == 'presence') {
  494. return '&nbsp;'
  495. . '<a href="gradebook_view_result.php?cidReq='.$course_id.'&amp;selecteval=' . $item->get_id() . '">'
  496. . $item->get_name()
  497. . '</a>';
  498. } else {
  499. return '&nbsp;'
  500. . '<a href="gradebook_view_result.php?cidReq='.$course_id.'&amp;selecteval=' . $item->get_id() . '">'
  501. . $item->get_name()
  502. . '</a>&nbsp;'.Display::label(get_lang('Evaluation'));
  503. }
  504. } elseif (ScoreDisplay :: instance()->is_custom() && $show_message===false) {
  505. // students can go to the statistics page (if custom display enabled)
  506. return '&nbsp;'
  507. . '<a href="gradebook_statistics.php?selecteval=' . $item->get_id() . '">'
  508. . $item->get_name()
  509. . '</a>';
  510. } elseif ($show_message===false && !api_is_allowed_to_edit() && !(ScoreDisplay :: instance()->is_custom())) {
  511. return '&nbsp;'
  512. . '<a href="gradebook_statistics.php?selecteval=' . $item->get_id() . '">'
  513. . $item->get_name()
  514. . '</a>';
  515. } else {
  516. return '['.get_lang('Evaluation').']&nbsp;&nbsp;'.$item->get_name().$show_message;
  517. }
  518. // link
  519. case 'L' :
  520. $cat = new Category();
  521. $course_id = CourseManager::get_course_by_category($_GET['selectcat']);
  522. $show_message = $cat->show_message_resource_delete($course_id);
  523. $url = $item->get_link();
  524. if (isset($url) && $show_message===false) {
  525. $text = '&nbsp;<a href="' . $item->get_link() . '">'
  526. . $item->get_name()
  527. . '</a>';
  528. } else {
  529. $text = $item->get_name();
  530. }
  531. $text .= "&nbsp;".Display::label($item->get_type_name(), 'info').$show_message;
  532. $cc = $this->currentcat->get_course_code();
  533. if (empty($cc)) {
  534. $text .= '&nbsp;[<a href="'.api_get_path(REL_COURSE_PATH).$item->get_course_code().'/">'.$item->get_course_code().'</a>]';
  535. }
  536. return $text;
  537. }
  538. }
  539. /**
  540. * @param $item
  541. * @return null|string
  542. */
  543. private function build_edit_column($item)
  544. {
  545. switch ($item->get_item_type()) {
  546. // category
  547. case 'C' :
  548. return build_edit_icons_cat($item, $this->currentcat);
  549. // evaluation
  550. case 'E' :
  551. return build_edit_icons_eval($item, $this->currentcat->get_id());
  552. // link
  553. case 'L' :
  554. return build_edit_icons_link($item, $this->currentcat->get_id());
  555. }
  556. }
  557. }