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. require_once __DIR__.'/../inc/global.inc.php';
  8. api_block_anonymous_users();
  9. GradebookUtils::block_students();
  10. $select_eval = Security::remove_XSS($_GET['selecteval']);
  11. if (empty($select_eval)) {
  12. api_not_allowed();
  13. }
  14. $resultedit = Result::load(null, null, $select_eval);
  15. $evaluation = Evaluation::load($select_eval);
  16. $evaluation[0]->check_lock_permissions();
  17. $edit_result_form = new EvalForm(
  18. EvalForm :: TYPE_ALL_RESULTS_EDIT,
  19. $evaluation[0],
  20. $resultedit,
  21. 'edit_result_form',
  22. null,
  23. api_get_self().'?selecteval='.$select_eval.'&'.api_get_cidreq()
  24. );
  25. if ($edit_result_form->validate()) {
  26. $values = $edit_result_form->exportValues();
  27. $scores = $values['score'];
  28. foreach ($scores as $userId => $score) {
  29. /** @var array $resultedit */
  30. $resultedit = Result::load($userId);
  31. /** @var Result $result */
  32. $result = $resultedit[0];
  33. if (empty($score)) {
  34. $score = 0;
  35. }
  36. $result->set_score(api_number_format($score, api_get_setting('gradebook_number_decimals')));
  37. $result->save();
  38. }
  39. Display::addFlash(Display::return_message(get_lang('AllResultsEdited')));
  40. header('Location: gradebook_view_result.php?selecteval='.$select_eval.'&'.api_get_cidreq());
  41. exit;
  42. }
  43. $table = $edit_result_form->toHtml();
  44. $interbreadcrumb[] = array(
  45. 'url' => $_SESSION['gradebook_dest'],
  46. 'name' => get_lang('Gradebook')
  47. );
  48. $interbreadcrumb[] = array(
  49. 'url' => 'gradebook_view_result.php?selecteval='.$select_eval.'&'.api_get_cidreq(),
  50. 'name' => get_lang('ViewResult')
  51. );
  52. Display::display_header(get_lang('EditResult'));
  53. DisplayGradebook::display_header_result($evaluation[0], null, 0, 0);
  54. echo $table;
  55. Display :: display_footer();