gradebook_add_user.php 2.6 KB

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