displaygradebook.php 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559
  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())) { // TODO this check needed ?
  60. $score = $evalobj->calc_score();
  61. if ($score != null) {
  62. $average = get_lang('Average') . ' :<b> ' . $scoredisplay->display_score($score, SCORE_AVERAGE) . '</b>';
  63. $student_score = $evalobj->calc_score(api_get_user_id());
  64. $student_score = Display::tag(
  65. 'h3',
  66. get_lang('Score') . ': ' . $scoredisplay->display_score($student_score, SCORE_DIV_PERCENT)
  67. );
  68. }
  69. }
  70. $description = "";
  71. if (!$evalobj->get_description() == '') {
  72. $description = get_lang('Description') . ' :<b> ' . $evalobj->get_description() . '</b><br>';
  73. }
  74. if ($evalobj->get_course_code() == null) {
  75. $course = get_lang('CourseIndependent');
  76. } else {
  77. $course = CourseManager::getCourseNameFromCode($evalobj->get_course_code());
  78. }
  79. $evalinfo = '<table width="100%" border="0"><tr><td>';
  80. $evalinfo .= '<h2>' . $evalobj->get_name() . '</h2><hr>';
  81. $evalinfo .= $description;
  82. $evalinfo .= get_lang('Course') . ' :<b> ' . $course . '</b><br />';
  83. $evalinfo .= get_lang('QualificationNumeric') . ' :<b> ' . $evalobj->get_max() . '</b><br>' . $average;
  84. if (!api_is_allowed_to_edit()) {
  85. $evalinfo .= $student_score;
  86. }
  87. if (!$evalobj->has_results()) {
  88. $evalinfo .= '<br /><i>' . get_lang('NoResultsInEvaluation') . '</i>';
  89. } elseif ($scoredisplay->is_custom() && api_get_self() != '/main/gradebook/gradebook_statistics.php') {
  90. if (api_is_allowed_to_edit(null, true)) {
  91. if ($page != 'statistics') {
  92. //$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>';
  93. }
  94. }
  95. }
  96. if ($page != 'statistics') {
  97. if (api_is_allowed_to_edit(null, true)) {
  98. $evalinfo .= '<br /><a href="gradebook_statistics.php?' . api_get_cidreq() . '&selecteval=' . Security::remove_XSS($_GET['selecteval']) . '"> ' .
  99. Display::return_icon('statistics.png', get_lang('ViewStatistics'), '', ICON_SIZE_MEDIUM) . '</a>';
  100. }
  101. }
  102. $evalinfo .= '</td><td>'.Display::return_icon('tutorial.gif', '', ['style' => 'float:right; position:relative;']).'</td></table>';
  103. echo $evalinfo;
  104. echo $header;
  105. }
  106. /**
  107. * Displays the header for the flatview page containing filters
  108. * @param $catobj
  109. * @param $showeval
  110. * @param $showlink
  111. */
  112. public static function display_header_reduce_flatview($catobj, $showeval, $showlink, $simple_search_form)
  113. {
  114. $header = '<div class="actions">';
  115. if ($catobj->get_parent_id() == 0) {
  116. $select_cat = $catobj->get_id();
  117. $url = Security::remove_XSS($_SESSION['gradebook_dest']);
  118. } else {
  119. $select_cat = $catobj->get_parent_id();
  120. $url = 'gradebook_flatview.php';
  121. }
  122. $header .= '<a href="' . $url . '?' . api_get_cidreq() . '&selectcat=' . $select_cat . '">' .
  123. Display::return_icon('back.png', get_lang('FolderView'), '', ICON_SIZE_MEDIUM) . '</a>';
  124. $pageNum = isset($_GET['flatviewlist_page_nr']) ? intval($_GET['flatviewlist_page_nr']) : null;
  125. $perPage = isset($_GET['flatviewlist_per_page']) ? intval($_GET['flatviewlist_per_page']) : null;
  126. $offset = isset($_GET['offset']) ? $_GET['offset'] : '0';
  127. $exportCsvUrl = api_get_self() . '?' . api_get_cidreq() . '&' . http_build_query([
  128. 'export_format' => 'csv',
  129. 'export_report' => 'export_report',
  130. 'selectcat' => $catobj->get_id()
  131. ]);
  132. $header .= Display::url(
  133. Display::return_icon('export_csv.png', get_lang('ExportAsCSV'), '', ICON_SIZE_MEDIUM),
  134. $exportCsvUrl
  135. );
  136. $exportXlsUrl = api_get_self() . '?' . api_get_cidreq() . '&' . http_build_query([
  137. 'export_format' => 'xls',
  138. 'export_report' => 'export_report',
  139. 'selectcat' => $catobj->get_id()
  140. ]);
  141. $header .= Display::url(
  142. Display::return_icon('export_excel.png', get_lang('ExportAsXLS'), '', ICON_SIZE_MEDIUM),
  143. $exportXlsUrl
  144. );
  145. $exportDocUrl = api_get_self() . '?' . api_get_cidreq() . '&' . http_build_query([
  146. 'export_format' => 'doc',
  147. 'export_report' => 'export_report',
  148. 'selectcat' => $catobj->get_id()
  149. ]);
  150. $header .= Display::url(
  151. Display::return_icon('export_doc.png', get_lang('ExportAsDOC'), '', ICON_SIZE_MEDIUM),
  152. $exportDocUrl
  153. );
  154. $exportPrintUrl = api_get_self() . '?' . api_get_cidreq() . '&' . http_build_query([
  155. 'print' => '',
  156. 'selectcat' => $catobj->get_id(),
  157. ]);
  158. $header .= Display::url(
  159. Display::return_icon('printer.png', get_lang('Print'), '', ICON_SIZE_MEDIUM),
  160. $exportPrintUrl,
  161. ['target' => '_blank']
  162. );
  163. $exportPdfUrl = api_get_self() . '?' . api_get_cidreq() . '&' . http_build_query([
  164. 'exportpdf' => '',
  165. 'selectcat' => $catobj->get_id(),
  166. 'offset' => $offset,
  167. 'flatviewlist_page_nr' => $pageNum,
  168. 'flatviewlist_per_page' => $perPage
  169. ]);
  170. $header .= Display::url(
  171. Display::return_icon('pdf.png', get_lang('ExportToPDF'), '', ICON_SIZE_MEDIUM),
  172. $exportPdfUrl
  173. );
  174. $header .= '</div>';
  175. echo $header;
  176. }
  177. /**
  178. * Displays the header for the gradebook containing the navigation tree and links
  179. * @param Category $catobj
  180. * @param int $showtree '1' will show the browse tree and naviation buttons
  181. * @param boolean $is_course_admin
  182. * @param boolean $is_platform_admin
  183. * @param boolean Whether to show or not the link to add a new qualification
  184. * (we hide it in case of the course-embedded tool where we have only one
  185. * calification per course or session)
  186. * @param boolean Whether to show or not the link to add a new item inside
  187. * the qualification (we hide it in case of the course-embedded tool
  188. * where we have only one calification per course or session)
  189. * @return void Everything is printed on screen upon closing
  190. */
  191. public static function header(
  192. $catobj,
  193. $showtree,
  194. $selectcat,
  195. $is_course_admin,
  196. $is_platform_admin,
  197. $simple_search_form,
  198. $show_add_qualification = true,
  199. $show_add_link = true,
  200. $certificateLinkInfo = null
  201. ) {
  202. $userId = api_get_user_id();
  203. $courseId = api_get_course_int_id();
  204. $sessionId = api_get_session_id();
  205. // Student.
  206. $status = CourseManager::getUserInCourseStatus($userId, $courseId);
  207. if (!empty($sessionId)) {
  208. $sessionStatus = SessionManager::get_user_status_in_course_session(
  209. $userId,
  210. $courseId,
  211. $sessionId
  212. );
  213. }
  214. $objcat = new Category();
  215. $course_id = CourseManager::get_course_by_category($selectcat);
  216. $message_resource = $objcat->show_message_resource_delete($course_id);
  217. $grade_model_id = $catobj->get_grade_model_id();
  218. $header = null;
  219. if (isset($catobj) && !empty($catobj)) {
  220. $categories = Category::load(
  221. null,
  222. null,
  223. null,
  224. $catobj->get_id(),
  225. null,
  226. $sessionId
  227. );
  228. }
  229. if (!$is_course_admin && ($status <> 1 || $sessionStatus == 0) && $selectcat <> 0) {
  230. $catcourse = Category::load($catobj->get_id());
  231. /** @var Category $category */
  232. $category = $catcourse[0];
  233. $main_weight = $category->get_weight();
  234. $scoredisplay = ScoreDisplay :: instance();
  235. $allevals = $category->get_evaluations($userId, true);
  236. $alllinks = $category->get_links($userId, true);
  237. $allEvalsLinks = array_merge($allevals, $alllinks);
  238. $item_value_total = 0;
  239. $scoreinfo = null;
  240. for ($count = 0; $count < count($allEvalsLinks); $count++) {
  241. $item = $allEvalsLinks[$count];
  242. $score = $item->calc_score($userId);
  243. if (!empty($score)) {
  244. $divide = $score[1] == 0 ? 1 : $score[1];
  245. $item_value = $score[0] / $divide * $item->get_weight();
  246. $item_value_total += $item_value;
  247. }
  248. }
  249. $item_total = $main_weight;
  250. $total_score = array($item_value_total, $item_total);
  251. $scorecourse_display = $scoredisplay->display_score($total_score, SCORE_DIV_PERCENT);
  252. if ((!$catobj->get_id() == '0') && (!isset($_GET['studentoverview'])) && (!isset($_GET['search']))) {
  253. $aditionalButtons = null;
  254. if (!empty($certificateLinkInfo)) {
  255. $aditionalButtons .= '<div class="btn-group pull-right">';
  256. $aditionalButtons .= isset($certificateLinkInfo['certificate_link']) ? $certificateLinkInfo['certificate_link'] : '';
  257. $aditionalButtons .= isset($certificateLinkInfo['badge_link']) ? $certificateLinkInfo['badge_link'] : '';
  258. $aditionalButtons .= '</div>';
  259. }
  260. $scoreinfo .= '<strong>' . sprintf(get_lang('TotalX'), $scorecourse_display . $aditionalButtons). '</strong>';
  261. }
  262. Display :: display_normal_message($scoreinfo, false);
  263. }
  264. // show navigation tree and buttons?
  265. if ($showtree == '1' || isset($_GET['studentoverview'])) {
  266. $header = '<div class="actions"><table>';
  267. $header .= '<tr>';
  268. if (!$selectcat == '0') {
  269. $header .= '<td><a href="' . api_get_self() . '?selectcat=' . $catobj->get_parent_id() . '">' .
  270. Display::return_icon('back.png', get_lang('BackTo') . ' ' . get_lang('RootCat'), '', ICON_SIZE_MEDIUM) . '</a></td>';
  271. }
  272. $header .= '<td>' . get_lang('CurrentCategory') . '</td>' .
  273. '<td><form name="selector"><select name="selectcat" onchange="document.selector.submit()">';
  274. $cats = Category :: load();
  275. $tree = $cats[0]->get_tree();
  276. unset($cats);
  277. $line = null;
  278. foreach ($tree as $cat) {
  279. for ($i = 0; $i < $cat[2]; $i++) {
  280. $line .= '&mdash;';
  281. }
  282. $line = isset($line) ? $line : '';
  283. if (isset($_GET['selectcat']) && $_GET['selectcat'] == $cat[0]) {
  284. $header .= '<option selected value=' . $cat[0] . '>' . $line . ' ' . $cat[1] . '</option>';
  285. } else {
  286. $header .= '<option value=' . $cat[0] . '>' . $line . ' ' . $cat[1] . '</option>';
  287. }
  288. $line = '';
  289. }
  290. $header .= '</select></form></td>';
  291. if (!empty($simple_search_form) && $message_resource === false) {
  292. $header .= '<td style="vertical-align: top;">' . $simple_search_form->toHtml() . '</td>';
  293. } else {
  294. $header .= '<td></td>';
  295. }
  296. if ($is_course_admin &&
  297. $message_resource === false &&
  298. isset($_GET['selectcat']) && $_GET['selectcat'] != 0
  299. ) {
  300. } elseif (!(isset($_GET['studentoverview']))) {
  301. } else {
  302. $header .= '<td style="vertical-align: top;"><a href="' . api_get_self() . '?' . api_get_cidreq() . '&studentoverview=&exportpdf=&selectcat=' . $catobj->get_id() . '" target="_blank">
  303. '.Display::return_icon('pdf.png', get_lang('ExportPDF'), [], ICON_SIZE_MEDIUM).'
  304. ' . get_lang('ExportPDF') . '</a>';
  305. }
  306. $header .= '</td></tr>';
  307. $header .= '</table></div>';
  308. }
  309. // for course admin & platform admin add item buttons are added to the header
  310. $actionsLeft = '';
  311. $my_api_cidreq = api_get_cidreq();
  312. if (api_is_allowed_to_edit(null, true)) {
  313. if (empty($grade_model_id) || $grade_model_id == -1) {
  314. $actionsLeft .= '<a href="gradebook_add_cat.php?' . api_get_cidreq() . '&selectcat=' . $catobj->get_id() . '">' .
  315. Display::return_icon('new_folder.png', get_lang('AddGradebook'), array(), ICON_SIZE_MEDIUM) . '</a></td>';
  316. }
  317. if ($selectcat == '0') {
  318. } else {
  319. $my_category = $catobj->shows_all_information_an_category($catobj->get_id());
  320. if ($my_api_cidreq == '') {
  321. $my_api_cidreq = 'cidReq=' . $my_category['course_code'];
  322. }
  323. if ($show_add_link && !$message_resource) {
  324. $actionsLeft .= '<a href="gradebook_add_eval.php?' . $my_api_cidreq . '&selectcat=' . $catobj->get_id() . '" >' .
  325. Display::return_icon('new_evaluation.png', get_lang('NewEvaluation'), '', ICON_SIZE_MEDIUM) . '</a>';
  326. $cats = Category :: load($selectcat);
  327. if ($cats[0]->get_course_code() != null && !$message_resource) {
  328. $actionsLeft .= '<a href="gradebook_add_link.php?' . $my_api_cidreq . '&selectcat=' . $catobj->get_id() . '">' .
  329. Display::return_icon('new_online_evaluation.png', get_lang('MakeLink'), '', ICON_SIZE_MEDIUM) . '</a>';
  330. } else {
  331. $actionsLeft .= '<a href="gradebook_add_link_select_course.php?' . $my_api_cidreq . '&selectcat=' . $catobj->get_id() . '">' .
  332. Display::return_icon('new_online_evaluation.png', get_lang('MakeLink'), '', ICON_SIZE_MEDIUM) . '</a>';
  333. }
  334. }
  335. if (!$message_resource) {
  336. $actionsLeft .= '<a href="gradebook_flatview.php?' . $my_api_cidreq . '&selectcat=' . $catobj->get_id() . '">' .
  337. Display::return_icon('stats.png', get_lang('FlatView'), '', ICON_SIZE_MEDIUM) . '</a>';
  338. if ($my_category['generate_certificates'] == 1) {
  339. $actionsLeft .= Display::url(
  340. Display::return_icon(
  341. 'certificate_list.png',
  342. get_lang('GradebookSeeListOfStudentsCertificates'),
  343. '',
  344. ICON_SIZE_MEDIUM
  345. ),
  346. "gradebook_display_certificate.php?$my_api_cidreq&cat_id=" . $selectcat
  347. );
  348. }
  349. $actionsLeft .= Display::url(
  350. Display::return_icon(
  351. 'user.png',
  352. get_lang('GradebookListOfStudentsReports'),
  353. '',
  354. ICON_SIZE_MEDIUM
  355. ),
  356. "gradebook_display_summary.php?$my_api_cidreq&selectcat=" . $selectcat
  357. );
  358. // Right icons
  359. $actionsRight = '<a href="gradebook_edit_cat.php?editcat=' . $catobj->get_id() . '&amp;cidReq=' . $catobj->get_course_code() . '&id_session='.$catobj->get_session_id(). '">' .
  360. Display::return_icon('edit.png', get_lang('Edit'), '', ICON_SIZE_MEDIUM) . '</a>';
  361. $actionsRight .= '<a href="../document/document.php?curdirpath=/certificates&' . $my_api_cidreq . '&origin=gradebook&selectcat=' . $catobj->get_id() . '">' .
  362. Display::return_icon('certificate.png', get_lang('AttachCertificate'), '', ICON_SIZE_MEDIUM) . '</a>';
  363. if (empty($categories)) {
  364. $actionsRight .= '<a href="gradebook_edit_all.php?id_session=' . api_get_session_id() . '&amp;' . $my_api_cidreq . '&selectcat=' . $catobj->get_id() . '">' .
  365. Display::return_icon('percentage.png', get_lang('EditAllWeights'), '', ICON_SIZE_MEDIUM) . '</a>';
  366. }
  367. $score_display_custom = api_get_setting('gradebook_score_display_custom');
  368. if (api_get_setting('teachers_can_change_score_settings') == 'true' && $score_display_custom['my_display_custom'] == 'true') {
  369. $actionsRight .= '<a href="gradebook_scoring_system.php?' . $my_api_cidreq . '&selectcat=' . $catobj->get_id() . '">' .
  370. Display::return_icon('ranking.png', get_lang('ScoreEdit'), '', ICON_SIZE_MEDIUM) . '</a>';
  371. }
  372. }
  373. }
  374. } elseif (isset($_GET['search'])) {
  375. echo $header = '<b>' . get_lang('SearchResults') . ' :</b>';
  376. }
  377. $isDrhOfCourse = CourseManager::isUserSubscribedInCourseAsDrh(
  378. api_get_user_id(),
  379. api_get_course_info()
  380. );
  381. if ($isDrhOfCourse) {
  382. $$actionsLeft .= '<a href="gradebook_flatview.php?' . $my_api_cidreq . '&selectcat=' . $catobj->get_id() . '">' .
  383. Display::return_icon('stats.png', get_lang('FlatView'), '', ICON_SIZE_MEDIUM) . '</a>';
  384. }
  385. if (api_is_allowed_to_edit(null, true)){
  386. echo $toolbar = Display::toolbarAction('gradebook-actions', array($actionsLeft, $actionsRight));
  387. }
  388. if (api_is_allowed_to_edit(null, true)) {
  389. $weight = intval($catobj->get_weight()) > 0 ? $catobj->get_weight() : 0;
  390. $weight = '<strong>' . get_lang('TotalWeight') . ' : </strong>' . $weight;
  391. $min_certification = (intval($catobj->get_certificate_min_score() > 0) ? $catobj->get_certificate_min_score() : 0);
  392. $min_certification = get_lang('CertificateMinScore') . ' : ' . $min_certification;
  393. $edit_icon = '<a href="gradebook_edit_cat.php?editcat=' . $catobj->get_id() . '&amp;cidReq=' . $catobj->get_course_code() . '&id_session='.$catobj->get_session_id(). '">' .
  394. Display::return_icon('edit.png', get_lang('Edit'), array(), ICON_SIZE_SMALL) . '</a>';
  395. //$msg = Display::tag('h3', $weight.' - '.$min_certification);
  396. $msg = $weight . ' - ' . $min_certification . $edit_icon;
  397. //@todo show description
  398. $description = (($catobj->get_description() == "" || is_null($catobj->get_description())) ? '' : '<strong>' . get_lang('GradebookDescriptionLog') . '</strong>' . ': ' . $catobj->get_description());
  399. Display::display_normal_message($msg, false);
  400. if (!empty($description)) {
  401. echo Display::div($description, array());
  402. }
  403. }
  404. }
  405. /**
  406. * @param Category $catobj
  407. * @param $is_course_admin
  408. * @param $is_platform_admin
  409. * @param $simple_search_form
  410. * @param bool $show_add_qualification
  411. * @param bool $show_add_link
  412. */
  413. public function display_reduce_header_gradebook($catobj, $is_course_admin, $is_platform_admin, $simple_search_form, $show_add_qualification = true, $show_add_link = true)
  414. {
  415. //student
  416. if (!$is_course_admin) {
  417. $user = api_get_user_info(api_get_user_id());
  418. $catcourse = Category :: load($catobj->get_id());
  419. $scoredisplay = ScoreDisplay :: instance();
  420. $scorecourse = $catcourse[0]->calc_score(api_get_user_id());
  421. $scorecourse_display = (isset($scorecourse) ? $scoredisplay->display_score($scorecourse, SCORE_AVERAGE) : get_lang('NoResultsAvailable'));
  422. $cattotal = Category :: load(0);
  423. $scoretotal = $cattotal[0]->calc_score(api_get_user_id());
  424. $scoretotal_display = (isset($scoretotal) ? $scoredisplay->display_score($scoretotal, SCORE_PERCENT) : get_lang('NoResultsAvailable'));
  425. $scoreinfo = get_lang('StatsStudent') . ' :<b> ' . $user['complete_name']. '</b><br />';
  426. if ((!$catobj->get_id() == '0') && (!isset($_GET['studentoverview'])) && (!isset($_GET['search'])))
  427. $scoreinfo.= '<br />' . get_lang('TotalForThisCategory') . ' : <b>' . $scorecourse_display . '</b>';
  428. $scoreinfo.= '<br />' . get_lang('Total') . ' : <b>' . $scoretotal_display . '</b>';
  429. Display :: display_normal_message($scoreinfo, false);
  430. }
  431. // show navigation tree and buttons?
  432. $header = '<div class="actions">';
  433. if ($is_course_admin) {
  434. $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>';
  435. $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>';
  436. } elseif (!(isset($_GET['studentoverview']))) {
  437. $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>';
  438. } else {
  439. $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>';
  440. }
  441. $header.='</div>';
  442. echo $header;
  443. }
  444. /**
  445. * @param int $userid
  446. */
  447. public static function display_header_user($userid, $categoryId)
  448. {
  449. $user_id = $userid;
  450. $user = api_get_user_info($user_id);
  451. $catcourse = Category :: load($categoryId);
  452. $scoredisplay = ScoreDisplay :: instance();
  453. $scorecourse = $catcourse[0]->calc_score($user_id);
  454. // generating the total score for a course
  455. $allevals = $catcourse[0]->get_evaluations($user_id, true);
  456. $alllinks = $catcourse[0]->get_links($user_id, true);
  457. $evals_links = array_merge($allevals, $alllinks);
  458. $item_value = 0;
  459. $item_total = 0;
  460. for ($count = 0; $count < count($evals_links); $count++) {
  461. $item = $evals_links[$count];
  462. $score = $item->calc_score($user_id);
  463. $my_score_denom = ($score[1] == 0) ? 1 : $score[1];
  464. $item_value+=$score[0] / $my_score_denom * $item->get_weight();
  465. $item_total+=$item->get_weight();
  466. }
  467. $item_value = api_number_format($item_value, 2);
  468. $total_score = array($item_value, $item_total);
  469. $scorecourse_display = $scoredisplay->display_score($total_score, SCORE_DIV_PERCENT);
  470. $cattotal = Category :: load(0);
  471. $scoretotal = $cattotal[0]->calc_score($user_id);
  472. $scoretotal_display = (isset($scoretotal) ? $scoredisplay->display_score($scoretotal, SCORE_PERCENT) : get_lang('NoResultsAvailable'));
  473. $imageUrl = UserManager::getUserPicture($userid);
  474. $info = '<div class="row"><div class="col-md-3">';
  475. $info .= '<div class="thumbnail"><img src="' . $imageUrl . '" /></div>';
  476. $info .= '</div>';
  477. $info .= '<div class="col-md-6">';
  478. $info .= get_lang('Name') . ' : <a target="_blank" href="' . api_get_path(WEB_CODE_PATH) . 'social/profile.php?u=' . $userid . '"> ' .
  479. $user['complete_name'] . '</a><br />';
  480. if (api_get_setting('show_email_addresses') == 'true') {
  481. $info .= get_lang('Email') . ' : <a href="mailto:' . $user['email'] . '">' . $user['email'] . '</a><br />';
  482. }
  483. $info .= get_lang('TotalUser') . ' : <b>' . $scorecourse_display . '</b>';
  484. $info .= '</div>';
  485. $info .= '</div>';
  486. echo $info;
  487. }
  488. }