gradebook_display_certificate.php 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. <?php
  2. /* For licensing terms, see /license.txt */
  3. $language_file = 'gradebook';
  4. //$cidReset = true;
  5. require_once '../inc/global.inc.php';
  6. require_once 'lib/gradebook_functions.inc.php';
  7. require_once 'lib/be.inc.php';
  8. require_once 'lib/gradebook_data_generator.class.php';
  9. require_once api_get_path(LIBRARY_PATH).'usermanager.lib.php';
  10. //extra javascript functions for in html head:
  11. $htmlHeadXtra[] =
  12. "<script language='javascript' type='text/javascript'>
  13. function confirmation() {
  14. if (confirm(\" ".trim(get_lang('AreYouSureToDelete'))." ?\"))
  15. {return true;}
  16. else
  17. {return false;}
  18. }
  19. </script>";
  20. api_block_anonymous_users();
  21. if (!api_is_allowed_to_edit()) {
  22. api_not_allowed(true);
  23. }
  24. $interbreadcrumb[] = array ('url' => Security::remove_XSS($_SESSION['gradebook_dest']).'?', 'name' => get_lang('Gradebook'));
  25. $interbreadcrumb[] = array ('url' => Security::remove_XSS($_SESSION['gradebook_dest']).'?selectcat='.Security::remove_XSS($_GET['cat_id']),'name' => get_lang('Details'));
  26. $interbreadcrumb[] = array ('url' => 'gradebook_display_certificate.php?cat_id='.Security::remove_XSS($_GET['cat_id']),'name' => get_lang('GradebookListOfStudentsCertificates'));
  27. $this_section = SECTION_COURSES;
  28. Display::display_header('');
  29. if (isset($_GET['user_id']) && $_GET['user_id']==strval(intval($_GET['user_id'])) && isset($_GET['cat_id']) && $_GET['cat_id']==strval(intval($_GET['cat_id']))) {
  30. if($_GET['action'] == 'delete') {
  31. $info=delete_certificate($_GET['cat_id'],$_GET['user_id']);
  32. if ($info===true) {
  33. Display::display_confirmation_message(get_lang('CertificateRemoved'));
  34. } else {
  35. Display::display_error_message(get_lang('CertificateNotRemoved'));
  36. }
  37. }
  38. }
  39. echo Display::tag('h3', get_lang('GradebookListOfStudentsCertificates'));
  40. ?>
  41. <table class="data_table" border="0" width="100%" >
  42. <?php
  43. $cat_id=isset($_GET['cat_id']) ? (int)$_GET['cat_id'] : null;
  44. //@todo replace all this code with something like get_total_weight()
  45. $cats = Category :: load ($cat_id, null, null, null, null, null, false);
  46. if (!empty($cats)) {
  47. //with this fix the teacher only can view 1 gradebook
  48. //$stud_id= (api_is_allowed_to_create_course() ? null : api_get_user_id());
  49. if (api_is_platform_admin()) {
  50. $stud_id= (api_is_allowed_to_create_course() ? null : api_get_user_id());
  51. } else {
  52. $stud_id= api_get_user_id();
  53. }
  54. $total_weight = $cats[0]->get_weight();
  55. $allcat = $cats[0]->get_subcategories($stud_id, $course_code, $session_id);
  56. $alleval = $cats[0]->get_evaluations($stud_id);
  57. $alllink = $cats[0]->get_links($stud_id);
  58. $datagen = new GradebookDataGenerator ($allcat,$alleval, $alllink);
  59. $total_resource_weight = 0;
  60. if (!empty($datagen)) {
  61. $data_array = $datagen->get_data(GradebookDataGenerator :: GDG_SORT_NAME,0,null,true);
  62. if (!empty($data_array)) {
  63. $newarray = array();
  64. foreach ($data_array as $data) {
  65. $newarray[] = array_slice($data, 1);
  66. }
  67. foreach($newarray as $item) {
  68. $total_resource_weight = $total_resource_weight + $item['2'];
  69. }
  70. }
  71. }
  72. if ($total_resource_weight != $total_weight) {
  73. Display::display_warning_message(get_lang('SumOfActivitiesWeightMustBeEqualToTotalWeight'));
  74. }
  75. }
  76. $certificate_list = get_list_users_certificates($cat_id);
  77. if (count($certificate_list)==0) {
  78. echo get_lang('NoResultsAvailable');
  79. } else {
  80. foreach ($certificate_list as $index=>$value) {
  81. ?>
  82. <tr>
  83. <td width="100%" class="actions"><?php echo get_lang('Student').' : '.api_get_person_name($value['firstname'], $value['lastname']) ?>
  84. </td>
  85. </tr>
  86. <tr>
  87. <td>
  88. <table class="data_table" width="100%" >
  89. <?php
  90. $list_certificate = get_list_gradebook_certificates_by_user_id ($value['user_id'],$cat_id);
  91. foreach ($list_certificate as $index_certificate=>$value_certificate) {
  92. ?>
  93. <tr >
  94. <td width="50%"><?php echo get_lang('Score').' : '.$value_certificate['score_certificate'] ?></td>
  95. <td width="30%"><?php echo get_lang('Date').' : '.api_convert_and_format_date($value_certificate['created_at']) ?></td>
  96. <td width="20%">
  97. <?php
  98. $url = "index.php?export_certificate=yes&cat_id=".$cat_id."&user=".$value['user_id'];
  99. $certificates = Display::url(Display::return_icon('certificate.png', get_lang('Certificates'), array(), 22), $url, array('target'=>'_blank'));
  100. echo $certificates;
  101. ?>
  102. <a onclick="return confirmation();" href="gradebook_display_certificate.php?action=delete&<?php echo 'user_id='.$value_certificate['user_id'].'&amp;cat_id='.$value_certificate['cat_id'] ?>"><?php echo Display::return_icon('delete.png',get_lang('Delete')); ?></a>
  103. </td>
  104. </tr>
  105. <?php
  106. }
  107. ?>
  108. </table>
  109. </td>
  110. </tr>
  111. <?php
  112. }
  113. }
  114. ?>
  115. </table>
  116. <?php
  117. Display::display_footer();