displaygradebook.php 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628
  1. <?php
  2. /* For licensing terms, see /license.txt */
  3. /**
  4. * Class DisplayGradebook
  5. * @package chamilo.gradebook
  6. */
  7. class DisplayGradebook
  8. {
  9. /**
  10. * Displays the header for the result page containing the navigation tree and links
  11. * @param $evalobj
  12. * @param $selectcat
  13. * @param $shownavbar 1=show navigation bar
  14. * @param $forpdf only output for pdf file
  15. */
  16. public static function display_header_result($evalobj, $selectcat, $page)
  17. {
  18. $header = null;
  19. if (api_is_allowed_to_edit(null, true)) {
  20. $header = '<div class="actions">';
  21. if ($page != 'statistics') {
  22. $header .= '<a href="' . Security::remove_XSS($_SESSION['gradebook_dest']) . '?selectcat=' . $selectcat . '&'.api_get_cidreq().'">' .
  23. Display::return_icon(('back.png'), get_lang('FolderView'), '', ICON_SIZE_MEDIUM) . '</a>';
  24. if ($evalobj->get_course_code() == null) {
  25. } elseif (!$evalobj->has_results()) {
  26. $header .= '<a href="gradebook_add_result.php?'.api_get_cidreq().'&selectcat=' . $selectcat . '&selecteval=' . $evalobj->get_id() . '">
  27. ' . Display::return_icon('evaluation_rate.png', get_lang('AddResult'), '', ICON_SIZE_MEDIUM) . '</a>';
  28. }
  29. if (api_is_platform_admin() || $evalobj->is_locked() == false) {
  30. $header .= '<a href="' . api_get_self() . '?'.api_get_cidreq().'&selecteval=' . $evalobj->get_id() . '&import=">' .
  31. Display::return_icon('import_evaluation.png', get_lang('ImportResult'), '', ICON_SIZE_MEDIUM) . '</a>';
  32. }
  33. if ($evalobj->has_results()) {
  34. $header .= '<a href="' . api_get_self() . '?'.api_get_cidreq().'&selecteval=' . $evalobj->get_id() . '&export=">' .
  35. Display::return_icon('export_evaluation.png', get_lang('ExportResult'), '', ICON_SIZE_MEDIUM) . '</a>';
  36. if (api_is_platform_admin() || $evalobj->is_locked() == false) {
  37. $header .= '<a href="gradebook_edit_result.php?'.api_get_cidreq().'&selecteval=' . $evalobj->get_id() . '">' .
  38. Display::return_icon('edit.png', get_lang('EditResult'), '', ICON_SIZE_MEDIUM) . '</a>';
  39. $header .= '<a href="' . api_get_self() . '?'.api_get_cidreq().'&selecteval=' . $evalobj->get_id() . '&deleteall=" onclick="return confirmationall();">' .
  40. Display::return_icon('delete.png', get_lang('DeleteResult'), '', ICON_SIZE_MEDIUM) . '</a>';
  41. }
  42. }
  43. $header .= '<a href="'.api_get_self().'?'.api_get_cidreq().'&print=&selecteval='.$evalobj->get_id().'" target="_blank">'.
  44. Display::return_icon('printer.png', get_lang('Print'), '', ICON_SIZE_MEDIUM).'</a>';
  45. } else {
  46. $header .= '<a href="gradebook_view_result.php?'.api_get_cidreq().'&selecteval='.Security::remove_XSS($_GET['selecteval']).'"> '.
  47. Display::return_icon(('back.png'), get_lang('FolderView'), '', ICON_SIZE_MEDIUM).'</a>';
  48. }
  49. $header .= '</div>';
  50. }
  51. if ($evalobj->is_visible() == '1') {
  52. $visible = get_lang('Yes');
  53. } else {
  54. $visible = get_lang('No');
  55. }
  56. $scoredisplay = ScoreDisplay::instance();
  57. $student_score = '';
  58. $average = '';
  59. if (($evalobj->has_results())) {
  60. // TODO this check needed ?
  61. $score = $evalobj->calc_score();
  62. if ($score != null) {
  63. $average = get_lang('Average').' :<b> '.$scoredisplay->display_score($score, SCORE_AVERAGE).'</b>';
  64. $student_score = $evalobj->calc_score(api_get_user_id());
  65. $student_score = Display::tag(
  66. 'h3',
  67. get_lang('Score').': '.$scoredisplay->display_score($student_score, SCORE_DIV_PERCENT)
  68. );
  69. }
  70. }
  71. $description = "";
  72. if (!$evalobj->get_description() == '') {
  73. $description = get_lang('Description').' :<b> '.$evalobj->get_description().'</b><br>';
  74. }
  75. if ($evalobj->get_course_code() == null) {
  76. $course = get_lang('CourseIndependent');
  77. } else {
  78. $course = CourseManager::getCourseNameFromCode($evalobj->get_course_code());
  79. }
  80. $evalinfo = '<table width="100%" border="0"><tr><td>';
  81. $evalinfo .= '<h2>'.$evalobj->get_name().'</h2><hr>';
  82. $evalinfo .= $description;
  83. $evalinfo .= get_lang('Course').' :<b> '.$course.'</b><br />';
  84. $evalinfo .= get_lang('QualificationNumeric').' :<b> '.$evalobj->get_max().'</b><br>'.$average;
  85. if (!api_is_allowed_to_edit()) {
  86. $evalinfo .= $student_score;
  87. }
  88. if (!$evalobj->has_results()) {
  89. $evalinfo .= '<br /><i>'.get_lang('NoResultsInEvaluation').'</i>';
  90. }
  91. /* Code comment without reason
  92. elseif ($scoredisplay->is_custom() && api_get_self() != '/main/gradebook/gradebook_statistics.php') {
  93. if (api_is_allowed_to_edit(null, true)) {
  94. if ($page != 'statistics') {
  95. //$evalinfo .= '<br /><br /><a href="gradebook_view_result.php?selecteval='.Security::remove_XSS($_GET['selecteval']).'"> '.Display::return_icon(('evaluation_rate.png'),get_lang('ViewResult'),'',ICON_SIZE_MEDIUM) . '</a>';
  96. }
  97. }
  98. }
  99. */
  100. if ($page != 'statistics') {
  101. if (api_is_allowed_to_edit(null, true)) {
  102. $evalinfo .= '<br /><a href="gradebook_statistics.php?'.api_get_cidreq().'&selecteval='.Security::remove_XSS($_GET['selecteval']).'"> '.
  103. Display::return_icon(
  104. 'statistics.png',
  105. get_lang('ViewStatistics'),
  106. '',
  107. ICON_SIZE_MEDIUM
  108. ).'</a>';
  109. }
  110. }
  111. $evalinfo .= '</td><td>'.
  112. Display::return_icon(
  113. 'tutorial.gif',
  114. '',
  115. ['style' => 'float:right; position:relative;']
  116. )
  117. .'</td></table>';
  118. echo $evalinfo;
  119. echo $header;
  120. }
  121. /**
  122. * Displays the header for the flatview page containing filters
  123. * @param $catobj
  124. * @param $showeval
  125. * @param $showlink
  126. */
  127. public static function display_header_reduce_flatview($catobj, $showeval, $showlink, $simple_search_form)
  128. {
  129. $header = '<div class="actions">';
  130. if ($catobj->get_parent_id() == 0) {
  131. $select_cat = $catobj->get_id();
  132. $url = Category::getUrl();
  133. } else {
  134. $select_cat = $catobj->get_parent_id();
  135. $url = 'gradebook_flatview.php';
  136. }
  137. $header .= '<a href="'.$url.'?'.api_get_cidreq().'&selectcat='.$select_cat.'">'.
  138. Display::return_icon('back.png', get_lang('FolderView'), '', ICON_SIZE_MEDIUM).'</a>';
  139. $pageNum = isset($_GET['flatviewlist_page_nr']) ? intval($_GET['flatviewlist_page_nr']) : null;
  140. $perPage = isset($_GET['flatviewlist_per_page']) ? intval($_GET['flatviewlist_per_page']) : null;
  141. $offset = isset($_GET['offset']) ? $_GET['offset'] : '0';
  142. $exportCsvUrl = api_get_self().'?'.api_get_cidreq().'&'.http_build_query([
  143. 'export_format' => 'csv',
  144. 'export_report' => 'export_report',
  145. 'selectcat' => $catobj->get_id()
  146. ]);
  147. $header .= Display::url(
  148. Display::return_icon(
  149. 'export_csv.png',
  150. get_lang('ExportAsCSV'),
  151. '',
  152. ICON_SIZE_MEDIUM
  153. ),
  154. $exportCsvUrl
  155. );
  156. $exportXlsUrl = api_get_self().'?'.api_get_cidreq().'&'.http_build_query([
  157. 'export_format' => 'xls',
  158. 'export_report' => 'export_report',
  159. 'selectcat' => $catobj->get_id()
  160. ]);
  161. $header .= Display::url(
  162. Display::return_icon(
  163. 'export_excel.png',
  164. get_lang('ExportAsXLS'),
  165. '',
  166. ICON_SIZE_MEDIUM
  167. ),
  168. $exportXlsUrl
  169. );
  170. $exportDocUrl = api_get_self().'?'.api_get_cidreq().'&'.http_build_query([
  171. 'export_format' => 'doc',
  172. 'export_report' => 'export_report',
  173. 'selectcat' => $catobj->get_id()
  174. ]);
  175. $header .= Display::url(
  176. Display::return_icon(
  177. 'export_doc.png',
  178. get_lang('ExportAsDOC'),
  179. '',
  180. ICON_SIZE_MEDIUM
  181. ),
  182. $exportDocUrl
  183. );
  184. $exportPrintUrl = api_get_self().'?'.api_get_cidreq().'&'.http_build_query([
  185. 'print' => '',
  186. 'selectcat' => $catobj->get_id(),
  187. ]);
  188. $header .= Display::url(
  189. Display::return_icon(
  190. 'printer.png',
  191. get_lang('Print'),
  192. '',
  193. ICON_SIZE_MEDIUM
  194. ),
  195. $exportPrintUrl,
  196. ['target' => '_blank']
  197. );
  198. $exportPdfUrl = api_get_self().'?'.api_get_cidreq().'&'.http_build_query([
  199. 'exportpdf' => '',
  200. 'selectcat' => $catobj->get_id(),
  201. 'offset' => $offset,
  202. 'flatviewlist_page_nr' => $pageNum,
  203. 'flatviewlist_per_page' => $perPage
  204. ]);
  205. $header .= Display::url(
  206. Display::return_icon(
  207. 'pdf.png',
  208. get_lang('ExportToPDF'),
  209. '',
  210. ICON_SIZE_MEDIUM
  211. ),
  212. $exportPdfUrl
  213. );
  214. $header .= '</div>';
  215. echo $header;
  216. }
  217. /**
  218. * Displays the header for the gradebook containing the navigation tree and links
  219. * @param Category $catobj
  220. * @param int $showtree '1' will show the browse tree and naviation buttons
  221. * @param boolean $is_course_admin
  222. * @param boolean $is_platform_admin
  223. * @param boolean Whether to show or not the link to add a new qualification
  224. * (we hide it in case of the course-embedded tool where we have only one
  225. * calification per course or session)
  226. * @param boolean Whether to show or not the link to add a new item inside
  227. * the qualification (we hide it in case of the course-embedded tool
  228. * where we have only one calification per course or session)
  229. * @return void Everything is printed on screen upon closing
  230. */
  231. public static function header(
  232. $catobj,
  233. $showtree,
  234. $selectcat,
  235. $is_course_admin,
  236. $is_platform_admin,
  237. $simple_search_form,
  238. $show_add_qualification = true,
  239. $show_add_link = true,
  240. $certificateLinkInfo = null
  241. ) {
  242. $userId = api_get_user_id();
  243. $courseId = api_get_course_int_id();
  244. $sessionId = api_get_session_id();
  245. // Student.
  246. $status = CourseManager::getUserInCourseStatus($userId, $courseId);
  247. $sessionStatus = 0;
  248. if (!empty($sessionId)) {
  249. $sessionStatus = SessionManager::get_user_status_in_course_session(
  250. $userId,
  251. $courseId,
  252. $sessionId
  253. );
  254. }
  255. $objcat = new Category();
  256. $course_id = CourseManager::get_course_by_category($selectcat);
  257. $message_resource = $objcat->show_message_resource_delete($course_id);
  258. $grade_model_id = $catobj->get_grade_model_id();
  259. $header = null;
  260. if (isset($catobj) && !empty($catobj)) {
  261. $categories = Category::load(
  262. null,
  263. null,
  264. null,
  265. $catobj->get_id(),
  266. null,
  267. $sessionId
  268. );
  269. }
  270. if (!$is_course_admin && ($status <> 1 || $sessionStatus == 0) && $selectcat <> 0) {
  271. $catcourse = Category::load($catobj->get_id());
  272. /** @var Category $category */
  273. $category = $catcourse[0];
  274. $main_weight = $category->get_weight();
  275. $scoredisplay = ScoreDisplay::instance();
  276. $allevals = $category->get_evaluations($userId, true);
  277. $alllinks = $category->get_links($userId, true);
  278. $allEvalsLinks = array_merge($allevals, $alllinks);
  279. $item_value_total = 0;
  280. $scoreinfo = null;
  281. for ($count = 0; $count < count($allEvalsLinks); $count++) {
  282. $item = $allEvalsLinks[$count];
  283. $score = $item->calc_score($userId);
  284. if (!empty($score)) {
  285. $divide = $score[1] == 0 ? 1 : $score[1];
  286. $item_value = $score[0] / $divide * $item->get_weight();
  287. $item_value_total += $item_value;
  288. }
  289. }
  290. $item_total = $main_weight;
  291. $total_score = array($item_value_total, $item_total);
  292. $scorecourse_display = $scoredisplay->display_score($total_score, SCORE_DIV_PERCENT);
  293. if ((!$catobj->get_id() == '0') && (!isset($_GET['studentoverview'])) && (!isset($_GET['search']))) {
  294. $aditionalButtons = null;
  295. if (!empty($certificateLinkInfo)) {
  296. $aditionalButtons .= '<div class="btn-group pull-right">';
  297. $aditionalButtons .= isset($certificateLinkInfo['certificate_link']) ? $certificateLinkInfo['certificate_link'] : '';
  298. $aditionalButtons .= isset($certificateLinkInfo['badge_link']) ? $certificateLinkInfo['badge_link'] : '';
  299. $aditionalButtons .= '</div>';
  300. }
  301. $scoreinfo .= '<strong>'.sprintf(get_lang('TotalX'), $scorecourse_display.$aditionalButtons).'</strong>';
  302. }
  303. echo Display::return_message($scoreinfo, 'normal', false);
  304. }
  305. // show navigation tree and buttons?
  306. if ($showtree == '1' || isset($_GET['studentoverview'])) {
  307. $header = '<div class="actions"><table>';
  308. $header .= '<tr>';
  309. if (!$selectcat == '0') {
  310. $header .= '<td><a href="'.api_get_self().'?selectcat='.$catobj->get_parent_id().'">'.
  311. Display::return_icon(
  312. 'back.png',
  313. get_lang('BackTo').' '.get_lang('RootCat'),
  314. '',
  315. ICON_SIZE_MEDIUM
  316. ).
  317. '</a></td>';
  318. }
  319. $header .= '<td>'.get_lang('CurrentCategory').'</td>'.
  320. '<td><form name="selector"><select name="selectcat" onchange="document.selector.submit()">';
  321. $cats = Category::load();
  322. $tree = $cats[0]->get_tree();
  323. unset($cats);
  324. $line = null;
  325. foreach ($tree as $cat) {
  326. for ($i = 0; $i < $cat[2]; $i++) {
  327. $line .= '&mdash;';
  328. }
  329. $line = isset($line) ? $line : '';
  330. if (isset($_GET['selectcat']) && $_GET['selectcat'] == $cat[0]) {
  331. $header .= '<option selected value='.$cat[0].'>'.$line.' '.$cat[1].'</option>';
  332. } else {
  333. $header .= '<option value='.$cat[0].'>'.$line.' '.$cat[1].'</option>';
  334. }
  335. $line = '';
  336. }
  337. $header .= '</select></form></td>';
  338. if (!empty($simple_search_form) && $message_resource === false) {
  339. $header .= '<td style="vertical-align: top;">'.$simple_search_form->toHtml().'</td>';
  340. } else {
  341. $header .= '<td></td>';
  342. }
  343. if (!($is_course_admin &&
  344. $message_resource === false &&
  345. isset($_GET['selectcat']) && $_GET['selectcat'] != 0) &&
  346. isset($_GET['studentoverview'])
  347. ) {
  348. $header .= '<td style="vertical-align: top;"><a href="'.api_get_self().'?'.api_get_cidreq().'&studentoverview=&exportpdf=&selectcat='.$catobj->get_id().'" target="_blank">
  349. '.Display::return_icon('pdf.png', get_lang('ExportPDF'), [], ICON_SIZE_MEDIUM).'
  350. ' . get_lang('ExportPDF').'</a>';
  351. }
  352. $header .= '</td></tr>';
  353. $header .= '</table></div>';
  354. }
  355. // for course admin & platform admin add item buttons are added to the header
  356. $actionsLeft = '';
  357. $actionsRight = '';
  358. $my_api_cidreq = api_get_cidreq();
  359. if (api_is_allowed_to_edit(null, true)) {
  360. if (empty($grade_model_id) || $grade_model_id == -1) {
  361. $actionsLeft .= '<a href="gradebook_add_cat.php?'.api_get_cidreq().'&selectcat='.$catobj->get_id().'">'.
  362. Display::return_icon(
  363. 'new_folder.png',
  364. get_lang('AddGradebook'),
  365. array(),
  366. ICON_SIZE_MEDIUM
  367. ).'</a></td>';
  368. }
  369. if ($selectcat != '0') {
  370. $my_category = $catobj->showAllCategoryInfo($catobj->get_id());
  371. if ($my_api_cidreq == '') {
  372. $my_api_cidreq = 'cidReq='.$my_category['course_code'];
  373. }
  374. if ($show_add_link && !$message_resource) {
  375. $actionsLeft .= '<a href="gradebook_add_eval.php?'.$my_api_cidreq.'&selectcat='.$catobj->get_id().'" >'.
  376. Display::return_icon('new_evaluation.png', get_lang('NewEvaluation'), '', ICON_SIZE_MEDIUM).'</a>';
  377. $cats = Category::load($selectcat);
  378. if ($cats[0]->get_course_code() != null && !$message_resource) {
  379. $actionsLeft .= '<a href="gradebook_add_link.php?'.$my_api_cidreq.'&selectcat='.$catobj->get_id().'">'.
  380. Display::return_icon('new_online_evaluation.png', get_lang('MakeLink'), '', ICON_SIZE_MEDIUM).'</a>';
  381. } else {
  382. $actionsLeft .= '<a href="gradebook_add_link_select_course.php?'.$my_api_cidreq.'&selectcat='.$catobj->get_id().'">'.
  383. Display::return_icon('new_online_evaluation.png', get_lang('MakeLink'), '', ICON_SIZE_MEDIUM).'</a>';
  384. }
  385. }
  386. if (!$message_resource) {
  387. $actionsLeft .= '<a href="gradebook_flatview.php?'.$my_api_cidreq.'&selectcat='.$catobj->get_id().'">'.
  388. Display::return_icon('stats.png', get_lang('FlatView'), '', ICON_SIZE_MEDIUM).'</a>';
  389. if ($my_category['generate_certificates'] == 1) {
  390. $actionsLeft .= Display::url(
  391. Display::return_icon(
  392. 'certificate_list.png',
  393. get_lang('GradebookSeeListOfStudentsCertificates'),
  394. '',
  395. ICON_SIZE_MEDIUM
  396. ),
  397. "gradebook_display_certificate.php?$my_api_cidreq&cat_id=".$selectcat
  398. );
  399. }
  400. $actionsLeft .= Display::url(
  401. Display::return_icon(
  402. 'user.png',
  403. get_lang('GradebookListOfStudentsReports'),
  404. '',
  405. ICON_SIZE_MEDIUM
  406. ),
  407. "gradebook_display_summary.php?$my_api_cidreq&selectcat=".$selectcat
  408. );
  409. $allow = api_get_configuration_value('gradebook_custom_student_report');
  410. if ($allow) {
  411. $actionsLeft .= Display::url(
  412. get_lang('GenerateCustomReport'),
  413. api_get_path(WEB_AJAX_PATH)."gradebook.ajax.php?$my_api_cidreq&a=generate_custom_report",
  414. ['class' => 'btn btn-default ajax']
  415. );
  416. }
  417. // Right icons
  418. $actionsRight = '<a href="gradebook_edit_cat.php?editcat='.$catobj->get_id().'&amp;cidReq='.$catobj->get_course_code().'&id_session='.$catobj->get_session_id().'">'.
  419. Display::return_icon('edit.png', get_lang('Edit'), '', ICON_SIZE_MEDIUM).'</a>';
  420. $actionsRight .= '<a href="../document/document.php?curdirpath=/certificates&'.$my_api_cidreq.'&origin=gradebook&selectcat='.$catobj->get_id().'">'.
  421. Display::return_icon('certificate.png', get_lang('AttachCertificate'), '', ICON_SIZE_MEDIUM).'</a>';
  422. if (empty($categories)) {
  423. $actionsRight .= '<a href="gradebook_edit_all.php?id_session='.api_get_session_id().'&amp;'.$my_api_cidreq.'&selectcat='.$catobj->get_id().'">'.
  424. Display::return_icon('percentage.png', get_lang('EditAllWeights'), '', ICON_SIZE_MEDIUM).'</a>';
  425. }
  426. $score_display_custom = api_get_setting('gradebook_score_display_custom');
  427. if (api_get_setting('teachers_can_change_score_settings') == 'true' && $score_display_custom['my_display_custom'] == 'true') {
  428. $actionsRight .= '<a href="gradebook_scoring_system.php?'.$my_api_cidreq.'&selectcat='.$catobj->get_id().'">'.
  429. Display::return_icon('ranking.png', get_lang('ScoreEdit'), '', ICON_SIZE_MEDIUM).'</a>';
  430. }
  431. }
  432. }
  433. } elseif (isset($_GET['search'])) {
  434. echo $header = '<b>'.get_lang('SearchResults').' :</b>';
  435. }
  436. $isDrhOfCourse = CourseManager::isUserSubscribedInCourseAsDrh(
  437. api_get_user_id(),
  438. api_get_course_info()
  439. );
  440. if ($isDrhOfCourse) {
  441. $actionsLeft .= '<a href="gradebook_flatview.php?'.$my_api_cidreq.'&selectcat='.$catobj->get_id().'">'.
  442. Display::return_icon(
  443. 'stats.png',
  444. get_lang('FlatView'),
  445. '',
  446. ICON_SIZE_MEDIUM
  447. ).
  448. '</a>';
  449. }
  450. if (api_is_allowed_to_edit(null, true)) {
  451. echo $toolbar = Display::toolbarAction(
  452. 'gradebook-actions',
  453. array($actionsLeft, $actionsRight)
  454. );
  455. }
  456. if (api_is_allowed_to_edit(null, true)) {
  457. $weight = intval($catobj->get_weight()) > 0 ? $catobj->get_weight() : 0;
  458. $weight = '<strong>'.get_lang('TotalWeight').' : </strong>'.$weight;
  459. $min_certification = (intval($catobj->getCertificateMinScore() > 0) ? $catobj->getCertificateMinScore() : 0);
  460. $min_certification = get_lang('CertificateMinScore').' : '.$min_certification;
  461. $edit_icon = '<a href="gradebook_edit_cat.php?editcat='.$catobj->get_id().'&amp;cidReq='.$catobj->get_course_code().'&id_session='.$catobj->get_session_id().'">'.
  462. Display::return_icon('edit.png', get_lang('Edit'), array(), ICON_SIZE_SMALL).'</a>';
  463. //$msg = Display::tag('h3', $weight.' - '.$min_certification);
  464. $msg = $weight.' - '.$min_certification.$edit_icon;
  465. //@todo show description
  466. $description = (($catobj->get_description() == "" || is_null($catobj->get_description())) ? '' : '<strong>'.get_lang('GradebookDescriptionLog').'</strong>'.': '.$catobj->get_description());
  467. echo Display::return_message($msg, 'normal', false);
  468. if (!empty($description)) {
  469. echo Display::div($description, array());
  470. }
  471. }
  472. }
  473. /**
  474. * @param Category $catobj
  475. * @param $is_course_admin
  476. * @param $is_platform_admin
  477. * @param $simple_search_form
  478. * @param bool $show_add_qualification
  479. * @param bool $show_add_link
  480. */
  481. public function display_reduce_header_gradebook(
  482. $catobj,
  483. $is_course_admin,
  484. $is_platform_admin,
  485. $simple_search_form,
  486. $show_add_qualification = true,
  487. $show_add_link = true
  488. ) {
  489. //student
  490. if (!$is_course_admin) {
  491. $user = api_get_user_info(api_get_user_id());
  492. $catcourse = Category::load($catobj->get_id());
  493. $scoredisplay = ScoreDisplay::instance();
  494. $scorecourse = $catcourse[0]->calc_score(api_get_user_id());
  495. $scorecourse_display = isset($scorecourse) ? $scoredisplay->display_score($scorecourse, SCORE_AVERAGE) : get_lang('NoResultsAvailable');
  496. $cattotal = Category::load(0);
  497. $scoretotal = $cattotal[0]->calc_score(api_get_user_id());
  498. $scoretotal_display = isset($scoretotal) ? $scoredisplay->display_score($scoretotal, SCORE_PERCENT) : get_lang('NoResultsAvailable');
  499. $scoreinfo = get_lang('StatsStudent').' :<b> '.$user['complete_name'].'</b><br />';
  500. if ((!$catobj->get_id() == '0') && (!isset($_GET['studentoverview'])) && (!isset($_GET['search'])))
  501. $scoreinfo .= '<br />'.get_lang('TotalForThisCategory').' : <b>'.$scorecourse_display.'</b>';
  502. $scoreinfo .= '<br />'.get_lang('Total').' : <b>'.$scoretotal_display.'</b>';
  503. Display::addFlash(
  504. Display::return_message($scoreinfo, 'normal', false)
  505. );
  506. }
  507. // show navigation tree and buttons?
  508. $header = '<div class="actions">';
  509. if ($is_course_admin) {
  510. $header .= '<a href="gradebook_flatview.php?'.api_get_cidreq().'&selectcat='.$catobj->get_id().'">'.Display::return_icon('stats.png', get_lang('FlatView'), '', ICON_SIZE_MEDIUM).'</a>';
  511. $header .= '<a href="gradebook_scoring_system.php?'.api_get_cidreq().'&selectcat='.$catobj->get_id().'">'.Display::return_icon('settings.png', get_lang('ScoreEdit'), '', ICON_SIZE_MEDIUM).'</a>';
  512. } elseif (!(isset($_GET['studentoverview']))) {
  513. $header .= '<a href="'.api_get_self().'?'.api_get_cidreq().'&studentoverview=&selectcat='.$catobj->get_id().'">'.Display::return_icon('view_list.gif', get_lang('FlatView')).' '.get_lang('FlatView').'</a>';
  514. } else {
  515. $header .= '<a href="'.api_get_self().'?'.api_get_cidreq().'&studentoverview=&exportpdf=&selectcat='.$catobj->get_id().'" target="_blank">'.Display::return_icon('pdf.png', get_lang('ExportPDF'), '', ICON_SIZE_MEDIUM).'</a>';
  516. }
  517. $header .= '</div>';
  518. echo $header;
  519. }
  520. /**
  521. * @param $userId
  522. * @param $categoryId
  523. * @return string
  524. */
  525. public static function display_header_user($userId, $categoryId)
  526. {
  527. $user = api_get_user_info($userId);
  528. if (empty($user)) {
  529. return '';
  530. }
  531. $catcourse = Category::load($categoryId);
  532. $scoredisplay = ScoreDisplay::instance();
  533. // generating the total score for a course
  534. $allevals = $catcourse[0]->get_evaluations(
  535. $userId,
  536. true,
  537. api_get_course_id()
  538. );
  539. $alllinks = $catcourse[0]->get_links(
  540. $userId,
  541. true,
  542. api_get_course_id()
  543. );
  544. $evals_links = array_merge($allevals, $alllinks);
  545. $item_value = 0;
  546. $item_total = 0;
  547. for ($count = 0; $count < count($evals_links); $count++) {
  548. $item = $evals_links[$count];
  549. $score = $item->calc_score($userId);
  550. $my_score_denom = ($score[1] == 0) ? 1 : $score[1];
  551. $item_value += $score[0] / $my_score_denom * $item->get_weight();
  552. $item_total += $item->get_weight();
  553. }
  554. $item_value = api_number_format($item_value, 2);
  555. $total_score = array($item_value, $item_total);
  556. $scorecourse_display = $scoredisplay->display_score($total_score, SCORE_DIV_PERCENT);
  557. $info = '<div class="row"><div class="col-md-3">';
  558. $info .= '<div class="thumbnail"><img src="'.$user['avatar'].'" /></div>';
  559. $info .= '</div>';
  560. $info .= '<div class="col-md-6">';
  561. $info .= get_lang('Name').' : <a target="_blank" href="'.api_get_path(WEB_CODE_PATH).'social/profile.php?u='.$userId.'"> '.
  562. $user['complete_name'].'</a><br />';
  563. if (api_get_setting('show_email_addresses') == 'true') {
  564. $info .= get_lang('Email').' : <a href="mailto:'.$user['email'].'">'.$user['email'].'</a><br />';
  565. }
  566. $info .= get_lang('TotalUser').' : <b>'.$scorecourse_display.'</b>';
  567. $info .= '</div>';
  568. $info .= '</div>';
  569. echo $info;
  570. }
  571. }