gradebook_edit_result.php 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  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/fe/displaygradebook.php';
  15. require_once 'lib/gradebook_functions.inc.php';
  16. require_once 'lib/fe/evalform.class.php';
  17. require_once 'lib/scoredisplay.class.php';
  18. api_block_anonymous_users();
  19. block_students();
  20. $select_eval=Security::remove_XSS($_GET['selecteval']);
  21. if (empty($select_eval)) {
  22. api_not_allowed();
  23. }
  24. $resultedit = Result :: load (null,null,$select_eval);
  25. $evaluation = Evaluation :: load ($select_eval);
  26. $evaluation[0]->check_lock_permissions();
  27. $edit_result_form = new EvalForm(EvalForm :: TYPE_ALL_RESULTS_EDIT, $evaluation[0], $resultedit, 'edit_result_form', null, api_get_self() . '?&selecteval='.$select_eval);
  28. $table = $edit_result_form->toHtml();
  29. if ($edit_result_form->validate()) {
  30. $values = $edit_result_form->exportValues();
  31. $scores = ($values['score']);
  32. foreach ($scores as $row) {
  33. $resultedit = Result :: load (key($scores));
  34. $row_value = $row;
  35. if ($row_value != '' ) {
  36. $resultedit[0]->set_score(floatval(number_format($row_value, api_get_setting('gradebook_number_decimals'))));
  37. $resultedit[0]->save();
  38. }
  39. next($scores);
  40. }
  41. header('Location: gradebook_view_result.php?selecteval='.$select_eval.'&editallresults=');
  42. exit;
  43. }
  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,
  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();