gradebook_add_user.php 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. <?php
  2. // $Id: gradebook_add_result.php 328 2007-04-04 14:02:48Z stijn $
  3. /*
  4. ==============================================================================
  5. Dokeos - elearning and course management software
  6. Copyright (c) 2006 Dokeos S.A.
  7. Copyright (c) 2006 Ghent University (UGent)
  8. Copyright (c) various contributors
  9. For a full list of contributors, see "credits.txt".
  10. The full license can be read in "license.txt".
  11. This program is free software; you can redistribute it and/or
  12. modify it under the terms of the GNU General Public License
  13. as published by the Free Software Foundation; either version 2
  14. of the License, or (at your option) any later version.
  15. See the GNU General Public License for more details.
  16. Contact address: Dokeos, 44 rue des palais, B-1030 Brussels, Belgium
  17. Mail: info@dokeos.com
  18. ==============================================================================
  19. */
  20. $language_file = 'gradebook';
  21. $cidReset = true;
  22. include_once ('../inc/global.inc.php');
  23. $this_section = SECTION_MYGRADEBOOK;
  24. include_once ('lib/be.inc.php');
  25. include_once ('lib/fe/displaygradebook.php');
  26. include_once ('lib/gradebook_functions.inc.php');
  27. include_once ('lib/fe/evalform.class.php');
  28. include_once ('lib/scoredisplay.class.php');
  29. api_block_anonymous_users();
  30. block_students();
  31. $evaluation= Evaluation :: load($_GET['selecteval']);
  32. $newstudents = $evaluation[0]->get_not_subscribed_students();
  33. if (count($newstudents) == '0')
  34. {
  35. header('Location: gradebook_view_result.php?nouser=&selecteval=' . $_GET['selecteval']);
  36. exit;
  37. }
  38. $add_user_form= new EvalForm(EvalForm :: TYPE_ADD_USERS_TO_EVAL,
  39. $evaluation[0],
  40. null,
  41. 'add_users_to_evaluation',
  42. null,
  43. api_get_self() . '?selecteval=' . $_GET['selecteval'],
  44. $_GET['firstletter'],
  45. $newstudents);
  46. if ($_POST['submit_button'])
  47. {
  48. $users= is_array($_POST['add_users']) ? $_POST['add_users'] : array ();
  49. foreach ($users as $key => $value)
  50. $users[$key]= intval($value);
  51. if (count($users) == 0)
  52. {
  53. header('Location: ' . api_get_self() . '?erroroneuser=&selecteval=' . $_GET['selecteval']);
  54. exit;
  55. }
  56. else
  57. {
  58. foreach ($users as $user_id)
  59. {
  60. $result= new Result();
  61. $result->set_user_id($user_id);
  62. $result->set_evaluation_id($_GET['selecteval']);
  63. $result->set_date(time());
  64. $result->add();
  65. }
  66. }
  67. header('Location: gradebook_view_result.php?adduser=&selecteval=' . $_GET['selecteval']);
  68. exit;
  69. }
  70. elseif ($_POST['firstLetterUser'])
  71. {
  72. $firstletter= $_POST['firstLetterUser'];
  73. if (!empty ($firstletter))
  74. {
  75. header('Location: ' . api_get_self() . '?firstletter=' . $firstletter . '&selecteval=' . $_GET['selecteval']);
  76. exit;
  77. }
  78. }
  79. $interbreadcrumb[]= array (
  80. 'url' => 'gradebook.php',
  81. 'name' => get_lang('Gradebook'
  82. ));
  83. $interbreadcrumb[]= array (
  84. 'url' => 'gradebook_view_result.php?selecteval=' . $_GET['selecteval'],
  85. 'name' => get_lang('ViewResult'
  86. ));
  87. Display :: display_header(get_lang('AddUserToEval'));
  88. if (isset ($_GET['erroroneuser']))
  89. {
  90. Display :: display_warning_message(get_lang('AtLeastOneUser'),false);
  91. }
  92. DisplayGradebook :: display_header_result($evaluation[0], null, 0,0);
  93. echo '<div class="main">';
  94. echo $add_user_form->toHtml();
  95. echo '</div>';
  96. Display :: display_footer();
  97. ?>