gradebook_edit_eval.php 2.4 KB

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