gradebook_add_user.php 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  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 '../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(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. if ( isset($_POST['submit_button']) ) {
  28. $users= is_array($_POST['add_users']) ? $_POST['add_users'] : array ();
  29. foreach ($users as $key => $value){
  30. $users[$key]= intval($value);
  31. }
  32. if (count($users) == 0) {
  33. header('Location: ' . api_get_self() . '?erroroneuser=&selecteval=' .Security::remove_XSS($_GET['selecteval']));
  34. exit;
  35. } else {
  36. foreach ($users as $user_id) {
  37. $result= new Result();
  38. $result->set_user_id($user_id);
  39. $result->set_evaluation_id($_GET['selecteval']);
  40. $result->add();
  41. }
  42. }
  43. header('Location: gradebook_view_result.php?adduser=&selecteval=' .Security::remove_XSS($_GET['selecteval']).'&'.api_get_cidreq());
  44. exit;
  45. } elseif ($_POST['firstLetterUser']) {
  46. $firstletter= $_POST['firstLetterUser'];
  47. if (!empty ($firstletter)) {
  48. header('Location: ' . api_get_self() . '?firstletter=' . Security::remove_XSS($firstletter) . '&selecteval=' . Security::remove_XSS($_GET['selecteval']));
  49. exit;
  50. }
  51. }
  52. $interbreadcrumb[]= array ('url' => Security::remove_XSS($_SESSION['gradebook_dest']),'name' => get_lang('Gradebook'));
  53. $interbreadcrumb[]= array(
  54. 'url' => 'gradebook_view_result.php?selecteval=' .Security::remove_XSS($_GET['selecteval']).'&'.api_get_cidreq(),
  55. 'name' => get_lang('ViewResult')
  56. );
  57. Display :: display_header(get_lang('AddUserToEval'));
  58. if (isset ($_GET['erroroneuser'])){
  59. Display :: display_warning_message(get_lang('AtLeastOneUser'),false);
  60. }
  61. DisplayGradebook :: display_header_result($evaluation[0], null, 0,0);
  62. echo '<div class="main">';
  63. echo $add_user_form->toHtml();
  64. echo '</div>';
  65. Display :: display_footer();