gradebook_edit_result.php 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. <?php
  2. /* For licensing terms, see /license.txt */
  3. /**
  4. * Script
  5. * @package chamilo.gradebook
  6. */
  7. api_block_anonymous_users();
  8. GradebookUtils::block_students();
  9. $select_eval=Security::remove_XSS($_GET['selecteval']);
  10. if (empty($select_eval)) {
  11. api_not_allowed();
  12. }
  13. $resultedit = Result :: load (null,null,$select_eval);
  14. $evaluation = Evaluation :: load ($select_eval);
  15. $evaluation[0]->check_lock_permissions();
  16. $edit_result_form = new EvalForm(
  17. EvalForm :: TYPE_ALL_RESULTS_EDIT,
  18. $evaluation[0],
  19. $resultedit,
  20. 'edit_result_form',
  21. null,
  22. api_get_self().'?&selecteval='.$select_eval
  23. );
  24. $table = $edit_result_form->toHtml();
  25. if ($edit_result_form->validate()) {
  26. $values = $edit_result_form->exportValues();
  27. $scores = ($values['score']);
  28. foreach ($scores as $row) {
  29. $resultedit = Result :: load (key($scores));
  30. $row_value = $row;
  31. if ($row_value != '' ) {
  32. $resultedit[0]->set_score(
  33. floatval(
  34. number_format(
  35. $row_value,
  36. api_get_setting('gradebook.gradebook_number_decimals')
  37. )
  38. )
  39. );
  40. $resultedit[0]->save();
  41. }
  42. next($scores);
  43. }
  44. header('Location: gradebook_view_result.php?selecteval='.$select_eval.'&editallresults=&'.api_get_cidreq());
  45. exit;
  46. }
  47. $interbreadcrumb[] = array (
  48. 'url' => $_SESSION['gradebook_dest'],
  49. 'name' => get_lang('Gradebook')
  50. );
  51. $interbreadcrumb[]= array (
  52. 'url' => 'gradebook_view_result.php?selecteval='.$select_eval.'&'.api_get_cidreq(),
  53. 'name' => get_lang('ViewResult')
  54. );
  55. Display :: display_header(get_lang('EditResult'));
  56. DisplayGradebook::display_header_result($evaluation[0], null, 0, 0);
  57. echo $table;
  58. Display :: display_footer();