gradebook_display_certificate.php 4.8 KB

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