gradebook_display_certificate.php 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  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).'usermanager.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' => Security::remove_XSS($_SESSION['gradebook_dest']).'?selectcat='.Security::remove_XSS($_GET['cat_id']),'name' => get_lang('Details'));
  32. $interbreadcrumb[] = array ('url' => 'gradebook_display_certificate.php?cat_id='.Security::remove_XSS($_GET['cat_id']),'name' => get_lang('GradebookListOfStudentsCertificates'));
  33. $this_section = SECTION_COURSES;
  34. Display::display_header('');
  35. 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']))) {
  36. if($_GET['action'] == 'delete') {
  37. $info=delete_certificate($_GET['cat_id'],$_GET['user_id']);
  38. if ($info===true) {
  39. Display::display_confirmation_message(get_lang('CertificateRemoved'));
  40. } else {
  41. Display::display_error_message(get_lang('CertificateNotRemoved'));
  42. }
  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. //$stud_id= (api_is_allowed_to_create_course() ? null : api_get_user_id());
  55. if (api_is_platform_admin()) {
  56. $stud_id= (api_is_allowed_to_create_course() ? null : api_get_user_id());
  57. } else {
  58. $stud_id= api_get_user_id();
  59. }
  60. $total_weight = $cats[0]->get_weight();
  61. $allcat = $cats[0]->get_subcategories($stud_id, api_get_course_id(), api_get_session_id());
  62. $alleval = $cats[0]->get_evaluations($stud_id);
  63. $alllink = $cats[0]->get_links($stud_id);
  64. $datagen = new GradebookDataGenerator ($allcat,$alleval, $alllink);
  65. $total_resource_weight = 0;
  66. if (!empty($datagen)) {
  67. $data_array = $datagen->get_data(GradebookDataGenerator :: GDG_SORT_NAME,0,null,true);
  68. if (!empty($data_array)) {
  69. $newarray = array();
  70. foreach ($data_array as $data) {
  71. $newarray[] = array_slice($data, 1);
  72. }
  73. foreach($newarray as $item) {
  74. $total_resource_weight = $total_resource_weight + $item['2'];
  75. }
  76. }
  77. }
  78. if ($total_resource_weight != $total_weight) {
  79. Display::display_warning_message(get_lang('SumOfActivitiesWeightMustBeEqualToTotalWeight'));
  80. }
  81. }
  82. $certificate_list = get_list_users_certificates($cat_id);
  83. if (count($certificate_list)==0) {
  84. echo Display::display_warning_message(get_lang('NoResultsAvailable'));
  85. } else {
  86. foreach ($certificate_list as $index=>$value) {
  87. ?>
  88. <tr>
  89. <td width="100%" class="actions"><?php echo get_lang('Student').' : '.api_get_person_name($value['firstname'], $value['lastname']) ?>
  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 $index_certificate=>$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. $certificates = Display::url(Display::return_icon('certificate.png', get_lang('Certificates'), array(), 22), $url, array('target'=>'_blank'));
  106. echo $certificates;
  107. ?>
  108. <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>
  109. </td>
  110. </tr>
  111. <?php
  112. }
  113. ?>
  114. </table>
  115. </td>
  116. </tr>
  117. <?php
  118. }
  119. }
  120. ?>
  121. </table>
  122. <?php
  123. Display::display_footer();