attendance_edit.php 3.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. <?php
  2. /* For licensing terms, see /license.txt */
  3. /**
  4. * View (MVC patter) for editing an attendance
  5. * @author Christian Fasanando <christian1827@gmail.com>
  6. * @package chamilo.attendance
  7. */
  8. // protect a course script
  9. api_protect_course_script(true);
  10. // error messages
  11. if (isset($error)) {
  12. Display::display_error_message(get_lang('FormHasErrorsPleaseComplete'),false);
  13. }
  14. $param_gradebook = '';
  15. if (isset($_SESSION['gradebook'])) {
  16. $param_gradebook = '&gradebook='.Security::remove_XSS($_SESSION['gradebook']);
  17. }
  18. if (!isset($error)) {
  19. $token = Security::get_token();
  20. }
  21. $attendance_weight = floatval($attendance_weight);
  22. // display form
  23. $form = new FormValidator('attendance_edit','POST','index.php?action=attendance_edit&'.api_get_cidreq().'&attendance_id='.$attendance_id.$param_gradebook);
  24. $form->addElement('header', '', get_lang('Edit'));
  25. $form->addElement('hidden', 'sec_token',$token);
  26. $form->addElement('hidden', 'attendance_id', $attendance_id);
  27. $form->addText('title', get_lang('Title'), true, array('size'=>'50'));
  28. $form->applyFilter('title','html_filter');
  29. $form->addHtmlEditor('description', get_lang('Description'), false, false, array('ToolbarSet' => 'TrainingDescription', 'Width' => '100%', 'Height' => '200'));
  30. // Adavanced Parameters
  31. if (Gradebook::is_active()) {
  32. if (!empty($attendance_qualify_title) || !empty($attendance_weight)) {
  33. $form->addButtonAdvancedSettings('id_qualify');
  34. $form->addElement('html','<div id="id_qualify_options" style="display:block">');
  35. $form->addElement('checkbox', 'attendance_qualify_gradebook', '', get_lang('QualifyAttendanceGradebook'),array('checked'=>'true','onclick'=>'javascript: if(this.checked){document.getElementById(\'options_field\').style.display = \'block\';}else{document.getElementById(\'options_field\').style.display = \'none\';}'));
  36. $form->addElement('html','<div id="options_field" style="display:block">');
  37. } else {
  38. $form->addButtonAdvancedSettings('id_qualify');
  39. $form->addElement('html','<div id="id_qualify_options" style="display:none">');
  40. $form->addElement('checkbox', 'attendance_qualify_gradebook', '', get_lang('QualifyAttendanceGradebook'),'onclick="javascript: if(this.checked){document.getElementById(\'options_field\').style.display = \'block\';}else{document.getElementById(\'options_field\').style.display = \'none\';}"');
  41. $form->addElement('html','<div id="options_field" style="display:none">');
  42. }
  43. GradebookUtils::load_gradebook_select_in_tool($form);
  44. $form->addElement('text', 'attendance_qualify_title', get_lang('TitleColumnGradebook'));
  45. $form->applyFilter('attendance_qualify_title', 'html_filter');
  46. $form->addElement('text', 'attendance_weight', get_lang('QualifyWeight'),'value="0.00" Style="width:40px" onfocus="javascript: this.select();"');
  47. $form->applyFilter('attendance_weight', 'html_filter');
  48. $form->addElement('html','</div>');
  49. $form->addElement('html','</div>');
  50. }
  51. $form->addButtonUpdate(get_lang('Save'));
  52. // set default values
  53. $default['title'] = Security::remove_XSS($title);
  54. $default['description'] = Security::remove_XSS($description,STUDENT);
  55. $default['attendance_qualify_title'] = $attendance_qualify_title;
  56. $default['attendance_weight'] = $attendance_weight;
  57. $link_info = GradebookUtils::is_resource_in_course_gradebook(
  58. api_get_course_id(),
  59. 7,
  60. $attendance_id,
  61. api_get_session_id()
  62. );
  63. $default['category_id'] = $link_info['category_id'];
  64. $form->setDefaults($default);
  65. $form->display();