gradebook_display_certificate.php 4.7 KB

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