chamilo /
chamilo-lms
| 1 | <?php |
||
| 2 | |||
| 3 | /* For licensing terms, see /license.txt */ |
||
| 4 | |||
| 5 | /** |
||
| 6 | * View (MVC patter) for editing an attendance. |
||
| 7 | * |
||
| 8 | * @author Christian Fasanando <[email protected]> |
||
| 9 | */ |
||
| 10 | api_protect_course_script(true); |
||
| 11 | |||
| 12 | // error messages |
||
| 13 | if (isset($error)) { |
||
| 14 | echo Display::return_message(get_lang('FormHasErrorsPleaseComplete'), 'error', false); |
||
| 15 | } |
||
| 16 | |||
| 17 | if (!isset($error)) { |
||
| 18 | $token = Security::get_token(); |
||
| 19 | } |
||
| 20 | |||
| 21 | $attendance_weight = api_float_val($attendance_weight); |
||
| 22 | |||
| 23 | $form = new FormValidator( |
||
| 24 | 'attendance_edit', |
||
| 25 | 'POST', |
||
| 26 | 'index.php?action=attendance_edit&'.api_get_cidreq().'&attendance_id='.$attendance_id |
||
| 27 | ); |
||
| 28 | $form->addElement('header', '', get_lang('Edit')); |
||
| 29 | $form->addElement('hidden', 'sec_token', $token); |
||
| 30 | $form->addElement('hidden', 'attendance_id', $attendance_id); |
||
| 31 | $form->addText('title', get_lang('Title'), true); |
||
| 32 | $form->applyFilter('title', 'html_filter'); |
||
| 33 | $form->addHtmlEditor( |
||
| 34 | 'description', |
||
| 35 | get_lang('Description'), |
||
| 36 | false, |
||
| 37 | false, |
||
| 38 | [ |
||
| 39 | 'ToolbarSet' => 'Basic', |
||
| 40 | 'Width' => '100%', |
||
| 41 | 'Height' => '200', |
||
| 42 | ] |
||
| 43 | ); |
||
| 44 | |||
| 45 | // Advanced Parameters |
||
| 46 | $skillList = []; |
||
| 47 | if (Gradebook::is_active()) { |
||
| 48 | if (!empty($attendance_qualify_title) || !empty($attendance_weight)) { |
||
| 49 | $form->addButtonAdvancedSettings('id_qualify'); |
||
| 50 | $form->addElement('html', '<div id="id_qualify_options" style="display:block">'); |
||
| 51 | $form->addElement( |
||
| 52 | 'checkbox', |
||
| 53 | 'attendance_qualify_gradebook', |
||
| 54 | '', |
||
| 55 | get_lang('QualifyAttendanceGradebook'), |
||
| 56 | [ |
||
| 57 | 'checked' => 'true', |
||
| 58 | 'onclick' => 'javascript: if(this.checked){document.getElementById(\'options_field\').style.display = \'block\';}else{document.getElementById(\'options_field\').style.display = \'none\';}', |
||
| 59 | ] |
||
| 60 | ); |
||
| 61 | $form->addElement('html', '<div id="options_field" style="display:block">'); |
||
| 62 | } else { |
||
| 63 | $form->addButtonAdvancedSettings('id_qualify'); |
||
| 64 | $form->addElement('html', '<div id="id_qualify_options" style="display:none">'); |
||
| 65 | $form->addElement( |
||
| 66 | 'checkbox', |
||
| 67 | 'attendance_qualify_gradebook', |
||
| 68 | '', |
||
| 69 | get_lang('QualifyAttendanceGradebook'), |
||
| 70 | 'onclick="javascript: if(this.checked){document.getElementById(\'options_field\').style.display = \'block\';}else{document.getElementById(\'options_field\').style.display = \'none\';}"' |
||
| 71 | ); |
||
| 72 | $form->addElement('html', '<div id="options_field" style="display:none">'); |
||
| 73 | } |
||
| 74 | GradebookUtils::load_gradebook_select_in_tool($form); |
||
| 75 | $form->addElement('text', 'attendance_qualify_title', get_lang('TitleColumnGradebook')); |
||
| 76 | $form->applyFilter('attendance_qualify_title', 'html_filter'); |
||
| 77 | $form->addElement( |
||
| 78 | 'text', |
||
| 79 | 'attendance_weight', |
||
| 80 | get_lang('QualifyWeight'), |
||
| 81 | 'value="0.00" Style="width:40px" onfocus="javascript: this.select();"' |
||
| 82 | ); |
||
| 83 | $form->applyFilter('attendance_weight', 'html_filter'); |
||
| 84 | $form->addElement('html', '</div>'); |
||
| 85 | Skill::addSkillsToForm($form, api_get_course_int_id(), api_get_session_id(), ITEM_TYPE_ATTENDANCE, $attendance_id); |
||
| 86 | $form->addElement('html', '</div>'); |
||
| 87 | } |
||
| 88 | $form->addButtonUpdate(get_lang('Save')); |
||
| 89 | |||
| 90 | // set default values |
||
| 91 | $default['title'] = Security::remove_XSS($title); |
||
| 92 | $default['description'] = Security::remove_XSS($description, STUDENT); |
||
| 93 | $default['attendance_qualify_title'] = $attendance_qualify_title; |
||
| 94 | $default['attendance_weight'] = $attendance_weight; |
||
| 95 | |||
| 96 | $linkInfo = GradebookUtils::isResourceInCourseGradebook( |
||
| 97 | api_get_course_id(), |
||
| 98 | 7, |
||
| 99 | $attendance_id, |
||
| 100 | api_get_session_id() |
||
| 101 | ); |
||
| 102 | |||
| 103 | $default['category_id'] = null; |
||
| 104 | if ($linkInfo) { |
||
|
0 ignored issues
–
show
|
|||
| 105 | $default['category_id'] = $linkInfo['category_id']; |
||
| 106 | } |
||
| 107 | |||
| 108 | $form->setDefaults($default); |
||
| 109 | $form->display(); |
||
| 110 |
This check marks implicit conversions of arrays to boolean values in a comparison. While in PHP an empty array is considered to be equal (but not identical) to false, this is not always apparent.
Consider making the comparison explicit by using
empty(..)or! empty(...)instead.