gradebook_edit_eval.php 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. <?php
  2. /* For licensing terms, see /license.txt */
  3. /**
  4. * Script
  5. * @package chamilo.gradebook
  6. */
  7. //$cidReset = true;
  8. require_once '../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=' . Security::remove_XSS($_GET['editeval'])
  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 = null;
  34. if ($parent_cat[0]->get_parent_id() == 0) {
  35. $final_weight = $values['weight_mask'];
  36. } else {
  37. $cat = Category :: load($parent_cat[0]->get_parent_id());
  38. $global_weight = $cat[0]->get_weight();
  39. $final_weight = $values['weight_mask']/$global_weight*$parent_cat[0]->get_weight();
  40. }*/
  41. $final_weight = $values['weight_mask'];
  42. $eval->set_weight($final_weight);
  43. $eval->set_max($values['max']);
  44. if (empty ($values['visible'])) {
  45. $visible = 0;
  46. } else {
  47. $visible = 1;
  48. }
  49. $eval->set_visible($visible);
  50. $eval->save();
  51. header('Location: '.$_SESSION['gradebook_dest'].'?editeval=&selectcat=' . $eval->get_category_id());
  52. exit;
  53. }
  54. $selectcat_inter=isset($_GET['selectcat'])?Security::remove_XSS($_GET['selectcat']):'';
  55. $interbreadcrumb[] = array (
  56. 'url' => $_SESSION['gradebook_dest'].'?selectcat='.$selectcat_inter,
  57. 'name' => get_lang('Gradebook'
  58. ));
  59. $htmlHeadXtra[] = '<script type="text/javascript">
  60. $(document).ready( 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();