gradebook_edit_eval.php 2.8 KB

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