gradebook_edit_eval.php 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  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. $evaledit = Evaluation :: load($_GET['editeval']);
  11. if ($evaledit[0]->is_locked() && !api_is_platform_admin()) {
  12. api_not_allowed();
  13. }
  14. $form = new EvalForm(
  15. EvalForm :: TYPE_EDIT,
  16. $evaledit[0],
  17. null,
  18. 'edit_eval_form',
  19. null,
  20. api_get_self() . '?editeval=' . Security::remove_XSS($_GET['editeval'])
  21. );
  22. if ($form->validate()) {
  23. $values = $form->exportValues();
  24. $eval = new Evaluation();
  25. $eval->set_id($values['hid_id']);
  26. $eval->set_name($values['name']);
  27. $eval->set_description($values['description']);
  28. $eval->set_user_id($values['hid_user_id']);
  29. $eval->set_course_code($values['hid_course_code']);
  30. $eval->set_category_id($values['hid_category_id']);
  31. $parent_cat = Category :: load($values['hid_category_id']);
  32. $final_weight = $values['weight_mask'];
  33. $eval->set_weight($final_weight);
  34. $eval->set_max($values['max']);
  35. if (empty ($values['visible'])) {
  36. $visible = 0;
  37. } else {
  38. $visible = 1;
  39. }
  40. $eval->set_visible($visible);
  41. $eval->save();
  42. header('Location: '.$_SESSION['gradebook_dest'].'?editeval=&selectcat=' . $eval->get_category_id());
  43. exit;
  44. }
  45. $selectcat_inter=isset($_GET['selectcat'])?Security::remove_XSS($_GET['selectcat']):'';
  46. $interbreadcrumb[] = array (
  47. 'url' => $_SESSION['gradebook_dest'].'?selectcat='.$selectcat_inter,
  48. 'name' => get_lang('Gradebook'
  49. ));
  50. $htmlHeadXtra[] = '<script type="text/javascript">
  51. $(document).ready( function() {
  52. $("#hid_category_id").change(function() {
  53. $("#hid_category_id option:selected").each(function () {
  54. var cat_id = $(this).val();
  55. $.ajax({
  56. url: "'.api_get_path(WEB_AJAX_PATH).'gradebook.ajax.php?a=get_gradebook_weight",
  57. data: "cat_id="+cat_id,
  58. success: function(return_value) {
  59. if (return_value != 0 ) {
  60. $("#max_weight").html(return_value);
  61. }
  62. }
  63. });
  64. });
  65. });
  66. });
  67. </script>';
  68. Display :: display_header(get_lang('EditEvaluation'));
  69. $form->display();
  70. Display :: display_footer();