Block in all Courses in Moodle 2.0

Block in all Courses in Moodle 2.0

by Martín Maglianesi -
Number of replies: 12

I tried putting the Activity Block in all courses. My way of procedure is as follows:

- Edit any course
- Add the Activities Block
- Edit the configuration and set the options restrictions value in "course-* (page Any Course)"

But not appears the block in all Courses. I'm doing something wrong or is it a bug?

I clarify that I have migrated courses from Moodle 1.9 to 2.0. Could it be the cause of the problem? In Moodle 1.9 running a script that was "blocks_repopulate_page ($page)" for each course. This feature has been deprecated in Moodle 2.0.

Thank you very much and excuse my English! wink

Martín

Average of ratings: -
In reply to Martín Maglianesi

Re: Block in all Courses in Moodle 2.0

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

Doing this is possible, but tricky. Here is how:

  1. Go to the front page of the site, and add the block there.
  2. Click the edit icon on the block and change Page contexts to "Display throughout the entire site."
  3. Go into any course, and click the edit icon on the block again.
  4. Set Restrict to these page types to "course-view-*".
Average of ratings: Useful (6)
In reply to Tim Hunt

Re: Block in all Courses in Moodle 2.0

by Martín Maglianesi -

Thank very much Tim. Works perfect!! smile

Greetings,

Martín

In reply to Martín Maglianesi

Re: Block in all Courses in Moodle 2.0

by Ray Lawrence -

Just so I'm clear on this:

  • Only possible if the required block is added to the Front Page1
  • The block will appear on the Front page too.

What happens if the block on the front page is hidden on that page i.e. does it still appear in every other course?

1Was this deliberate or did it just turn out this way? Just trying to understand the logic and whether it's work raising a feature request in the Tracker for a more intuitive way to resurrect the Sticky Blocks concept.

In reply to Ray Lawrence

Re: Block in all Courses in Moodle 2.0

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

I just hid the block on the front page and it seems to get hidden on the other pages too then - I thought (or rather a year or so ago it was Tim who actually told me) that to get a "sticky block" and not have it affecting the front page you added it on a site admin page like for example "notifications", rather than the front page - and then you went into the course and altered it following Tim's instructions above.

But -whichever way is right or wrong, sticky blocks and the whole positioning of blocks concept (with its * admin/index/etc pages) is really confusing to regular users. To be honest I  wrote about it in my book and I still don't really understand it - it really should have more user-friendly terminology. Many people don't even understand about the * wild card anyway (I didn't, until Tim explained 2 summers ago) I've an idea there already is a tracker entry about this - will take a look.

In reply to Mary Cooch

Re: Block in all Courses in Moodle 2.0

by Martín Maglianesi -
I agree it is confusing and not very intuitive but the steps proposed by Tim work. The problem could be solved with proper documentation or with a block that facilitates the configuration.
In reply to Ray Lawrence

Re: Block in all Courses in Moodle 2.0

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

If you are seeking clarity, I suggest you try it. For example, you would fine that the block does not appear on the front page. That is because that is page type site-index, which does not match the pattern course-view-*. (If you go to admin -> development -> debugging. there is the option to display the page information in the footer of every page.

Also, if you look at the settings form for the block, the Visible option appears in the "On this page" section of the form, which should let you work out the answer to your first question. (If not, try it.)

The new blocks system was intentionally designed to be as flexible as possible without hurting Moodle's performance. In practice that means the system has to be able to work out which blocks appear on the current page with a single DB query. The resulting system is very flexible and based on a simple logic. (I have explained it before in these forums.)

However, building a user-interface that exposes all that flexibility to users in a way they can understand is a much more complex problem, and we definitely have not solved it yet, hence the rather circuitous set of steps I had to give.

In reply to Tim Hunt

Re: Block in all Courses in Moodle 2.0

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

Here's the tracker entry to more user friendly blocks: http://tracker.moodle.org/browse/MDL-26105

In reply to Mary Cooch

Re: Block in all Courses in Moodle 2.0

by Ray Lawrence -

Agree it's difficult to get the balance right. Lots more flexibility which is great for "power users" but keeping the system accessible for more casual users is a real issue. I doubt it will ever be fully resolved.

In reply to Ray Lawrence

Re: Block in all Courses in Moodle 2.0

by sam marshall -
Picture of Core developers Picture of Peer reviewers Picture of Plugin developers

There is definitely room for improvement. Tim's workaround is a clever one, which I didn't think of - I found it easier to configure by altering the database row...

I think the biggest improvement required is the one given in this thread (because it's the one we needed here too): the ability to have a block on every course page throughout the site. Generically, you might also want to have a block on (e.g.) every forum page.

All this requires is a change to the 'Page contexts' option so that it additionally lets you select 'entire site' (or ideally 'category' etc) within the dropdown. At present it only lets you select up to course level.

In order to do this, the page would need to check you have permission (i.e. the same permissions it would check now if you tried to do this on the front page or a category page) before allowing those options. Other than that, though, I don't see a problem and it doesn't complicate the interface.

The interface is a bit confusing but I think it has to be in order to be this flexible (which is great btw); I think improved documentation would address the confusing part, or if really necessary it could be hidden behind an 'Advanced' so that this interface doesn't even display normally, but that's a separate discussion.

I filed this as MDL-26709 ( a bit more specific than MDL-26105 - annoyingly when I linked it it says 'will be resolved by' which is definitely not true, 'will help resolve' on the other end is true, but there are other problems with it apart from this one). Feel free to vote / code / etc smile

--sam

In reply to Tim Hunt

Re: Block in all Courses in Moodle 2.0

by William Lu -
Picture of Particularly helpful Moodlers

Sorry, everyone, I am not quite sure about the issue in this topic. But if you are talking about 'Sticky Block' in Moodle, I think it is pretty good.

For example, if you want to add a 'Sticky' block to all courses, just add it in the 'Front page' and set to 'Display throughout the entire site'.

1

Of course, you don't really want this Sticky block displayed on your 'Front page', so you prevent 'Guest view':

2

Done.



Hi Tim, I am quite sure that if the "course-view-*" means 'Any course page'? 

?


In reply to William Lu

Re: Block in all Courses in Moodle 2.0

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

I think "Any type of course main page."

In reply to Tim Hunt

Re: Block in all Courses in Moodle 2.0

by Khanh Dam -

Hi Tim,

Do you know how to achieve this by programming? I have created a block and adding, configuring it is fine. But now I want it to display itselft by default. I have try changing default block (but this is for new course only, not what I want).

Thanks.