gjbarnard / moodle-format_topcoll

Collapsed Topics course format for Moodle.
http://docs.moodle.org/en/Collapsed_Topics_course_format
GNU General Public License v3.0
35 stars 60 forks source link

Blocks optional moodle 39 #94

Closed John-Joubert closed 3 years ago

John-Joubert commented 3 years ago

Greetings Gabe.

This is change code for topcoll - to make the four default blocks optional.

This request is a change for the MOODLE_39 branch. (I will follow up with a change to the Moodle 3.10 version). I have it as a branch below the MOODLE_39 branch. At least, I've attempted to put it there - it's there in my .git correctly on my server - so I'm hoping it's there correctly in this upload. If I need to use a different push command other than the obvious "git push - please let me know. I tried to find examples of a different syntax for a push for sub-branch but I failed to find it. (Apologies if done wrong).

The branch name is: blocks_optional_MOODLE_39 - and it should be sub-branch of MOODLE_39.

I will be happy to make any changes you desire to accept this work.

It has a Yes/No setting in the settings screen, and it has the strings needed in the language files, and it has the change in the lib.php file to make the four blocks come up if chosen, by default - the code always includes your four blocks unless the settings are turned off.

I've documented everything in a file called "Changes_blocks_optional.md - which I've included here, so that you may read/review it here, and also in the project, if desired.


/var/www/moodle/course/format/topcoll$ cat Changes_blocks_optional.md

John Joubert - GitHub: https://github.com/John-Joubert

The purpose of this branch "blocks_optional_MOODLE_39" is to allow the blocks display to be optional. --> This branch "blocks_optional_MOODLE_39" is a sub-branch of MOODLE_39.

Code changes: 1) language - Added entries into language files: modified: lang/en/format_topcoll.php modified: lang/en_ar/format_topcoll.php modified: lang/en_us/format_topcoll.php

Last entries in the bottom of the "en" and "en_us" files above:

// Toggle Display Blocks $string['defaultdisplayblocks'] = 'Display the four blocks that come with this format plugin'; $string['defaultdisplayblocks_desc'] = "Display the four blocks that come with this format plugin in the course. Yes or No.";

*Note: additions for en_ar matches style of the rest of the file, or at least tries to // Toggle Display Blocks $string['defaultdisplayblocks'] = 'Display the four blocks that come with this format plugin to crew'; $string['defaultdisplayblocks_desc'] = "Display the four blocks that come with this format plugin in the course. Can bee Aye or Nay.";

2) New settings in settings.php, addition starts at line 50

/* Toggle instructions - 1 = no, 2 = yes. */
$name = 'format_topcoll/defaultdisplayblocks';
$title = get_string('defaultdisplayblocks', 'format_topcoll');
$description = get_string('defaultdisplayblocks_desc', 'format_topcoll');
$default = 2;
$choices = array(
    2 => new lang_string('yes'),// Yes.
    1 => new lang_string('no')  // No.
);  
$settings->add(new admin_setting_configselect($name, $title, $description, $default, $choices));

3) Replacement code in lib.php to make the settings of the blocks conditional on the settings for defaultdisplayblocks.

Replacement code is at line 337 of lib.php: /**

Original Code at line 337 of lib.php: /**