gradebook_add_user.php 2.7 KB

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