gradebook_add_result.php 1.9 KB

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