Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support indentation #209

Open
gjb2048 opened this issue May 13, 2024 · 3 comments
Open

Support indentation #209

gjb2048 opened this issue May 13, 2024 · 3 comments

Comments

@gjb2048
Copy link
Collaborator

gjb2048 commented May 13, 2024

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).

@gjb2048
Copy link
Collaborator Author

gjb2048 commented May 13, 2024

Note to self 'uses_indentation()' and JS changed etc.

@Shotte
Copy link

Shotte commented Jun 30, 2024

@gjb2048
At first view I figured out 4 files that requires adding/changing code, taken from comparing with topics/weekly format:

  1. 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
        ));  
}
  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;
    }

  1. 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.';
  1. 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.

@gjb2048
Copy link
Collaborator Author

gjb2048 commented Jun 30, 2024

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants