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 __DIR__.'/../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='.intval($_GET['editeval']).'&'.api_get_cidreq()
  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: '.Category::getUrl().'editeval=&selectcat='.$eval->get_category_id());
  43. exit;
  44. }
  45. $selectcat_inter = isset($_GET['selectcat']) ? (int) $_GET['selectcat'] : 0;
  46. $interbreadcrumb[] = array(
  47. 'url' => Category::getUrl().'selectcat='.$selectcat_inter,
  48. 'name' => get_lang('Gradebook')
  49. );
  50. $url = api_get_path(WEB_AJAX_PATH).'gradebook.ajax.php?a=get_gradebook_weight&'.api_get_cidreq();
  51. $htmlHeadXtra[] = '<script>
  52. $(document).ready( function() {
  53. $("#hid_category_id").change(function() {
  54. $("#hid_category_id option:selected").each(function () {
  55. var cat_id = $(this).val();
  56. $.ajax({
  57. url: "'.$url.'",
  58. data: "cat_id="+cat_id,
  59. success: function(return_value) {
  60. if (return_value != 0 ) {
  61. $("#max_weight").html(return_value);
  62. }
  63. }
  64. });
  65. });
  66. });
  67. });
  68. </script>';
  69. Display::display_header(get_lang('EditEvaluation'));
  70. $form->display();
  71. Display::display_footer();