How do I set the default blocks for all courses?

How do I set the default blocks for all courses?

by Glenn Pillsbury -
Number of replies: 16

Using Moodle 2.1.2.  When I create a new course, there are four blocks on by default: "Search forums", "Latest news", "Upcoming events", and "Recent activity".  How do I make sure those don't appear by default?

Instead, I'd like other blocks to appear by default (Calendar and QuickMail).

In 1.9 there was a way to set some course defaults, but I can't find those in 2.x.

Thanks for your help!

Average of ratings: -
In reply to Glenn Pillsbury

Re: How do I set the default blocks for all courses?

by Glenn Pillsbury -

I take it from the deafening silence on this question that there is in fact no way to set a default course layout.  That's too bad and a strange deletion of a nice 1.9 feature by the Moodle crew.

Will put this suggestion into the tracker.

In reply to Glenn Pillsbury

Re: How do I set the default blocks for all courses?

by Tim Hunt -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers

It is possible to set default course block in 2.x, in exactly the same way as in 1.9. Read config-dist.php.

Average of ratings: Useful (2)
In reply to Tim Hunt

Re: How do I set the default blocks for all courses?

by Glenn Pillsbury -

Thanks for that information.  I was refering more to the "sticky" blocks interface in 1.9 (Modules > Blocks > Sticky Blocks) which seems to have been removed from 2.x.

In reply to Glenn Pillsbury

Re: How do I set the default blocks for all courses?

by Mary Cooch -
Picture of Documentation writers Picture of Moodle HQ Picture of Particularly helpful Moodlers Picture of Testers Picture of Translators
In reply to Mary Cooch

Re: How do I set the default blocks for all courses?

by Glenn Pillsbury -

Thanks.  Will take a look at that, too.

In reply to Mary Cooch

Re: How do I set the default blocks for all courses?

by Zaid Ghansar -

I installed a block and configured it to show on every course page, but it does not show up.

Is there some other settings in back end?

In reply to Zaid Ghansar

Re: How do I set the default blocks for all courses?

by Zaid Ghansar -

NVM, I was adding it in a course and thought it will show up in other courses.

It needed to be added on main page.

In reply to Glenn Pillsbury

Re: How do I set the default blocks for all courses?

by Daniel Kaelin -

Glen, Did you figure this out? 

I'm also trying to figure out how to prevent the auto creation of these 4 blocks. 

I set site wide sticky blocks and they are conflicting with these blocks resulting in duplicate blocks. The main reason I don't want them auto created is you can't specify the default weight. When moodle auto creates these blocks in new shells the weights are 0,1,2,3. 

In reply to Daniel Kaelin

Re: How do I set the default blocks for all courses?

by Daniel Kaelin -

Well I ended up answering my own question through some experimentation. 

If you want to prevent Moodle from installing any blocks by default to new courses you have to add this line to your config.php.


$CFG->defaultblocks_override = ' ';

It requires the space in between the singe quotes. 

Average of ratings: Useful (7)
In reply to Daniel Kaelin

Re: How do I set the default blocks for all courses?

by Brian Merritt -
Picture of Particularly helpful Moodlers

Which course formats are you using Daniel?

You are better to change the course format to the blocks you actually want. For example, in Topics Format (course/format/topics/lib.php)

public function get_default_blocks() {
global $CFG;
if (!empty($CFG->defaultblocks)){
return blocks_parse_default_blocks_list($CFG->defaultblocks);
}
$blocknames = array(
BLOCK_POS_LEFT => array(),
BLOCK_POS_RIGHT => array('search_forums', 'news_items', 'calendar_upcoming', 'recent_activity')
);
return $blocknames;
}

Just change the names on the blocks.  To be safe, you can create your own course format and do other modifications to Topics and call it "danielstopics"

In reply to Brian Merritt

Re: How do I set the default blocks for all courses?

by Daniel Kaelin -

I feel much more comfortable with my method because the line goes in the config.php which won't be overwritten on upgrades. 

If you are managing a lot of Moodle instances it can be tedious tracking customizations on the actual Moodle installation files. 

In reply to Brian Merritt

Re: How do I set the default blocks for all courses?

by Elizabeth Dalton -

It's good to know where this is controlled, but having to edit php to set default blocks seems inconvenient (especially for those of us who have contracted for hosting services with a Moodle Partner -- they don't generally let us edit cfg files.) I think a request for a feature is in order here....

And in fact, it exists: MDL-34718