gradebook_add_result.php 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  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. $add_result_form = new EvalForm(EvalForm :: TYPE_RESULT_ADD, $evaluation[0], $resultadd, 'add_result_form', null, api_get_self() . '?selectcat=' . Security::remove_XSS($_GET['selectcat']) . '&selecteval=' . Security::remove_XSS($_GET['selecteval']));
  26. $table = $add_result_form->toHtml();
  27. if ($add_result_form->validate()) {
  28. $values = $add_result_form->exportValues();
  29. $nr_users = $values['nr_users'];
  30. if ($nr_users == '0') {
  31. header('Location: gradebook_view_result.php?addresultnostudents=&selecteval=' . Security::remove_XSS($_GET['selecteval']));
  32. exit;
  33. }
  34. $scores = ($values['score']);
  35. foreach ($scores as $row) {
  36. $res = new Result();
  37. $res->set_evaluation_id($values['evaluation_id']);
  38. $res->set_user_id(key($scores));
  39. //if no scores are given, don't set the score
  40. if ((!empty ($row)) || ($row == '0')) $res->set_score($row);
  41. $res->add();
  42. next($scores);
  43. }
  44. header('Location: gradebook_view_result.php?addresult=&selecteval=' . Security::remove_XSS($_GET['selecteval']));
  45. exit;
  46. }
  47. $interbreadcrumb[] = array ('url' => Security::remove_XSS($_SESSION['gradebook_dest']),'name' => get_lang('Gradebook'));
  48. Display :: display_header(get_lang('AddResult'));
  49. DisplayGradebook :: display_header_result ($evaluation[0], null, 0,0);
  50. echo $table;
  51. Display :: display_footer();