gradebook_add_user.php 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. <?php
  2. /* For licensing terms, see /license.txt */
  3. /**
  4. * Script
  5. * @package chamilo.gradebook
  6. */
  7. //Disabling code when course code is null (gradebook as a tab) see issue #2705
  8. exit;
  9. require_once __DIR__.'/../inc/global.inc.php';
  10. $this_section = SECTION_MYGRADEBOOK;
  11. api_block_anonymous_users();
  12. GradebookUtils::block_students();
  13. $evaluation = Evaluation :: load($_GET['selecteval']);
  14. $newstudents = $evaluation[0]->get_not_subscribed_students();
  15. if (count($newstudents) == '0') {
  16. header('Location: gradebook_view_result.php?nouser=&selecteval='.Security::remove_XSS($_GET['selecteval']).'&'.api_get_cidreq());
  17. exit;
  18. }
  19. $add_user_form = new EvalForm(
  20. EvalForm :: TYPE_ADD_USERS_TO_EVAL,
  21. $evaluation[0],
  22. null,
  23. 'add_users_to_evaluation',
  24. null,
  25. api_get_self().'?selecteval='.Security::remove_XSS($_GET['selecteval']),
  26. Security::remove_XSS($_GET['firstletter']),
  27. $newstudents
  28. );
  29. if (isset($_POST['submit_button'])) {
  30. $users = is_array($_POST['add_users']) ? $_POST['add_users'] : array();
  31. foreach ($users as $key => $value) {
  32. $users[$key] = intval($value);
  33. }
  34. if (count($users) == 0) {
  35. header('Location: '.api_get_self().'?erroroneuser=&selecteval='.Security::remove_XSS($_GET['selecteval']));
  36. exit;
  37. } else {
  38. foreach ($users as $user_id) {
  39. $result = new Result();
  40. $result->set_user_id($user_id);
  41. $result->set_evaluation_id($_GET['selecteval']);
  42. $result->add();
  43. }
  44. }
  45. header(
  46. 'Location: gradebook_view_result.php?adduser=&selecteval='.Security::remove_XSS($_GET['selecteval']).'&'.api_get_cidreq()
  47. );
  48. exit;
  49. } elseif ($_POST['firstLetterUser']) {
  50. $firstletter = $_POST['firstLetterUser'];
  51. if (!empty ($firstletter)) {
  52. header(
  53. 'Location: '.api_get_self().'?firstletter='.Security::remove_XSS(
  54. $firstletter
  55. ).'&selecteval='.Security::remove_XSS($_GET['selecteval'])
  56. );
  57. exit;
  58. }
  59. }
  60. $interbreadcrumb[] = array('url' => Security::remove_XSS($_SESSION['gradebook_dest']), 'name' => get_lang('Gradebook'));
  61. $interbreadcrumb[] = array(
  62. 'url' => 'gradebook_view_result.php?selecteval='.Security::remove_XSS($_GET['selecteval']).'&'.api_get_cidreq(),
  63. 'name' => get_lang('ViewResult')
  64. );
  65. Display :: display_header(get_lang('AddUserToEval'));
  66. if (isset ($_GET['erroroneuser'])) {
  67. echo Display::return_message(get_lang('AtLeastOneUser'), 'warning', false);
  68. }
  69. DisplayGradebook :: display_header_result($evaluation[0], null, 0, 0);
  70. echo '<div class="main">';
  71. echo $add_user_form->toHtml();
  72. echo '</div>';
  73. Display :: display_footer();