gradebook_edit_cat.php 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. <?php // $Id:$
  2. /* For licensing terms, see /license.txt */
  3. $language_file = 'gradebook';
  4. //$cidReset = true;
  5. require_once '../inc/global.inc.php';
  6. require_once 'lib/be.inc.php';
  7. require_once 'lib/gradebook_functions.inc.php';
  8. require_once 'lib/fe/catform.class.php';
  9. api_block_anonymous_users();
  10. block_students();
  11. $edit_cat= isset($_GET['editcat']) ? $_GET['editcat'] : '';
  12. $catedit = Category :: load($edit_cat);
  13. $form = new CatForm(CatForm :: TYPE_EDIT, $catedit[0], 'edit_cat_form');
  14. if ($form->validate()) {
  15. $values = $form->exportValues();
  16. $cat = new Category();
  17. $cat->set_id($values['hid_id']);
  18. $cat->set_name($values['name']);
  19. if (empty ($values['course_code'])) {
  20. $cat->set_course_code(null);
  21. }else {
  22. $cat->set_course_code($values['course_code']);
  23. }
  24. $cat->set_description($values['description']);
  25. $cat->set_user_id($values['hid_user_id']);
  26. $cat->set_parent_id($values['hid_parent_id']);
  27. $cat->set_weight($values['weight']);
  28. $cat->set_certificate_min_score($values['certif_min_score']);
  29. if (empty ($values['visible'])) {
  30. $visible = 0;
  31. } else {
  32. $visible = 1;
  33. }
  34. $cat->set_visible($visible);
  35. $cat->save();
  36. header('Location: '.Security::remove_XSS($_SESSION['gradebook_dest']).'?editcat=&selectcat=' . $cat->get_parent_id());
  37. exit;
  38. }
  39. $selectcat = isset($_GET['selectcat']) ? Security::remove_XSS($_GET['selectcat']) : '';
  40. $interbreadcrumb[] = array ('url' => Security::remove_XSS($_SESSION['gradebook_dest']).'?selectcat='.$selectcat,'name' => get_lang('Gradebook'));
  41. $this_section = SECTION_COURSES;
  42. Display :: display_header(get_lang('EditCategory'));
  43. echo '<div class="actions-message">'.get_lang('EditCategory').'</div>';
  44. $form->display();
  45. Display :: display_footer();