gradebook_add_user.php 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  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. $this_section = SECTION_MYGRADEBOOK;
  10. api_block_anonymous_users();
  11. GradebookUtils::block_students();
  12. $evaluation= Evaluation :: load($_GET['selecteval']);
  13. $newstudents = $evaluation[0]->get_not_subscribed_students();
  14. if (count($newstudents) == '0') {
  15. header('Location: gradebook_view_result.php?nouser=&selecteval=' . Security::remove_XSS($_GET['selecteval']).'&'.api_get_cidreq());
  16. exit;
  17. }
  18. $add_user_form = new EvalForm(
  19. EvalForm :: TYPE_ADD_USERS_TO_EVAL,
  20. $evaluation[0],
  21. null,
  22. 'add_users_to_evaluation',
  23. null,
  24. api_get_self().'?selecteval='.Security::remove_XSS($_GET['selecteval']),
  25. Security::remove_XSS($_GET['firstletter']),
  26. $newstudents
  27. );
  28. if (isset($_POST['submit_button'])) {
  29. $users = is_array($_POST['add_users']) ? $_POST['add_users'] : array();
  30. foreach ($users as $key => $value) {
  31. $users[$key] = intval($value);
  32. }
  33. if (count($users) == 0) {
  34. header('Location: '.api_get_self().'?erroroneuser=&selecteval='.Security::remove_XSS($_GET['selecteval']));
  35. exit;
  36. } else {
  37. foreach ($users as $user_id) {
  38. $result = new Result();
  39. $result->set_user_id($user_id);
  40. $result->set_evaluation_id($_GET['selecteval']);
  41. $result->add();
  42. }
  43. }
  44. header(
  45. 'Location: gradebook_view_result.php?adduser=&selecteval='.Security::remove_XSS($_GET['selecteval']).'&'.api_get_cidreq()
  46. );
  47. exit;
  48. } elseif ($_POST['firstLetterUser']) {
  49. $firstletter = $_POST['firstLetterUser'];
  50. if (!empty ($firstletter)) {
  51. header(
  52. 'Location: '.api_get_self().'?firstletter='.Security::remove_XSS(
  53. $firstletter
  54. ).'&selecteval='.Security::remove_XSS($_GET['selecteval'])
  55. );
  56. exit;
  57. }
  58. }
  59. $interbreadcrumb[]= array ('url' => Security::remove_XSS($_SESSION['gradebook_dest']),'name' => get_lang('Gradebook'));
  60. $interbreadcrumb[]= array(
  61. 'url' => 'gradebook_view_result.php?selecteval=' .Security::remove_XSS($_GET['selecteval']).'&'.api_get_cidreq(),
  62. 'name' => get_lang('ViewResult')
  63. );
  64. Display :: display_header(get_lang('AddUserToEval'));
  65. if (isset ($_GET['erroroneuser'])){
  66. Display :: display_warning_message(get_lang('AtLeastOneUser'),false);
  67. }
  68. DisplayGradebook :: display_header_result($evaluation[0], null, 0,0);
  69. echo '<div class="main">';
  70. echo $add_user_form->toHtml();
  71. echo '</div>';
  72. Display :: display_footer();