gradebook_add_result.php 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. <?php // $Id: $
  2. /* For licensing terms, see /license.txt */
  3. /**
  4. * Script
  5. * @package chamilo.gradebook
  6. */
  7. /**
  8. * Init
  9. */
  10. $language_file = 'gradebook';
  11. //$cidReset = true;
  12. //require_once '../inc/global.inc.php';
  13. require_once 'lib/be.inc.php';
  14. require_once 'lib/gradebook_functions.inc.php';
  15. require_once 'lib/fe/evalform.class.php';
  16. require_once 'lib/fe/displaygradebook.php';
  17. require_once 'lib/scoredisplay.class.php';
  18. $current_course_tool = TOOL_GRADEBOOK;
  19. api_protect_course_script();
  20. api_block_anonymous_users();
  21. block_students();
  22. $resultadd = new Result();
  23. $resultadd->set_evaluation_id($_GET['selecteval']);
  24. $evaluation = Evaluation :: load($_GET['selecteval']);
  25. $category = !empty($_GET['selectcat']) ? $_GET['selectcat'] : "";
  26. $add_result_form = new EvalForm(EvalForm :: TYPE_RESULT_ADD, $evaluation[0], $resultadd, 'add_result_form', null, api_get_self() . '?selectcat=' . Security::remove_XSS($category) . '&selecteval=' . Security::remove_XSS($_GET['selecteval']));
  27. $table = $add_result_form->toHtml();
  28. if ($add_result_form->validate()) {
  29. $values = $add_result_form->exportValues();
  30. $nr_users = $values['nr_users'];
  31. if ($nr_users == '0') {
  32. header('Location: gradebook_view_result.php?addresultnostudents=&selecteval=' . Security::remove_XSS($_GET['selecteval']));
  33. exit;
  34. }
  35. $scores = ($values['score']);
  36. foreach ($scores as $row) {
  37. $res = new Result();
  38. $res->set_evaluation_id($values['evaluation_id']);
  39. $res->set_user_id(key($scores));
  40. //if no scores are given, don't set the score
  41. if ((!empty ($row)) || ($row == '0')) $res->set_score($row);
  42. $res->add();
  43. next($scores);
  44. }
  45. header('Location: gradebook_view_result.php?addresult=&selecteval=' . Security::remove_XSS($_GET['selecteval']));
  46. exit;
  47. }
  48. $interbreadcrumb[] = array ('url' => Security::remove_XSS($_SESSION['gradebook_dest']),'name' => get_lang('Gradebook'));
  49. Display :: display_header(get_lang('AddResult'));
  50. DisplayGradebook :: display_header_result ($evaluation[0], null, 0,0);
  51. echo $table;
  52. Display :: display_footer();