gradebook_edit_eval.php 2.2 KB

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