The block system currently has functionality built in to allow default blocks to be defined for specific course formats. Unfortunately, it is limited to the standard 'social' format and one default setting set in the config file.
I propose that we allow a default block setting to be defined for any course format (standard and custom).
I think the easiest way to do this would be to add an optional 'config.php' file in every course format directory. Modules that need to can include the course format config file and have extra information associated with that course.
For blocks, this would mean that the course 'edit.php' file could pass any default blocks configuration string to 'blocks_get_default_blocks' instead of just depending on the site default.
So the code:
//Create blockinfo default content
if ($form->format == "social") {
$form->blockinfo = blocks_get_default_blocks (NULL,"participants,search_forums,calendar_month,calendar_upcoming,social_activities,recent_activity,admin,course_list");
} else {
//For topics and weeks formats (default built in the function)
$form->blockinfo = blocks_get_default_blocks();
}
could become:
$format_config = $CFG->dirroot.'/course/format/'.$course->format.'/config.php';
if (file_exists($format_config)) {
require($format_config);
}
if (isset($format['defaultblocks'])) {
$defblocks = $format['defaultblocks'];
}
else {
$defblocks = null;
}
$form->blockinfo = blocks_get_default_blocks(null, $defblocks);
The social format, which currently has the exception, would then just need to have a config file with the line:
$format['defaultblocks'] = 'participants,search_forums,calendar_month,calendar_upcoming,social_activities,recent_activity,admin,course_list';
in it, to do the same thing. Likewise, any other course format could include their own default setup. Any course without this specified will just fall back to the site defaults.
Thoughts?
mike
Nice point, Mike. Take a look at the latest blocklib.php though (hasn't anything to do with your proposal, but to get up to date).
I generally agree with the concept, even though I haven't given it too much thought.
Jon
I generally agree with the concept, even though I haven't given it too much thought.
Jon
Hi Jon -
Pretty sure I have the latest 'blocklib.php' (v 1.19 2004/08/31 07:29:25). What did you want me to look at?
I noticed that you have constants defined for each of the standard course formats, but as far as I can tell they are only used once for a site update, correct? And also as the default format (weeks) if there is no site default.
I know you guys have lots on your plates, but this is something that is really necessary in order to make custom formats and blocks useful. Currently, any time a new course is setup, a teacher has to completely reload and configure all blocks. This becomes a real chore when you use custom formats and custom blocks.
I'm willing to dump the changes into the system. I just need agreement to the approach.
mike
Pretty sure I have the latest 'blocklib.php' (v 1.19 2004/08/31 07:29:25). What did you want me to look at?
I noticed that you have constants defined for each of the standard course formats, but as far as I can tell they are only used once for a site update, correct? And also as the default format (weeks) if there is no site default.
I know you guys have lots on your plates, but this is something that is really necessary in order to make custom formats and blocks useful. Currently, any time a new course is setup, a teacher has to completely reload and configure all blocks. This becomes a real chore when you use custom formats and custom blocks.
I'm willing to dump the changes into the system. I just need agreement to the approach.
mike
This is fine, but it should be possible to set site defaults that override the course format defaults.
Martin said:
> This is fine, but it should be possible to set site defaults that override the
> course format defaults.
Hmmm. Are you sure about that?
Right now, the site defaults do not affect the 'social' format, but affect all others.
I would think it would be more desirable to have specific block defaults defined for every course format. That way, when you create a course with a specific format it comes pre-setup. If the site config overrules this, all course formats will have exactly the same default block setup.
> This is fine, but it should be possible to set site defaults that override the
> course format defaults.
Hmmm. Are you sure about that?
Right now, the site defaults do not affect the 'social' format, but affect all others.
I would think it would be more desirable to have specific block defaults defined for every course format. That way, when you create a course with a specific format it comes pre-setup. If the site config overrules this, all course formats will have exactly the same default block setup.
Sorry, I was probably not clear. I meant that it should be possible to override the format's own default for the block setup for each format individually.
eg something like
$CFG->defaultblocks_weekly = 'blah';
$CFG->defaultblocks_topics = 'blah';
$CFG->defaultblocks_g8 = 'blah';
and even keep the current $CFG->defaultblocks as a fallback to use if it exists.
so for weekly the logic would be something like,
if defaultblocks_weekly, use that
else if defaultblocks, use that
else use format's own default
I know a couple of sites who need to use $CFG->defaultblocks already, so providing the possibility for individual formats as well would be helpful.
eg something like
$CFG->defaultblocks_weekly = 'blah';
$CFG->defaultblocks_topics = 'blah';
$CFG->defaultblocks_g8 = 'blah';
and even keep the current $CFG->defaultblocks as a fallback to use if it exists.
so for weekly the logic would be something like,
if defaultblocks_weekly, use that
else if defaultblocks, use that
else use format's own default
I know a couple of sites who need to use $CFG->defaultblocks already, so providing the possibility for individual formats as well would be helpful.
Gotcha.
I agree except that I think the defaultblocks fallback should be just that. The one that's used if nothing else applies.
So the rules would be:
if site config defaultblocks_<format>, use that
else if <format> has own default, use that
else use defaultblocks
If we want one default to rule them all, we could create one called defaultblocks_override, which would be used for all formats, all the time. In this case, it would be the first rule above.
mike
I agree except that I think the defaultblocks fallback should be just that. The one that's used if nothing else applies.
So the rules would be:
if site config defaultblocks_<format>, use that
else if <format> has own default, use that
else use defaultblocks
If we want one default to rule them all, we could create one called defaultblocks_override, which would be used for all formats, all the time. In this case, it would be the first rule above.
mike
I vote "great!"
Okay. I have implemented in the 1.5 trunk.
The files that have been updated are:
I didn't merge it into the 1.4 stable. Not sure if we want to or not.
mike
The files that have been updated are:
course/format/<format>/config.php
course/edit.php
lib/blocklib.php
config-dist.php
course/edit.php
lib/blocklib.php
config-dist.php
I didn't merge it into the 1.4 stable. Not sure if we want to or not.
mike