gradebook_add_result.php 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. <?php
  2. // $Id: gradebook_add_result.php 905 2007-05-07 14:00:29Z 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. include_once ('lib/be.inc.php');
  24. include_once ('lib/gradebook_functions.inc.php');
  25. include_once ('lib/fe/evalform.class.php');
  26. include_once ('lib/fe/displaygradebook.php');
  27. include_once ('lib/scoredisplay.class.php');
  28. api_block_anonymous_users();
  29. block_students();
  30. $resultadd = new Result();
  31. $resultadd->set_evaluation_id($_GET['selecteval']);
  32. $evaluation = Evaluation :: load($_GET['selecteval']);
  33. $add_result_form = new EvalForm(EvalForm :: TYPE_RESULT_ADD, $evaluation[0], $resultadd, 'add_result_form', null, api_get_self() . '?selectcat=' . $_GET['selectcat'] . '&selecteval=' . $_GET['selecteval']);
  34. if ($add_result_form->validate()) {
  35. $values = $add_result_form->exportValues();
  36. $nr_users = $values['nr_users'];
  37. if ($nr_users == '0') {
  38. header('Location: gradebook_view_result.php?addresultnostudents=&selecteval=' . $_GET['selecteval']);
  39. exit;
  40. }
  41. $scores = ($values['score']);
  42. foreach ($scores as $row) {
  43. $res = new Result();
  44. $res->set_evaluation_id($values['evaluation_id']);
  45. $res->set_user_id(key($scores));
  46. //if no scores are given, don't set the score
  47. if ((!empty ($row)) || ($row == '0')) $res->set_score($row);
  48. $res->add();
  49. next($scores);
  50. }
  51. header('Location: gradebook_view_result.php?addresult=&selecteval=' . $_GET['selecteval']);
  52. exit;
  53. }
  54. $interbreadcrumb[] = array (
  55. 'url' => 'gradebook.php',
  56. 'name' => get_lang('Gradebook'
  57. ));
  58. Display :: display_header(get_lang('AddResult'));
  59. DisplayGradebook :: display_header_result ($evaluation[0], null, 0,0);
  60. echo '<div class="main">';
  61. echo $add_result_form->toHtml();
  62. echo '</div>';
  63. Display :: display_footer();
  64. ?>