displaygradebook.php 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414
  1. <?php
  2. /* For licensing terms, see /license.txt */
  3. class DisplayGradebook
  4. {
  5. /**
  6. * Displays the header for the result page containing the navigation tree and links
  7. * @param $evalobj
  8. * @param $selectcat
  9. * @param $shownavbar 1=show navigation bar
  10. * @param $forpdf only output for pdf file
  11. */
  12. function display_header_result($evalobj, $selectcat, $shownavbar) {
  13. $status=CourseManager::get_user_in_course_status(api_get_user_id(), api_get_course_id());
  14. if (api_is_allowed_to_edit(null, true)) {
  15. $header = '<div class="actions">';
  16. $header .= '<a href="'.Security::remove_XSS($_SESSION['gradebook_dest']).'?selectcat=' . $selectcat . '">'. Display::return_icon(('back.png'),get_lang('FolderView')) . get_lang('FolderView') . '</a>';
  17. if ($evalobj->get_course_code() == null) {
  18. $header .= '<a href="gradebook_add_user.php?selecteval=' . $evalobj->get_id() . '"><img src="../img/add_user_big.gif" alt="' . get_lang('AddStudent') . '" align="absmiddle" /> ' . get_lang('AddStudent') . '</a>';
  19. }
  20. elseif (!$evalobj->has_results()) {
  21. $header .= '<a href="gradebook_add_result.php?selectcat=' . $selectcat . '&selecteval=' . $evalobj->get_id() . '"><img src="../img/filenew.gif" alt="' . get_lang('AddResult') . '" align="absmiddle"/> ' . get_lang('AddResult') . '</a>';
  22. }
  23. $header .= '<a href="' . api_get_self() . '?&selecteval=' . $evalobj->get_id() . '&import="><img src="../img/import_data.gif" border="0" alt="" />' . ' ' . get_lang('ImportResult') . '</a>';
  24. if ($evalobj->has_results()) {
  25. $header .= '<a href="' . api_get_self() . '?&selecteval=' . $evalobj->get_id() . '&export="><img src="../img/file_pdf.gif" border="0" alt="" />' . ' ' . get_lang('ExportResult') . '</a>';
  26. $header .= '<a href="gradebook_edit_result.php?selecteval=' . $evalobj->get_id() .'"><img src="../img/edit.gif" alt="' . get_lang('EditResult') . '" align="absmiddle" /> ' . get_lang('EditResult') . '</a>';
  27. $header .= '<a href="' . api_get_self() . '?&selecteval=' . $evalobj->get_id() . '&deleteall=" onclick="return confirmationall();"><img src="../img/delete.gif" border="0" alt="" />' . ' ' . get_lang('DeleteResult') . '</a>';
  28. }
  29. $header .= '<a href="' . api_get_self() . '?print=&selecteval=' . $evalobj->get_id() . '" target="_blank"><img src="../img/printmgr.gif" alt="' . get_lang('Print') . '" /> ' . get_lang('Print') . '</a>';
  30. $header .= '</div>';
  31. }
  32. if ($evalobj->is_visible() == '1') {
  33. $visible= get_lang('Yes');
  34. } else {
  35. $visible= get_lang('No');
  36. }
  37. $scoredisplay = ScoreDisplay :: instance();
  38. if (($evalobj->has_results())){ // TODO this check needed ?
  39. $score= $evalobj->calc_score();
  40. if ($score != null)
  41. $average= get_lang('Average') . ' :<b> ' .$scoredisplay->display_score($score,SCORE_AVERAGE) . '</b>';
  42. }
  43. if (!$evalobj->get_description() == '') {
  44. $description= get_lang('Description') . ' :<b> ' . $evalobj->get_description() . '</b><br>';
  45. }
  46. if ($evalobj->get_course_code() == null) {
  47. $course= get_lang('CourseIndependent');
  48. } else {
  49. $course= get_course_name_from_code($evalobj->get_course_code());
  50. }
  51. $evalinfo= '<table width="100%" border="0"><tr><td>';
  52. $evalinfo .= get_lang('EvaluationName') . ' :<b> ' . $evalobj->get_name() . ' </b>(' . api_convert_and_format_date($evalobj->get_date()).' )<br />' . get_lang('Course') . ' :<b> ' . $course . '</b><br>' . get_lang('Weight') . ' :<b> ' . $evalobj->get_weight() . '</b><br>' . get_lang('QualificationNumeric') . ' :<b> ' . $evalobj->get_max() . '</b><br>' . $description . get_lang('Visible') . ' :<b> ' . $visible . '</b><br>' . $average;
  53. if (!$evalobj->has_results())
  54. $evalinfo .= '<br /><i>' . get_lang('NoResultsInEvaluation') . '</i>';
  55. elseif ($scoredisplay->is_custom() && api_get_self() != '/dokeos/main/gradebook/gradebook_statistics.php')
  56. $evalinfo .= '<br /><br /><a href="gradebook_view_result.php?selecteval='.Security::remove_XSS($_GET['selecteval']).'"> '.Display::return_icon(('gradebook_eval_not_empty.gif'),get_lang('ViewResult')) . '</a>';
  57. $evalinfo .= '<a href="gradebook_statistics.php?selecteval='.Security::remove_XSS($_GET['selecteval']).'"> '.Display::return_icon(('statistics.gif'),get_lang('ViewStatistics')) . '</a>';
  58. $evalinfo .= '</td><td><img style="float:right; position:relative;" src="../img/tutorial.gif"></img></td></table>';
  59. Display :: display_normal_message($evalinfo,false);
  60. echo $header;
  61. }
  62. /**
  63. * Displays the header for the flatview page containing filters
  64. * @param $catobj
  65. * @param $showeval
  66. * @param $showlink
  67. */
  68. function display_header_flatview($catobj, $showeval, $showlink,$simple_search_form) {
  69. $header= '<table border="0" cellpadding="5">';
  70. $header .= '<td style="vertical-align: top;"><a href="'.Security::remove_XSS($_SESSION['gradebook_dest']).'?selectcat=' . Security::remove_XSS($_GET['selectcat']) . '">' . Display::return_icon('gradebook.gif') . get_lang('Gradebook') . '</a></td>';
  71. $header .= '<td style="vertical-align: top;">' . get_lang('FilterCategory') . '</td><td style="vertical-align: top;"><form name="selector"><select name="selectcat" onchange="document.selector.submit()">';
  72. $cats= Category :: load();
  73. $tree= $cats[0]->get_tree();
  74. unset ($cats);
  75. foreach ($tree as $cat) {
  76. for ($i= 0; $i < $cat[2]; $i++) {
  77. $line .= '&mdash;';
  78. }
  79. if ($_GET['selectcat'] == $cat[0]) {
  80. $header .= '<option selected="selected" value=' . $cat[0] . '>' . $line . ' ' . $cat[1] . '</option>';
  81. } else {
  82. $header .= '<option value=' . $cat[0] . '>' . $line . ' ' . $cat[1] . '</option>';
  83. }
  84. $line= '';
  85. }
  86. $header .= '</td></select></form>';
  87. if (!$catobj->get_id() == '0') {
  88. $header .= '<td style="vertical-align: top;"><a href="' . api_get_self() . '?selectcat=' . $catobj->get_parent_id() . '"><img src="../img/gradebook.gif" border="0" alt="'.get_lang('Up').'" /></a></td>';
  89. }
  90. $header .= '<td style="vertical-align: top;">'.$simple_search_form->toHtml().'</td>';
  91. $header .= '<td style="vertical-align: top;"><a href="' . api_get_self() . '?exportpdf=&offset='.Security::remove_XSS($_GET['offset']).'&search=' . Security::remove_XSS($_GET['search']).'&selectcat=' . $catobj->get_id() . '"><img src=../img/file_pdf.gif alt=' . get_lang('ExportPDF') . '/> ' . get_lang('ExportPDF') . '</a>';
  92. $header .= '<td style="vertical-align: top;"><a href="' . api_get_self() . '?print=&selectcat=' . $catobj->get_id() . '" target="_blank"><img src="../img/printmgr.gif" alt=' . get_lang('Print') . '/> ' . get_lang('Print') . '</a>';
  93. $header .= '</td></tr></table>';
  94. if (!$catobj->get_id() == '0') {
  95. $header .= '<table border="0" cellpadding="5"><tr><td><form name="itemfilter" method="post" action="' . api_get_self() . '?selectcat=' . $catobj->get_id() . '"><input type="checkbox" name="showeval" onclick="document.itemfilter.submit()" ' . (($showeval == '1') ? 'checked' : '') . '>Show Evaluations &nbsp;';
  96. $header .= '<input type="checkbox" name="showlink" onclick="document.itemfilter.submit()" ' . (($showlink == '1') ? 'checked' : '') . '>'.get_lang('ShowLinks').'</form></td></tr></table>';
  97. }
  98. if (isset ($_GET['search'])) {
  99. $header .= '<b>'.get_lang('SearchResults').' :</b>';
  100. }
  101. echo $header;
  102. }
  103. /**
  104. * Displays the header for the flatview page containing filters
  105. * @param $catobj
  106. * @param $showeval
  107. * @param $showlink
  108. */
  109. function display_header_reduce_flatview($catobj, $showeval, $showlink,$simple_search_form) {
  110. $header = '<div class="actions">';
  111. $header .= '<a href="'.Security::remove_XSS($_SESSION['gradebook_dest']).'?'.api_get_cidreq().'">'. Display::return_icon('back.png',get_lang('FolderView')) . get_lang('FolderView') . '</a>';
  112. // $header .= '<td style="vertical-align: top;"><a href="' . api_get_self() . '?exportpdf=&offset='.Security::remove_XSS($_GET['offset']).'&search=' . Security::remove_XSS($_GET['search']).'&selectcat=' . $catobj->get_id() . '"><img src=../img/file_pdf.gif alt=' . get_lang('ExportPDF') . '/> ' . get_lang('ExportPDF') . '</a>';
  113. // this MUST be a GET variable not a POST
  114. if (isset($_GET['show'])) {
  115. $show=Security::remove_XSS($_GET['show']);
  116. } else {
  117. $show='';
  118. }
  119. echo '<form id="form1a" name="form1a" method="post" action="'.api_get_self().'?show='.$show.'">';
  120. echo '<input type="hidden" name="export_report" value="export_report">';
  121. echo '<input type="hidden" name="selectcat" value="'.$catobj->get_id() .'">';
  122. echo '<input type="hidden" name="export_format" value="csv">';
  123. echo '</form>';
  124. echo '<form id="form1b" name="form1b" method="post" action="'.api_get_self().'?show='.$show.'">';
  125. echo '<input type="hidden" name="export_report" value="export_report">';
  126. echo '<input type="hidden" name="selectcat" value="'.$catobj->get_id() .'">';
  127. echo '<input type="hidden" name="export_format" value="xls">';
  128. echo '</form>';
  129. $header .= '<a href="javascript: void(0);" onclick="javascript: document.form1a.submit();">'.Display::return_icon('csv.gif', get_lang('ExportAsCSV')).' '.get_lang('ExportAsCSV').'</a>';
  130. $header .= '<span><a " href="javascript: void(0);" onclick="javascript: document.form1b.submit();">'.Display::return_icon('excel.gif', get_lang('ExportAsXLS')).' '.get_lang('ExportAsXLS').'</a></span>';
  131. $header .= '<a href="' . api_get_self() . '?print=&selectcat=' . $catobj->get_id() . '" target="_blank">'.Display::return_icon('printmgr.gif', get_lang('Print')).' ' . get_lang('Print') . '</a>';
  132. $header .= '<a href="' . api_get_self() . '?exportpdf=&selectcat=' . $catobj->get_id() . '" >'.Display::return_icon('file_pdf.gif', get_lang('ExportToPDF')).' ' . get_lang('ExportToPDF') . '</a>';
  133. //exportpdf
  134. //<div class="clear">
  135. $header .= '</div>';
  136. if (!$catobj->get_id() == '0') {
  137. //this is necessary?
  138. //$header .= '<table border="0" cellpadding="5"><tr><td><form name="itemfilter" method="post" action="' . api_get_self() . '?selectcat=' . $catobj->get_id() . '"><input type="checkbox" name="showeval" onclick="document.itemfilter.submit()" ' . (($showeval == '1') ? 'checked' : '') . '>Show Evaluations &nbsp;';
  139. //$header .= '<input type="checkbox" name="showlink" onclick="document.itemfilter.submit()" ' . (($showlink == '1') ? 'checked' : '') . '>'.get_lang('ShowLinks').'</form></td></tr></table>';
  140. }
  141. /*
  142. if (isset ($_GET['search'])) {
  143. $header .= '<b>'.get_lang('SearchResults').' :</b>';
  144. }*/
  145. echo $header;
  146. }
  147. /**
  148. * Displays the header for the gradebook containing the navigation tree and links
  149. * @param category_object $currentcat
  150. * @param int $showtree '1' will show the browse tree and naviation buttons
  151. * @param boolean $is_course_admin
  152. * @param boolean $is_platform_admin
  153. * @param boolean Whether to show or not the link to add a new qualification (we hide it in case of the course-embedded tool where we have only one calification per course or session)
  154. * @param boolean Whether to show or not the link to add a new item inside the qualification (we hide it in case of the course-embedded tool where we have only one calification per course or session)
  155. * @return void Everything is printed on screen upon closing
  156. */
  157. function display_header_gradebook($catobj, $showtree, $selectcat, $is_course_admin, $is_platform_admin, $simple_search_form, $show_add_qualification = true, $show_add_link = true) {
  158. //student
  159. $status=CourseManager::get_user_in_course_status(api_get_user_id(), api_get_course_id());
  160. $objcat=new Category();
  161. //$objdat=new Database();
  162. $course_id=Database::get_course_by_category($selectcat);
  163. $message_resource=$objcat->show_message_resource_delete($course_id);
  164. if (!$is_course_admin && $status<>1 && $selectcat<>0) {
  165. $user_id = api_get_user_id();
  166. $user= get_user_info_from_id($user_id);
  167. $catcourse= Category :: load($catobj->get_id());
  168. $scoredisplay = ScoreDisplay :: instance();
  169. $scorecourse = $catcourse[0]->calc_score($user_id);
  170. // generating the total score for a course
  171. $allevals= $catcourse[0]->get_evaluations($user_id,true);
  172. $alllinks= $catcourse[0]->get_links($user_id,true);
  173. $evals_links = array_merge($allevals, $alllinks);
  174. $item_value=0;
  175. $item_total=0;
  176. for ($count=0; $count < count($evals_links); $count++) {
  177. $item = $evals_links[$count];
  178. $score = $item->calc_score($user_id);
  179. $my_score_denom=($score[1]==0) ? 1 : $score[1];
  180. $item_value+=$score[0]/$my_score_denom*$item->get_weight();
  181. $item_total+=$item->get_weight();
  182. //$row[] = $scoredisplay->display_score($score,SCORE_DIV_PERCENT);
  183. }
  184. $item_value = number_format($item_value, 2, '.', ' ');
  185. $total_score=array($item_value,$item_total);
  186. $scorecourse_display = $scoredisplay->display_score($total_score,SCORE_DIV_PERCENT);
  187. //----------------------
  188. //$scorecourse_display = (isset($scorecourse) ? $scoredisplay->display_score($scorecourse,SCORE_AVERAGE) : get_lang('NoResultsAvailable'));
  189. $cattotal = Category :: load(0);
  190. $scoretotal= $cattotal[0]->calc_score(api_get_user_id());
  191. $scoretotal_display = (isset($scoretotal) ? $scoredisplay->display_score($scoretotal,SCORE_PERCENT) : get_lang('NoResultsAvailable'));
  192. $scoreinfo = get_lang('StatsStudent') . ' :<b> '.api_get_person_name($user['firstname'], $user['lastname']).'</b><br />';
  193. if ((!$catobj->get_id() == '0') && (!isset ($_GET['studentoverview'])) && (!isset ($_GET['search']))) {
  194. $scoreinfo.= '<br />'.get_lang('Total') . ' : <b>' . $scorecourse_display . '</b>';
  195. }
  196. //$scoreinfo.= '<br />'.get_lang('Total') . ' : <b>' . $scoretotal_display . '</b>';
  197. Display :: display_normal_message($scoreinfo,false);
  198. }
  199. // show navigation tree and buttons?
  200. $header='';
  201. $header .= '<div class="actions"><table border=0 >';
  202. if (($showtree == '1') || (isset ($_GET['studentoverview']))) {
  203. $header .= '<tr>';
  204. if (!$selectcat == '0') {
  205. $header .= '<td style=" "><a href="' . api_get_self() . '?selectcat=' . $catobj->get_parent_id() . '">'.Display::return_icon('back.png',get_lang('BackTo').' '.get_lang('RootCat')).get_lang('BackTo').' '.get_lang('RootCat').'</a></td>';
  206. }
  207. $header .= '<td style=" ">' . get_lang('CurrentCategory') . '</td>' .
  208. '<td style=" "><form name="selector"><select name="selectcat" onchange="document.selector.submit()">';
  209. $cats= Category :: load();
  210. $tree= $cats[0]->get_tree();
  211. unset ($cats);
  212. foreach ($tree as $cat) {
  213. for ($i= 0; $i < $cat[2]; $i++) {
  214. $line .= '&mdash;';
  215. }
  216. $line=isset($line) ? $line : '';
  217. if (isset($_GET['selectcat']) && $_GET['selectcat'] == $cat[0]) {
  218. $header .= '<option selected value=' . $cat[0] . '>' . $line . ' ' . $cat[1] . '</option>';
  219. } else {
  220. $header .= '<option value=' . $cat[0] . '>' . $line . ' ' . $cat[1] . '</option>';
  221. }
  222. $line= '';
  223. }
  224. $header .= '</select></form></td>';
  225. if (!empty($simple_search_form) && $message_resource===false) {
  226. $header .= '<td style="vertical-align: top;">'.$simple_search_form->toHtml().'</td>';
  227. } else {
  228. $header .= '<td></td>';
  229. }
  230. if ($is_course_admin && $message_resource===false && $_GET['selectcat']!=0) {
  231. /*$header .= '<td style="vertical-align: top;"><a href="gradebook_flatview.php?'.api_get_cidreq().'&selectcat=' . $catobj->get_id() . '"><img src="../img/view_list.gif" alt="' . get_lang('FlatView') . '" /> ' . get_lang('FlatView') . '</a>';
  232. if ($is_course_admin && $message_resource===false) {
  233. $header .= '<td style="vertical-align: top;"><a href="gradebook_scoring_system.php?'.api_get_cidreq().'&selectcat=' . $catobj->get_id() .'"><img src="../img/acces_tool.gif" alt="' . get_lang('ScoreEdit') . '" /> ' . get_lang('ScoreEdit') . '</a>';
  234. }*/
  235. } elseif (!(isset ($_GET['studentoverview']))) {
  236. if ( $message_resource===false ) {
  237. //$header .= '<td style="vertical-align: top;"><a href="'.api_get_self().'?'.api_get_cidreq().'&studentoverview=&selectcat=' . $catobj->get_id() . '"><img src="../img/view_list.gif" alt="' . get_lang('FlatView') . '" /> ' . get_lang('FlatView') . '</a>';
  238. }
  239. } else {
  240. $header .= '<td style="vertical-align: top;"><a href="'.api_get_self().'?'.api_get_cidreq().'&studentoverview=&exportpdf=&selectcat=' . $catobj->get_id() . '" target="_blank"><img src="../img/file_pdf.gif" alt="' . get_lang('ExportPDF') . '" /> ' . get_lang('ExportPDF') . '</a>';
  241. }
  242. $header .= '</td></tr>';
  243. }
  244. $header.='</table></div>';
  245. // for course admin & platform admin add item buttons are added to the header
  246. $header .= '<div class="actions">';
  247. $my_category=$catobj->shows_all_information_an_category($catobj->get_id());
  248. $user_id=api_get_user_id();
  249. $course_code=$my_category['course_code'];
  250. $status_user=api_get_status_of_user_in_course ($user_id,$course_code);
  251. if (api_is_allowed_to_edit(null, true)) {
  252. if ($selectcat == '0') {
  253. if ($show_add_qualification === true) {
  254. // $header .= '<a href="gradebook_add_cat.php?'.api_get_cidreq().'&selectcat=0"><img src="../img/folder_new.gif" alt="' . get_lang('NewCategory') . '" /> ' . get_lang('NewCategory') . '</a></td>';
  255. }
  256. if ($show_add_link) {
  257. //$header .= '<td><a href="gradebook_add_eval.php?'.api_get_cidreq().'"><img src="../img/filenew.gif" alt="' . get_lang('NewEvaluation') . '" /> ' . get_lang('NewEvaluation') . '</a>';
  258. }
  259. } else {
  260. if ($show_add_qualification === true && $message_resource===false) {
  261. //$header .= '<a href="gradebook_add_cat.php?'.api_get_cidreq().'&selectcat=' . $catobj->get_id() . '" ><img src="../img/folder_new.gif" alt="' . get_lang('NewSubCategory') . '" align="absmiddle" /> ' . get_lang('NewSubCategory') . '</a></td>';
  262. }
  263. $my_category=$catobj->shows_all_information_an_category($catobj->get_id());
  264. $my_api_cidreq = api_get_cidreq();
  265. if ($my_api_cidreq=='') {
  266. $my_api_cidreq='cidReq='.$my_category['course_code'];
  267. }
  268. if ($show_add_link && !$message_resource) {
  269. $header .= '<td><a href="gradebook_add_eval.php?'.$my_api_cidreq.'&selectcat=' . $catobj->get_id() . '" >'.Display::return_icon('filenew.gif', get_lang('NewEvaluation')).' ' . get_lang('NewEvaluation') . '</a>&nbsp;';
  270. $cats= Category :: load($selectcat);
  271. if ($cats[0]->get_course_code() != null && !$message_resource) {
  272. //$header .= '<td><a href="gradebook_add_link.php?'.api_get_cidreq().'&selectcat=' . $catobj->get_id() . '"><img src="../img/link.gif" alt="' . get_lang('MakeLink') . '" align="absmiddle" /> ' . get_lang('MakeLink') . '</a>';
  273. $header .= '<td><a href="gradebook_add_link.php?'.$my_api_cidreq.'&selectcat=' . $catobj->get_id() . '">'.Display::return_icon('link.gif', get_lang('MakeLink')).' ' . get_lang('MakeLink') . '</a>&nbsp;';
  274. } else {
  275. $header .= '<td><a href="gradebook_add_link_select_course.php?'.$my_api_cidreq.'&selectcat=' . $catobj->get_id() . '">'.Display::return_icon('link.gif', get_lang('MakeLink')).' ' . get_lang('MakeLink') . '</a>&nbsp;';
  276. }
  277. }
  278. if (!$message_resource) {
  279. $myname=$catobj->shows_all_information_an_category($catobj->get_id());
  280. $header .= '<td><a href="gradebook_edit_all.php?id_session='.intval($_SESSION['id_session']).'&amp;'.$my_api_cidreq.'&selectcat=' . $catobj->get_id() . '">'.Display::return_icon('statistics.gif', get_lang('EditAllWeights')).' ' . get_lang('EditAllWeights') . '</a>';
  281. $my_course_id=api_get_course_id();
  282. $my_file= substr($_SESSION['gradebook_dest'],0,5);
  283. if (api_is_allowed_to_edit(null, true)) {
  284. $header .= '<td style="vertical-align: top;"><a href="gradebook_scoring_system.php?'.$my_api_cidreq.'&selectcat=' . $catobj->get_id() .'">'.Display::return_icon('acces_tool.gif', get_lang('ScoreEdit')).' ' . get_lang('ScoreEdit') . '</a>';
  285. $header .= '<td style="vertical-align: top;"><a href="gradebook_flatview.php?'.$my_api_cidreq.'&selectcat=' . $catobj->get_id() . '">'.Display::return_icon('stats_access.gif', get_lang('FlatView')).' ' . get_lang('FlatView') . '</a>';
  286. $header .= '<td style="vertical-align: top;"><a href="../document/document.php?curdirpath=/certificates&'.$my_api_cidreq.'&origin=gradebook&selectcat=' . $catobj->get_id() . '">'.Display::return_icon('certificate.png', get_lang('AttachCertificate')).' ' . get_lang('AttachCertificate') . '</a>';
  287. $header .= '<td style="vertical-align: top;"><a href="gradebook_display_certificate.php?'.$my_api_cidreq.'&amp;cat_id='.(int)$_GET['selectcat'].'">'.Display::return_icon('gradebook_eval_not_empty.gif', get_lang('GradebookSeeListOfStudentsCertificates')).' ' . get_lang('GradebookSeeListOfStudentsCertificates') . '</a>';
  288. }
  289. }
  290. }
  291. } elseif (isset ($_GET['search'])) {
  292. $header .= '<b>'.get_lang('SearchResults').' :</b>';
  293. }
  294. $header .= '</div>';
  295. echo $header;
  296. }
  297. function display_reduce_header_gradebook($catobj,$is_course_admin, $is_platform_admin, $simple_search_form, $show_add_qualification = true, $show_add_link = true) {
  298. //student
  299. if (!$is_course_admin) {
  300. $user= get_user_info_from_id(api_get_user_id());
  301. $catcourse= Category :: load($catobj->get_id());
  302. $scoredisplay = ScoreDisplay :: instance();
  303. $scorecourse = $catcourse[0]->calc_score(api_get_user_id());
  304. $scorecourse_display = (isset($scorecourse) ? $scoredisplay->display_score($scorecourse,SCORE_AVERAGE) : get_lang('NoResultsAvailable'));
  305. $cattotal = Category :: load(0);
  306. $scoretotal= $cattotal[0]->calc_score(api_get_user_id());
  307. $scoretotal_display = (isset($scoretotal) ? $scoredisplay->display_score($scoretotal,SCORE_PERCENT) : get_lang('NoResultsAvailable'));
  308. $scoreinfo = get_lang('StatsStudent') . ' :<b> '.api_get_person_name($user['firstname'], $user['lastname']).'</b><br />';
  309. if ((!$catobj->get_id() == '0') && (!isset ($_GET['studentoverview'])) && (!isset ($_GET['search'])))
  310. $scoreinfo.= '<br />'.get_lang('TotalForThisCategory') . ' : <b>' . $scorecourse_display . '</b>';
  311. $scoreinfo.= '<br />'.get_lang('Total') . ' : <b>' . $scoretotal_display . '</b>';
  312. Display :: display_normal_message($scoreinfo,false);
  313. }
  314. // show navigation tree and buttons?
  315. $header = '<div class="actions">';
  316. if ($is_course_admin) {
  317. $header .= '<a href="gradebook_flatview.php?'.api_get_cidreq().'&selectcat=' . $catobj->get_id() . '">'.Display::return_icon('stats_access.gif', get_lang('FlatView')).' '. get_lang('FlatView') . '</a>';
  318. $header .= '<a href="gradebook_scoring_system.php?'.api_get_cidreq().'&selectcat=' . $catobj->get_id() .'">'.Display::return_icon('acces_tool.gif', get_lang('ScoreEdit')).' ' . get_lang('ScoreEdit') . '</a>';
  319. } elseif (!(isset ($_GET['studentoverview']))) {
  320. $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>';
  321. } else {
  322. $header .= '<a href="'.api_get_self().'?'.api_get_cidreq().'&studentoverview=&exportpdf=&selectcat=' . $catobj->get_id() . '" target="_blank">'.Display::return_icon('file_pdf.gif', get_lang('ExportPDF')).' ' . get_lang('ExportPDF') . '</a>';
  323. }
  324. $header.='</div>';
  325. echo $header;
  326. }
  327. function display_header_user($userid) {
  328. $select_cat=Security::remove_XSS($_GET['selectcat']);
  329. $user_id = $userid;
  330. $user= get_user_info_from_id($user_id);
  331. $catcourse= Category :: load($select_cat);
  332. $scoredisplay = ScoreDisplay :: instance();
  333. $scorecourse = $catcourse[0]->calc_score($user_id);
  334. // generating the total score for a course
  335. $allevals= $catcourse[0]->get_evaluations($user_id,true);
  336. $alllinks= $catcourse[0]->get_links($user_id,true);
  337. $evals_links = array_merge($allevals, $alllinks);
  338. $item_value=0;
  339. $item_total=0;
  340. for ($count=0; $count < count($evals_links); $count++) {
  341. $item = $evals_links[$count];
  342. $score = $item->calc_score($user_id);
  343. $my_score_denom=($score[1]==0) ? 1 : $score[1];
  344. $item_value+=$score[0]/$my_score_denom*$item->get_weight();
  345. $item_total+=$item->get_weight();
  346. //$row[] = $scoredisplay->display_score($score,SCORE_DIV_PERCENT);
  347. }
  348. $item_value = number_format($item_value, 2, '.', ' ');
  349. $total_score=array($item_value,$item_total);
  350. $scorecourse_display = $scoredisplay->display_score($total_score,SCORE_DIV_PERCENT);
  351. //----------------------
  352. //$scorecourse_display = (isset($scorecourse) ? $scoredisplay->display_score($scorecourse,SCORE_AVERAGE) : get_lang('NoResultsAvailable'));
  353. $cattotal = Category :: load(0);
  354. $scoretotal= $cattotal[0]->calc_score($user_id);
  355. $scoretotal_display = (isset($scoretotal) ? $scoredisplay->display_score($scoretotal,SCORE_PERCENT) : get_lang('NoResultsAvailable'));
  356. //---------------------
  357. $image_syspath = UserManager::get_user_picture_path_by_id($userid,'system',false,true);
  358. $image_size = getimagesize($image_syspath['dir'].$image_syspath['file']);
  359. //Web path
  360. $image_path = UserManager::get_user_picture_path_by_id($userid,'web',false,true);
  361. $image_file = $image_path['dir'].$image_path['file'];
  362. $img_attributes= 'src="' . $image_file . '?rand=' . time() . '" ' . 'alt="' . api_get_person_name($user['firstname'], $user['lastname']) . '" ';
  363. if ($image_size[0] > 200) {
  364. //limit display width to 200px
  365. $img_attributes .= 'width="200" ';
  366. }
  367. $info = '<table width="100%" border=0 cellpadding=5><tr><td width="80%">';
  368. $info.= get_lang('Name') . ' : <b>' . api_get_person_name($user['firstname'], $user['lastname']) . '</b> ( <a href="user_info.php?userid=' . $userid . '&selectcat=' . Security::remove_XSS($_GET['selectcat']) . '">' . get_lang('MoreInfo') . '...</a> )<br>';
  369. $info.= get_lang('Email') . ' : <b><a href="mailto:' . $user['email'] . '">' . $user['email'] . '</a></b><br><br>';
  370. $info.= get_lang('TotalUser') . ' : <b>' . $scorecourse_display . '</b><br>';
  371. $info.= '</td><td>';
  372. $info.= '<img ' . $img_attributes . '/></td></tr></table>';
  373. //--------------
  374. //$scoreinfo = get_lang('StatsStudent') . ' :<b> '.api_get_person_name($user['lastname'], $user['firstname']).'</b><br />';
  375. //$scoreinfo.= '<br />'.get_lang('Total') . ' : <b>' . $scorecourse_display . '</b>';
  376. //$scoreinfo.= '<br />'.get_lang('Total') . ' : <b>' . $scoretotal_display . '</b>';
  377. Display :: display_normal_message($info,false);
  378. }
  379. }