displaygradebook.php 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415
  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 ($shownavbar == '1' && $status==1) {
  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_format_date($evalobj->get_date(), "%d/%m/%Y %R") . ')<br>' . get_lang('Course') . ' :<b> ' . $course . '</b><br>' . get_lang('Weight') . ' :<b> ' . $evalobj->get_weight() . '</b><br>' . get_lang('Max') . ' :<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_statistics.php?selecteval='.Security::remove_XSS($_GET['selecteval']).'"> '. get_lang('ViewStatistics') . '</a>';
  57. $evalinfo .= '</td><td><img style="float:right; position:relative;" src="../img/tutorial.gif"></img></td></table>';
  58. Display :: display_normal_message($evalinfo,false);
  59. echo $header;
  60. }
  61. /**
  62. * Displays the header for the flatview page containing filters
  63. * @param $catobj
  64. * @param $showeval
  65. * @param $showlink
  66. */
  67. function display_header_flatview($catobj, $showeval, $showlink,$simple_search_form) {
  68. $header= '<table border="0" cellpadding="5">';
  69. $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>';
  70. $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()">';
  71. $cats= Category :: load();
  72. $tree= $cats[0]->get_tree();
  73. unset ($cats);
  74. foreach ($tree as $cat) {
  75. for ($i= 0; $i < $cat[2]; $i++) {
  76. $line .= '&mdash;';
  77. }
  78. if ($_GET['selectcat'] == $cat[0]) {
  79. $header .= '<option selected="selected" value=' . $cat[0] . '>' . $line . ' ' . $cat[1] . '</option>';
  80. } else {
  81. $header .= '<option value=' . $cat[0] . '>' . $line . ' ' . $cat[1] . '</option>';
  82. }
  83. $line= '';
  84. }
  85. $header .= '</td></select></form>';
  86. if (!$catobj->get_id() == '0') {
  87. $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>';
  88. }
  89. $header .= '<td style="vertical-align: top;">'.$simple_search_form->toHtml().'</td>';
  90. $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>';
  91. $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>';
  92. $header .= '</td></tr></table>';
  93. if (!$catobj->get_id() == '0') {
  94. $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;';
  95. $header .= '<input type="checkbox" name="showlink" onclick="document.itemfilter.submit()" ' . (($showlink == '1') ? 'checked' : '') . '>'.get_lang('ShowLinks').'</form></td></tr></table>';
  96. }
  97. if (isset ($_GET['search'])) {
  98. $header .= '<b>'.get_lang('SearchResults').' :</b>';
  99. }
  100. echo $header;
  101. }
  102. /**
  103. * Displays the header for the flatview page containing filters
  104. * @param $catobj
  105. * @param $showeval
  106. * @param $showlink
  107. */
  108. function display_header_reduce_flatview($catobj, $showeval, $showlink,$simple_search_form) {
  109. $header = '<div class="actions">';
  110. $header .= '<a href="'.Security::remove_XSS($_SESSION['gradebook_dest']).'?'.api_get_cidreq().'">'. Display::return_icon('back.png',get_lang('FolderView')) . get_lang('FolderView') . '</a>';
  111. // $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>';
  112. // this MUST be a GET variable not a POST
  113. if (isset($_GET['show'])) {
  114. $show=Security::remove_XSS($_GET['show']);
  115. } else {
  116. $show='';
  117. }
  118. echo '<form id="form1a" name="form1a" method="post" action="'.api_get_self().'?show='.$show.'">';
  119. echo '<input type="hidden" name="export_report" value="export_report">';
  120. echo '<input type="hidden" name="selectcat" value="'.$catobj->get_id() .'">';
  121. echo '<input type="hidden" name="export_format" value="csv">';
  122. echo '</form>';
  123. echo '<form id="form1b" name="form1b" method="post" action="'.api_get_self().'?show='.$show.'">';
  124. echo '<input type="hidden" name="export_report" value="export_report">';
  125. echo '<input type="hidden" name="selectcat" value="'.$catobj->get_id() .'">';
  126. echo '<input type="hidden" name="export_format" value="xls">';
  127. echo '</form>';
  128. $header .= '<a href="javascript: void(0);" onclick="javascript: document.form1a.submit();">'.Display::return_icon('csv.gif', get_lang('ExportAsCSV')).' '.get_lang('ExportAsCSV').'</a>';
  129. $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>';
  130. $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>';
  131. $header .= '<a href="' . api_get_self() . '?exportpdf=&selectcat=' . $catobj->get_id() . '" >'.Display::return_icon('file_pdf.gif', get_lang('ExportToPDF')).' ' . get_lang('ExportToPDF') . '</a>';
  132. //exportpdf
  133. //<div class="clear">
  134. $header .= '</div>';
  135. if (!$catobj->get_id() == '0') {
  136. //this is necessary?
  137. //$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;';
  138. //$header .= '<input type="checkbox" name="showlink" onclick="document.itemfilter.submit()" ' . (($showlink == '1') ? 'checked' : '') . '>'.get_lang('ShowLinks').'</form></td></tr></table>';
  139. }
  140. /*
  141. if (isset ($_GET['search'])) {
  142. $header .= '<b>'.get_lang('SearchResults').' :</b>';
  143. }*/
  144. echo $header;
  145. }
  146. /**
  147. * Displays the header for the gradebook containing the navigation tree and links
  148. * @param category_object $currentcat
  149. * @param int $showtree '1' will show the browse tree and naviation buttons
  150. * @param boolean $is_course_admin
  151. * @param boolean $is_platform_admin
  152. * @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)
  153. * @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)
  154. * @return void Everything is printed on screen upon closing
  155. */
  156. function display_header_gradebook($catobj, $showtree, $selectcat, $is_course_admin, $is_platform_admin, $simple_search_form, $show_add_qualification = true, $show_add_link = true) {
  157. //student
  158. $status=CourseManager::get_user_in_course_status(api_get_user_id(), api_get_course_id());
  159. $objcat=new Category();
  160. //$objdat=new Database();
  161. $course_id=Database::get_course_by_category($selectcat);
  162. $message_resource=$objcat->show_message_resource_delete($course_id);
  163. if (!$is_course_admin && $status<>1 && $selectcat<>0) {
  164. $user_id = api_get_user_id();
  165. $user= get_user_info_from_id($user_id);
  166. $catcourse= Category :: load($catobj->get_id());
  167. $scoredisplay = ScoreDisplay :: instance();
  168. $scorecourse = $catcourse[0]->calc_score($user_id);
  169. // generating the total score for a course
  170. $allevals= $catcourse[0]->get_evaluations($user_id,true);
  171. $alllinks= $catcourse[0]->get_links($user_id,true);
  172. $evals_links = array_merge($allevals, $alllinks);
  173. $item_value=0;
  174. $item_total=0;
  175. for ($count=0; $count < count($evals_links); $count++) {
  176. $item = $evals_links[$count];
  177. $score = $item->calc_score($user_id);
  178. $my_score_denom=($score[1]==0) ? 1 : $score[1];
  179. $item_value+=$score[0]/$my_score_denom*$item->get_weight();
  180. $item_total+=$item->get_weight();
  181. //$row[] = $scoredisplay->display_score($score,SCORE_DIV_PERCENT);
  182. }
  183. $item_value = number_format($item_value, 2, '.', ' ');
  184. $total_score=array($item_value,$item_total);
  185. $scorecourse_display = $scoredisplay->display_score($total_score,SCORE_DIV_PERCENT);
  186. //----------------------
  187. //$scorecourse_display = (isset($scorecourse) ? $scoredisplay->display_score($scorecourse,SCORE_AVERAGE) : get_lang('NoResultsAvailable'));
  188. $cattotal = Category :: load(0);
  189. $scoretotal= $cattotal[0]->calc_score(api_get_user_id());
  190. $scoretotal_display = (isset($scoretotal) ? $scoredisplay->display_score($scoretotal,SCORE_PERCENT) : get_lang('NoResultsAvailable'));
  191. $scoreinfo = get_lang('StatsStudent') . ' :<b> '.api_get_person_name($user['firstname'], $user['lastname']).'</b><br />';
  192. if ((!$catobj->get_id() == '0') && (!isset ($_GET['studentoverview'])) && (!isset ($_GET['search']))) {
  193. $scoreinfo.= '<br />'.get_lang('Total') . ' : <b>' . $scorecourse_display . '</b>';
  194. }
  195. //$scoreinfo.= '<br />'.get_lang('Total') . ' : <b>' . $scoretotal_display . '</b>';
  196. Display :: display_normal_message($scoreinfo,false);
  197. }
  198. // show navigation tree and buttons?
  199. $header='';
  200. $header .= '<div class="actions"><table border=0 >';
  201. if (($showtree == '1') || (isset ($_GET['studentoverview']))) {
  202. $header .= '<tr>';
  203. if (!$selectcat == '0') {
  204. $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>';
  205. }
  206. $header .= '<td style=" ">' . get_lang('CurrentCategory') . '</td>' .
  207. '<td style=" "><form name="selector"><select name="selectcat" onchange="document.selector.submit()">';
  208. $cats= Category :: load();
  209. $tree= $cats[0]->get_tree();
  210. unset ($cats);
  211. foreach ($tree as $cat) {
  212. for ($i= 0; $i < $cat[2]; $i++) {
  213. $line .= '&mdash;';
  214. }
  215. $line=isset($line) ? $line : '';
  216. if (isset($_GET['selectcat']) && $_GET['selectcat'] == $cat[0]) {
  217. $header .= '<option selected value=' . $cat[0] . '>' . $line . ' ' . $cat[1] . '</option>';
  218. } else {
  219. $header .= '<option value=' . $cat[0] . '>' . $line . ' ' . $cat[1] . '</option>';
  220. }
  221. $line= '';
  222. }
  223. $header .= '</select></form></td>';
  224. if (!empty($simple_search_form) && $message_resource===false) {
  225. $header .= '<td style="vertical-align: top;">'.$simple_search_form->toHtml().'</td>';
  226. } else {
  227. $header .= '<td></td>';
  228. }
  229. if ($is_course_admin && $message_resource===false && $_GET['selectcat']!=0) {
  230. /*$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>';
  231. if ($is_course_admin && $message_resource===false) {
  232. $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>';
  233. }*/
  234. } elseif (!(isset ($_GET['studentoverview']))) {
  235. if ( $message_resource===false ) {
  236. //$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>';
  237. }
  238. } else {
  239. $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>';
  240. }
  241. $header .= '</td></tr>';
  242. }
  243. $header.='</table></div>';
  244. // for course admin & platform admin add item buttons are added to the header
  245. $header .= '<div class="actions">';
  246. $my_category=$catobj->shows_all_information_an_category($catobj->get_id());
  247. $user_id=api_get_user_id();
  248. $course_code=$my_category['course_code'];
  249. $status_user=api_get_status_of_user_in_course ($user_id,$course_code);
  250. if (($status_user==1 && $is_course_admin && !isset ($_GET['search'])) || api_is_platform_admin()) {
  251. if ($selectcat == '0') {
  252. if ($show_add_qualification === true) {
  253. // $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>';
  254. }
  255. if ($show_add_link === true) {
  256. //$header .= '<td><a href="gradebook_add_eval.php?'.api_get_cidreq().'"><img src="../img/filenew.gif" alt="' . get_lang('NewEvaluation') . '" /> ' . get_lang('NewEvaluation') . '</a>';
  257. }
  258. } else {
  259. if ($show_add_qualification === true && $message_resource===false) {
  260. //$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>';
  261. }
  262. $my_category=$catobj->shows_all_information_an_category($catobj->get_id());
  263. $my_api_cidreq = api_get_cidreq();
  264. if ($my_api_cidreq=='') {
  265. $my_api_cidreq='cidReq='.$my_category['course_code'];
  266. }
  267. if ($show_add_link === true && $message_resource==false) {
  268. $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;';
  269. $cats= Category :: load($selectcat);
  270. if ($cats[0]->get_course_code() != null && $message_resource===false) {
  271. //$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>';
  272. $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;';
  273. } else {
  274. $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;';
  275. }
  276. }
  277. if ($message_resource===false ) {
  278. $myname=$catobj->shows_all_information_an_category($catobj->get_id());
  279. $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>';
  280. $my_course_id=api_get_course_id();
  281. $my_file= substr($_SESSION['gradebook_dest'],0,5);
  282. if (($my_file!='index' || $status_user==1) || api_is_platform_admin()) {
  283. $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>';
  284. if (/*($is_course_admin && $message_resource===false && $status_user==1) ||*/ api_is_platform_admin()) {
  285. $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>';
  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('acces_tool.gif', 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('acces_tool.gif', get_lang('Certificate')).' ' . get_lang('GradebookSeeListOfStudentsCertificates') . '</a>';
  288. }
  289. }
  290. }
  291. }
  292. } elseif (isset ($_GET['search'])) {
  293. $header .= '<b>'.get_lang('SearchResults').' :</b>';
  294. }
  295. $header .= '</div>';
  296. echo $header;
  297. }
  298. function display_reduce_header_gradebook($catobj,$is_course_admin, $is_platform_admin, $simple_search_form, $show_add_qualification = true, $show_add_link = true) {
  299. //student
  300. if (!$is_course_admin) {
  301. /*$user= get_user_info_from_id(api_get_user_id());
  302. $catcourse= Category :: load($catobj->get_id());
  303. $scoredisplay = ScoreDisplay :: instance();
  304. $scorecourse = $catcourse[0]->calc_score(api_get_user_id());
  305. $scorecourse_display = (isset($scorecourse) ? $scoredisplay->display_score($scorecourse,SCORE_AVERAGE) : get_lang('NoResultsAvailable'));
  306. $cattotal = Category :: load(0);
  307. $scoretotal= $cattotal[0]->calc_score(api_get_user_id());
  308. $scoretotal_display = (isset($scoretotal) ? $scoredisplay->display_score($scoretotal,SCORE_PERCENT) : get_lang('NoResultsAvailable'));
  309. $scoreinfo = get_lang('StatsStudent') . ' :<b> '.api_get_person_name($user['firstname'], $user['lastname']).'</b><br />';
  310. if ((!$catobj->get_id() == '0') && (!isset ($_GET['studentoverview'])) && (!isset ($_GET['search'])))
  311. $scoreinfo.= '<br />'.get_lang('TotalForThisCategory') . ' : <b>' . $scorecourse_display . '</b>';
  312. $scoreinfo.= '<br />'.get_lang('Total') . ' : <b>' . $scoretotal_display . '</b>';
  313. Display :: display_normal_message($scoreinfo,false);
  314. */
  315. }
  316. // show navigation tree and buttons?
  317. $header = '<div class="actions">';
  318. if ($is_course_admin) {
  319. $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>';
  320. if ( api_is_platform_admin() /*$is_platform_admin || $is_course_admin*/)
  321. $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>';
  322. } elseif (!(isset ($_GET['studentoverview']))) {
  323. $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>';
  324. } else {
  325. $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>';
  326. }
  327. $header.='</div>';
  328. echo $header;
  329. }
  330. function display_header_user($userid) {
  331. $select_cat=Security::remove_XSS($_GET['selectcat']);
  332. $user_id = $userid;
  333. $user= get_user_info_from_id($user_id);
  334. $catcourse= Category :: load($select_cat);
  335. $scoredisplay = ScoreDisplay :: instance();
  336. $scorecourse = $catcourse[0]->calc_score($user_id);
  337. // generating the total score for a course
  338. $allevals= $catcourse[0]->get_evaluations($user_id,true);
  339. $alllinks= $catcourse[0]->get_links($user_id,true);
  340. $evals_links = array_merge($allevals, $alllinks);
  341. $item_value=0;
  342. $item_total=0;
  343. for ($count=0; $count < count($evals_links); $count++) {
  344. $item = $evals_links[$count];
  345. $score = $item->calc_score($user_id);
  346. $my_score_denom=($score[1]==0) ? 1 : $score[1];
  347. $item_value+=$score[0]/$my_score_denom*$item->get_weight();
  348. $item_total+=$item->get_weight();
  349. //$row[] = $scoredisplay->display_score($score,SCORE_DIV_PERCENT);
  350. }
  351. $item_value = number_format($item_value, 2, '.', ' ');
  352. $total_score=array($item_value,$item_total);
  353. $scorecourse_display = $scoredisplay->display_score($total_score,SCORE_DIV_PERCENT);
  354. //----------------------
  355. //$scorecourse_display = (isset($scorecourse) ? $scoredisplay->display_score($scorecourse,SCORE_AVERAGE) : get_lang('NoResultsAvailable'));
  356. $cattotal = Category :: load(0);
  357. $scoretotal= $cattotal[0]->calc_score($user_id);
  358. $scoretotal_display = (isset($scoretotal) ? $scoredisplay->display_score($scoretotal,SCORE_PERCENT) : get_lang('NoResultsAvailable'));
  359. //---------------------
  360. $image_syspath = UserManager::get_user_picture_path_by_id($userid,'system',false,true);
  361. $image_size = getimagesize($image_syspath['dir'].$image_syspath['file']);
  362. //Web path
  363. $image_path = UserManager::get_user_picture_path_by_id($userid,'web',false,true);
  364. $image_file = $image_path['dir'].$image_path['file'];
  365. $img_attributes= 'src="' . $image_file . '?rand=' . time() . '" ' . 'alt="' . api_get_person_name($user['firstname'], $user['lastname']) . '" ';
  366. if ($image_size[0] > 200) {
  367. //limit display width to 200px
  368. $img_attributes .= 'width="200" ';
  369. }
  370. $info = '<table width="100%" border=0 cellpadding=5><tr><td width="80%">';
  371. $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>';
  372. $info.= get_lang('Email') . ' : <b><a href="mailto:' . $user['email'] . '">' . $user['email'] . '</a></b><br><br>';
  373. $info.= get_lang('TotalUser') . ' : <b>' . $scorecourse_display . '</b><br>';
  374. $info.= '</td><td>';
  375. $info.= '<img ' . $img_attributes . '/></td></tr></table>';
  376. //--------------
  377. //$scoreinfo = get_lang('StatsStudent') . ' :<b> '.api_get_person_name($user['lastname'], $user['firstname']).'</b><br />';
  378. //$scoreinfo.= '<br />'.get_lang('Total') . ' : <b>' . $scorecourse_display . '</b>';
  379. //$scoreinfo.= '<br />'.get_lang('Total') . ' : <b>' . $scoretotal_display . '</b>';
  380. Display :: display_normal_message($info,false);
  381. }
  382. }