chamilo /
chamilo-lms
| 1 | <?php |
||
| 2 | |||
| 3 | /* For licensing terms, see /license.txt */ |
||
| 4 | |||
| 5 | use ChamiloSession as Session; |
||
| 6 | |||
| 7 | /** |
||
| 8 | * Script allowing simple edition of learnpath information (title, description, etc). |
||
| 9 | * |
||
| 10 | * @author Yannick Warnier <[email protected]> |
||
| 11 | */ |
||
| 12 | require_once api_get_path(LIBRARY_PATH).'specific_fields_manager.lib.php'; |
||
| 13 | |||
| 14 | api_protect_course_script(); |
||
| 15 | |||
| 16 | /** @var learnpath $learnPath */ |
||
| 17 | $learnPath = Session::read('oLP'); |
||
| 18 | |||
| 19 | $nameTools = get_lang('Doc'); |
||
| 20 | $this_section = SECTION_COURSES; |
||
| 21 | Event::event_access_tool(TOOL_LEARNPATH); |
||
|
0 ignored issues
–
show
|
|||
| 22 | |||
| 23 | $lpId = $learnPath->get_id(); |
||
| 24 | |||
| 25 | if (api_is_in_gradebook()) { |
||
| 26 | $interbreadcrumb[] = [ |
||
| 27 | 'url' => Category::getUrl(), |
||
| 28 | 'name' => get_lang('ToolGradebook'), |
||
| 29 | ]; |
||
| 30 | } |
||
| 31 | $interbreadcrumb[] = [ |
||
| 32 | 'url' => 'lp_controller.php?action=list&'.api_get_cidreq(), |
||
| 33 | 'name' => get_lang('LearningPaths'), |
||
| 34 | ]; |
||
| 35 | $interbreadcrumb[] = [ |
||
| 36 | 'url' => api_get_self()."?action=build&lp_id=".$lpId.'&'.api_get_cidreq(), |
||
| 37 | 'name' => $learnPath->getNameNoTags(), |
||
| 38 | ]; |
||
| 39 | |||
| 40 | $htmlHeadXtra[] = '<script> |
||
| 41 | function activate_start_date() { |
||
| 42 | if(document.getElementById(\'start_date_div\').style.display == \'none\') { |
||
| 43 | document.getElementById(\'start_date_div\').style.display = \'block\'; |
||
| 44 | } else { |
||
| 45 | document.getElementById(\'start_date_div\').style.display = \'none\'; |
||
| 46 | } |
||
| 47 | } |
||
| 48 | |||
| 49 | function activate_end_date() { |
||
| 50 | if(document.getElementById(\'end_date_div\').style.display == \'none\') { |
||
| 51 | document.getElementById(\'end_date_div\').style.display = \'block\'; |
||
| 52 | } else { |
||
| 53 | document.getElementById(\'end_date_div\').style.display = \'none\'; |
||
| 54 | } |
||
| 55 | } |
||
| 56 | |||
| 57 | </script>'; |
||
| 58 | |||
| 59 | $defaults = []; |
||
| 60 | $form = new FormValidator( |
||
| 61 | 'form1', |
||
| 62 | 'post', |
||
| 63 | 'lp_controller.php?'.api_get_cidreq() |
||
| 64 | ); |
||
| 65 | |||
| 66 | // Form title |
||
| 67 | $form->addElement('header', get_lang('Edit')); |
||
| 68 | |||
| 69 | // Title |
||
| 70 | if (api_get_configuration_value('save_titles_as_html')) { |
||
| 71 | $form->addHtmlEditor( |
||
| 72 | 'lp_name', |
||
| 73 | get_lang('LPName'), |
||
| 74 | true, |
||
| 75 | false, |
||
| 76 | ['ToolbarSet' => 'TitleAsHtml'] |
||
| 77 | ); |
||
| 78 | } else { |
||
| 79 | $form->addElement('text', 'lp_name', api_ucfirst(get_lang('LearnpathTitle')), ['size' => 43]); |
||
| 80 | } |
||
| 81 | $form->applyFilter('lp_name', 'html_filter'); |
||
| 82 | $form->addRule('lp_name', get_lang('ThisFieldIsRequired'), 'required'); |
||
| 83 | $form->addElement('hidden', 'lp_encoding'); |
||
| 84 | $items = learnpath::getCategoryFromCourseIntoSelect(api_get_course_int_id(), true); |
||
| 85 | $form->addElement('select', 'category_id', get_lang('Category'), $items); |
||
| 86 | |||
| 87 | // Hide toc frame |
||
| 88 | $form->addElement( |
||
| 89 | 'checkbox', |
||
| 90 | 'hide_toc_frame', |
||
| 91 | null, |
||
| 92 | get_lang('HideTocFrame') |
||
| 93 | ); |
||
| 94 | |||
| 95 | if (api_get_setting('allow_course_theme') === 'true') { |
||
| 96 | $mycourselptheme = api_get_course_setting('allow_learning_path_theme'); |
||
| 97 | if (!empty($mycourselptheme) && $mycourselptheme != -1 && $mycourselptheme == 1) { |
||
| 98 | //LP theme picker |
||
| 99 | $theme_select = $form->addElement('SelectTheme', 'lp_theme', get_lang('Theme')); |
||
| 100 | $form->applyFilter('lp_theme', 'trim'); |
||
| 101 | $s_theme = $learnPath->get_theme(); |
||
| 102 | $theme_select->setSelected($s_theme); //default |
||
| 103 | } |
||
| 104 | } |
||
| 105 | |||
| 106 | // Author |
||
| 107 | $form->addHtmlEditor( |
||
| 108 | 'lp_author', |
||
| 109 | get_lang('Author'), |
||
| 110 | false, |
||
| 111 | false, |
||
| 112 | ['ToolbarSet' => 'LearningPathAuthor', 'Width' => '100%', 'Height' => '200px'] |
||
| 113 | ); |
||
| 114 | $form->applyFilter('lp_author', 'html_filter'); |
||
| 115 | |||
| 116 | // LP image |
||
| 117 | if (strlen($learnPath->get_preview_image()) > 0) { |
||
| 118 | $show_preview_image = '<img src='.api_get_path(WEB_COURSE_PATH).api_get_course_path() |
||
| 119 | .'/upload/learning_path/images/'.$learnPath->get_preview_image().'>'; |
||
| 120 | $form->addElement('label', get_lang('ImagePreview'), $show_preview_image); |
||
| 121 | $form->addElement('checkbox', 'remove_picture', null, get_lang('DelImage')); |
||
| 122 | } |
||
| 123 | $label = $learnPath->get_preview_image() != '' ? get_lang('UpdateImage') : get_lang('AddImage'); |
||
| 124 | $form->addElement('file', 'lp_preview_image', [$label, get_lang('ImageWillResizeMsg')]); |
||
| 125 | $form->addRule('lp_preview_image', get_lang('OnlyImagesAllowed'), 'filetype', ['jpg', 'jpeg', 'png', 'gif']); |
||
| 126 | |||
| 127 | // Search terms (only if search is activated). |
||
| 128 | if (api_get_setting('search_enabled') === 'true') { |
||
| 129 | $specific_fields = get_specific_field_list(); |
||
| 130 | foreach ($specific_fields as $specific_field) { |
||
| 131 | $form->addElement('text', $specific_field['code'], $specific_field['name']); |
||
| 132 | $filter = [ |
||
| 133 | 'c_id' => "'".api_get_course_int_id()."'", |
||
| 134 | 'field_id' => $specific_field['id'], |
||
| 135 | 'ref_id' => $learnPath->lp_id, |
||
| 136 | 'tool_id' => '\''.TOOL_LEARNPATH.'\'', |
||
| 137 | ]; |
||
| 138 | $values = get_specific_field_values_list($filter, ['value']); |
||
| 139 | if (!empty($values)) { |
||
| 140 | $arr_str_values = []; |
||
| 141 | foreach ($values as $value) { |
||
| 142 | $arr_str_values[] = $value['value']; |
||
| 143 | } |
||
| 144 | $defaults[$specific_field['code']] = implode(', ', $arr_str_values); |
||
| 145 | } |
||
| 146 | } |
||
| 147 | } |
||
| 148 | |||
| 149 | $hideTableOfContents = $learnPath->getHideTableOfContents(); |
||
| 150 | $defaults['lp_encoding'] = Security::remove_XSS($learnPath->encoding); |
||
| 151 | $defaults['lp_name'] = Security::remove_XSS($learnPath->get_name()); |
||
| 152 | $defaults['lp_author'] = Security::remove_XSS($learnPath->get_author()); |
||
| 153 | $defaults['hide_toc_frame'] = $hideTableOfContents; |
||
| 154 | $defaults['category_id'] = $learnPath->getCategoryId(); |
||
| 155 | $defaults['accumulate_scorm_time'] = $learnPath->getAccumulateScormTime(); |
||
| 156 | |||
| 157 | $expired_on = $learnPath->expired_on; |
||
| 158 | $publicated_on = $learnPath->publicated_on; |
||
| 159 | |||
| 160 | // Prerequisites |
||
| 161 | $form->addElement('html', '<div class="form-group">'); |
||
| 162 | $items = $learnPath->display_lp_prerequisites_list(); |
||
| 163 | $form->addElement('html', '<label class="col-md-2">'.get_lang('LearnpathPrerequisites').'</label>'); |
||
| 164 | $form->addElement('html', '<div class="col-md-8">'); |
||
| 165 | $form->addElement('html', $items); |
||
| 166 | $form->addElement('html', '<div class="help-block">'.get_lang('LpPrerequisiteDescription').'</div>'); |
||
| 167 | $form->addElement('html', '</div>'); |
||
| 168 | $form->addElement('html', '<div class="col-md-2"></div>'); |
||
| 169 | $form->addElement('html', '</div>'); |
||
| 170 | // Time Control |
||
| 171 | if (Tracking::minimumTimeAvailable(api_get_session_id(), api_get_course_int_id())) { |
||
| 172 | $accumulateTime = $_SESSION['oLP']->getAccumulateWorkTime(); |
||
| 173 | $form->addText('accumulate_work_time', [get_lang('LpMinTime'), get_lang('LpMinTimeDescription')]); |
||
| 174 | $defaults['accumulate_work_time'] = $accumulateTime; |
||
| 175 | } |
||
| 176 | |||
| 177 | // Start date |
||
| 178 | $form->addElement( |
||
| 179 | 'checkbox', |
||
| 180 | 'activate_start_date_check', |
||
| 181 | null, |
||
| 182 | get_lang('EnableStartTime'), |
||
| 183 | ['onclick' => 'activate_start_date()'] |
||
| 184 | ); |
||
| 185 | |||
| 186 | $display_date = 'none'; |
||
| 187 | if (!empty($publicated_on) && $publicated_on !== '0000-00-00 00:00:00') { |
||
| 188 | $display_date = 'block'; |
||
| 189 | $defaults['activate_start_date_check'] = 1; |
||
| 190 | } |
||
| 191 | |||
| 192 | $form->addElement('html', '<div id="start_date_div" style="display:'.$display_date.';">'); |
||
| 193 | $form->addDateTimePicker('publicated_on', get_lang('PublicationDate')); |
||
| 194 | $form->addElement('html', '</div>'); |
||
| 195 | |||
| 196 | //End date |
||
| 197 | $form->addElement( |
||
| 198 | 'checkbox', |
||
| 199 | 'activate_end_date_check', |
||
| 200 | null, |
||
| 201 | get_lang('EnableEndTime'), |
||
| 202 | ['onclick' => 'activate_end_date()'] |
||
| 203 | ); |
||
| 204 | $display_date = 'none'; |
||
| 205 | if (!empty($expired_on)) { |
||
| 206 | $display_date = 'block'; |
||
| 207 | $defaults['activate_end_date_check'] = 1; |
||
| 208 | } |
||
| 209 | |||
| 210 | $form->addElement('html', '<div id="end_date_div" style="display:'.$display_date.';">'); |
||
| 211 | $form->addDateTimePicker('expired_on', get_lang('ExpirationDate')); |
||
| 212 | $form->addElement('html', '</div>'); |
||
| 213 | |||
| 214 | if (api_is_platform_admin()) { |
||
| 215 | $form->addElement('checkbox', 'use_max_score', null, get_lang('UseMaxScore100')); |
||
| 216 | $defaults['use_max_score'] = $learnPath->use_max_score; |
||
| 217 | } |
||
| 218 | |||
| 219 | $subscriptionSettings = learnpath::getSubscriptionSettings(); |
||
| 220 | if ($subscriptionSettings['allow_add_users_to_lp']) { |
||
| 221 | $form->addElement( |
||
| 222 | 'checkbox', |
||
| 223 | 'subscribe_users', |
||
| 224 | null, |
||
| 225 | get_lang('SubscribeUsersToLp') |
||
| 226 | ); |
||
| 227 | } |
||
| 228 | |||
| 229 | // accumulate_scorm_time |
||
| 230 | $form->addElement( |
||
| 231 | 'checkbox', |
||
| 232 | 'accumulate_scorm_time', |
||
| 233 | [null, get_lang('AccumulateScormTimeInfo')], |
||
| 234 | get_lang('AccumulateScormTime') |
||
| 235 | ); |
||
| 236 | |||
| 237 | $scoreAsProgressSetting = api_get_configuration_value('lp_score_as_progress_enable'); |
||
| 238 | $countItems = $learnPath->get_total_items_count(); |
||
| 239 | $lpType = $learnPath->get_type(); |
||
| 240 | // This option is only usable for SCORM, if there is only 1 item, otherwise |
||
| 241 | // using the score as progress would not work anymore (we would have to divide |
||
| 242 | // between the two without knowing if the second has any score at all) |
||
| 243 | // TODO: automatically cancel this setting if items >= 2 |
||
| 244 | if ($scoreAsProgressSetting && $countItems < 2 && $lpType == 2) { |
||
| 245 | $scoreAsProgress = $learnPath->getUseScoreAsProgress(); |
||
| 246 | $form->addElement( |
||
| 247 | 'checkbox', |
||
| 248 | 'extra_use_score_as_progress', |
||
| 249 | [null, get_lang('LearnpathUseScoreAsProgressComment')], |
||
| 250 | get_lang('LearnpathUseScoreAsProgress') |
||
| 251 | ); |
||
| 252 | $defaults['extra_use_score_as_progress'] = $scoreAsProgress; |
||
| 253 | } |
||
| 254 | |||
| 255 | $options = learnpath::getIconSelect(); |
||
| 256 | |||
| 257 | if (!empty($options)) { |
||
| 258 | $form->addSelect( |
||
| 259 | 'extra_lp_icon', |
||
| 260 | get_lang('Icon'), |
||
| 261 | $options |
||
| 262 | ); |
||
| 263 | $defaults['extra_lp_icon'] = learnpath::getSelectedIcon($lpId); |
||
| 264 | } |
||
| 265 | |||
| 266 | $extraField = new ExtraField('lp'); |
||
| 267 | $extra = $extraField->addElements( |
||
| 268 | $form, |
||
| 269 | $lpId, |
||
| 270 | ['lp_icon', 'use_score_as_progress'] |
||
| 271 | ); |
||
| 272 | |||
| 273 | if ($form->hasElement('extra_authors')) { |
||
| 274 | /** @var HTML_QuickForm_select $author */ |
||
| 275 | $author = $form->getElement('extra_authors'); |
||
| 276 | $conditions = [ |
||
| 277 | 'enabled' => 1, |
||
| 278 | 'status' => COURSEMANAGER, |
||
| 279 | ]; |
||
| 280 | $teachers = UserManager::get_user_list($conditions); |
||
| 281 | $options = []; |
||
| 282 | foreach ($teachers as $teacher) { |
||
| 283 | $options[$teacher['id']] = $teacher['complete_name']; |
||
| 284 | } |
||
| 285 | $author->setOptions($options); |
||
| 286 | } |
||
| 287 | |||
| 288 | Skill::addSkillsToForm($form, api_get_course_int_id(), api_get_session_id(), ITEM_TYPE_LEARNPATH, $lpId); |
||
| 289 | |||
| 290 | // select the next lp |
||
| 291 | if (true === api_get_configuration_value('lp_enable_flow')) { |
||
| 292 | $nextLpsOptions = learnpath::getNextLpsAvailable(api_get_course_int_id(), $lpId); |
||
| 293 | $nextLpId = learnpath::getFlowNextLpId($lpId, api_get_course_int_id()); |
||
| 294 | if (!empty($nextLpId)) { |
||
| 295 | $nextLpsOptions[$nextLpId] = learnPath::getLpNameById($nextLpId); |
||
| 296 | } |
||
| 297 | if (!empty($nextLpsOptions)) { |
||
| 298 | $form->addSelect( |
||
| 299 | 'next_lp_id', |
||
| 300 | get_lang('SelectTheNextLp'), |
||
| 301 | $nextLpsOptions |
||
| 302 | ); |
||
| 303 | $defaults['next_lp_id'] = $nextLpId; |
||
| 304 | } |
||
| 305 | } |
||
| 306 | |||
| 307 | // Submit button |
||
| 308 | $form->addButtonSave(get_lang('SaveLPSettings')); |
||
| 309 | |||
| 310 | // Hidden fields |
||
| 311 | $form->addElement('hidden', 'action', 'update_lp'); |
||
| 312 | $form->addElement('hidden', 'lp_id', $lpId); |
||
| 313 | |||
| 314 | $htmlHeadXtra[] = '<script> |
||
| 315 | $(function() { |
||
| 316 | '.$extra['jquery_ready_content'].' |
||
| 317 | }); |
||
| 318 | </script>'; |
||
| 319 | |||
| 320 | $htmlHeadXtra[] = '<script>'.$learnPath->get_js_dropdown_array().'</script>'; |
||
| 321 | |||
| 322 | $defaults['publicated_on'] = !empty($publicated_on) && $publicated_on !== '0000-00-00 00:00:00' |
||
| 323 | ? api_get_local_time($publicated_on) |
||
| 324 | : null; |
||
| 325 | $defaults['expired_on'] = (!empty($expired_on)) |
||
| 326 | ? api_get_local_time($expired_on) |
||
| 327 | : date('Y-m-d 12:00:00', time() + 84600); |
||
| 328 | $defaults['subscribe_users'] = $learnPath->getSubscribeUsers(); |
||
| 329 | |||
| 330 | $display = api_get_configuration_value('lp_view_settings')['display'] ?? []; |
||
| 331 | |||
| 332 | if (!empty($display)) { |
||
| 333 | $addExtraQuitToHomeIcon = $display['add_extra_quit_to_home_icon'] ?? false; |
||
| 334 | $value = (new ExtraFieldValue('lp'))->get_values_by_handler_and_field_variable($lpId, 'add_extra_quit_button'); |
||
| 335 | |||
| 336 | if (!is_array($value) && $addExtraQuitToHomeIcon) { |
||
| 337 | $defaults['extra_add_extra_quit_button[extra_add_extra_quit_button]'] = true; |
||
| 338 | } |
||
| 339 | } |
||
| 340 | |||
| 341 | $form->setDefaults($defaults); |
||
| 342 | |||
| 343 | Display::display_header(get_lang('CourseSettings'), 'Path'); |
||
| 344 | |||
| 345 | echo $learnPath->build_action_menu(false, false, true, false); |
||
| 346 | echo '<div class="row">'; |
||
| 347 | echo '<div class="'.($hideTableOfContents ? 'col-md-12' : 'col-md-8').'" id="pnl-frm">'; |
||
| 348 | $form->display(); |
||
| 349 | echo '</div>'; |
||
| 350 | echo '<div class="'.($hideTableOfContents ? 'hide' : 'col-md-4').' text-right" id="pnl-toc">'; |
||
| 351 | echo Display::return_icon('course_setting_layout.png'); |
||
| 352 | echo '</div>'; |
||
| 353 | echo '</div>'; |
||
| 354 | echo " |
||
| 355 | <script> |
||
| 356 | $(function() { |
||
| 357 | $('[name=\'hide_toc_frame\']').on('change', function() { |
||
| 358 | $('#pnl-frm').toggleClass('col-md-8').toggleClass('col-sm-12'); |
||
| 359 | $('#pnl-toc').toggleClass('col-md-4').toggleClass('hide'); |
||
| 360 | }); |
||
| 361 | }); |
||
| 362 | </script> |
||
| 363 | "; |
||
| 364 | Display::display_footer(); |
||
| 365 |
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.
This is most likely a typographical error or the method has been renamed.