gradebook_edit_eval.php 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  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: '.$_SESSION['gradebook_dest'].'?editeval=&selectcat='.$eval->get_category_id().'&'.api_get_cidreq());
  43. exit;
  44. }
  45. $selectcat_inter = isset($_GET['selectcat']) ? (int) $_GET['selectcat'] : 0;
  46. $interbreadcrumb[] = array(
  47. 'url' => $_SESSION['gradebook_dest'].'?selectcat='.$selectcat_inter,
  48. 'name' => get_lang('Gradebook')
  49. );
  50. $htmlHeadXtra[] = '<script>
  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();