gradebook_edit_eval.php 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. <?php // $Id: $
  2. /* For licensing terms, see /license.txt */
  3. /**
  4. * Script
  5. * @package chamilo.gradebook
  6. */
  7. /**
  8. * Init
  9. */
  10. $language_file = 'gradebook';
  11. //$cidReset = true;
  12. require_once '../inc/global.inc.php';
  13. require_once 'lib/be.inc.php';
  14. require_once 'lib/gradebook_functions.inc.php';
  15. require_once 'lib/fe/evalform.class.php';
  16. api_block_anonymous_users();
  17. block_students();
  18. $evaledit = Evaluation :: load($_GET['editeval']);
  19. if ($evaledit[0]->is_locked() && !api_is_platform_admin()) {
  20. api_not_allowed();
  21. }
  22. $form = new EvalForm(EvalForm :: TYPE_EDIT, $evaledit[0], null, 'edit_eval_form',null,api_get_self() . '?editeval=' . Security::remove_XSS($_GET['editeval']));
  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();