Open gjb2048 opened 6 months ago
Note to self 'uses_indentation()' and JS changed etc.
@gjb2048 At first view I figured out 4 files that requires adding/changing code, taken from comparing with topics/weekly format:
settings.php: added part for indentation settings (at admin panel)
if ($ADMIN->fulltree) {
...
// allow indentation
$url = new moodle_url('/admin/course/resetindentation.php', ['format' => 'grid']);
$link = html_writer::link($url, get_string('resetindentation', 'admin'));
$settings->add(new admin_setting_configcheckbox(
'format_grid/indentation',
new lang_string('indentation', 'format_grid'),
new lang_string('indentation_help', 'format_grid').'<br />'.$link,
1
));
}
lib.php: changed two methods
public function uses_indentation(): bool {
return (get_config('format_grid', 'indentation')) ? true : false;
}
public function get_config_for_external() {
// Return everything (nothing to hide).
$formatoptions = $this->get_format_options();
$formatoptions['indentation'] = get_config('format_topics', 'indentation');
return $formatoptions;
}
3. lang/en/format_grid.php: added two strings at "Other" section
$string['indentation'] = 'Allow indentation on course page'; $string['indentation_help'] = 'Allow teachers, and other users with the manage activities capability, to indent items on the course page.';
4. db/upgrade.php: added oldversion compare
function xmldb_format_grid_upgrade($oldversion = 0) { ...
if ($oldversion < 2023030700) {
// For sites migrating from 4.0.x or 4.1.x where the indentation was removed,
// we are disabling 'indentation' value by default.
if ($oldversion >= 2022041900) {
set_config('indentation', 0, 'format_topics');
} else {
set_config('indentation', 1, 'format_topics');
}
upgrade_plugin_savepoint(true, 2023030700, 'format', 'topics');
}
...
After all these changes I tried it using Moodle 4.3 (that's my current running version) and the admin setting as well as the possibility to to move the contents to left/right are provided.
Whats missing is the automatic update in the view during editing course content. There must somewhere added an event that let Moodle update the view. Maybe you are able to find out and add this hopefully simple action.
Dear @Shotte,
As already labelled, this will need funding.
With respect, your code has some serious flaws in it. Start by getting 'uses_indentation()' to simply return 'true' and then workout what else needs to change to make it happen.
G
Is your feature request related to a problem? Please describe. Indentation not supported like Collapsed Topics etc.
Describe the solution you'd like Indentation to work almost like it did before.
Describe alternatives you've considered A clear and concise description of any alternative solutions or features you've considered.
Additional context Ref: https://moodle.org/mod/forum/discuss.php?d=458403
Versions you are currently using (please complete the following information): Grid format release 401.2.3, version 2022112609 on Moodle 4.1.10 (Build: 20240422).