gradebook_edit_result.php 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. <?php
  2. /* For licensing terms, see /license.txt */
  3. /**
  4. * Script
  5. * @package chamilo.gradebook
  6. */
  7. require_once '../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
  24. );
  25. $table = $edit_result_form->toHtml();
  26. if ($edit_result_form->validate()) {
  27. $values = $edit_result_form->exportValues();
  28. $scores = ($values['score']);
  29. foreach ($scores as $row) {
  30. $resultedit = Result :: load (key($scores));
  31. $row_value = $row;
  32. if ($row_value != '' ) {
  33. $resultedit[0]->set_score(floatval(number_format($row_value, api_get_setting('gradebook_number_decimals'))));
  34. $resultedit[0]->save();
  35. }
  36. next($scores);
  37. }
  38. header('Location: gradebook_view_result.php?selecteval='.$select_eval.'&editallresults=&'.api_get_cidreq());
  39. exit;
  40. }
  41. $interbreadcrumb[] = array (
  42. 'url' => $_SESSION['gradebook_dest'],
  43. 'name' => get_lang('Gradebook')
  44. );
  45. $interbreadcrumb[]= array (
  46. 'url' => 'gradebook_view_result.php?selecteval='.$select_eval.'&'.api_get_cidreq(),
  47. 'name' => get_lang('ViewResult')
  48. );
  49. Display :: display_header(get_lang('EditResult'));
  50. DisplayGradebook::display_header_result($evaluation[0],null,0,0);
  51. echo $table;
  52. Display :: display_footer();