Custom Course Format Settings

Custom Course Format Settings

by Brandon Turner -
Number of replies: 3
Does anyone know if there is a "standard" way to add new course settings from within a plugin such as a course formatter? I've been working on a custom course formatter and need to add some settings relating to the formatter that vary by course.

I was reading Sam's excellent new wiki about creating settings for themes and wondered if there was equivalent functionality for creating settings for course formats.

If there is not, and I were to try writing a patch for core to implement such functionality, does anyone have any thoughts/suggestions? I am currently thinking of two options:

1) Course format settings would appear on the course settings page in their own fieldset box. The biggest problem I see with this is the behavior when an administrator changes the course format (via the dropdown) but has yet to save the page.

2) Course format settings would be added to the Course Administration navigation. Only settings for the currently selected course format would be available.


Finally, perhaps this deserves its own topic, but any thoughts on how a local plugin could add course settings?

I'm looking forward to your thoughts and/or pointers. Thanks in advance!
Average of ratings: -
In reply to Brandon Turner

Re: Custom Course Format Settings

by sam marshall -
Picture of Core developers Picture of Peer reviewers Picture of Plugin developers
Neat idea. Not to suggest this isn't a good plan, but just to mention - it's possible for format settings to be handled independently in the user interface, which might be better in some instances (...as well as worse in others) because the course format obviously has full control of the course page.

For example, our custom 1.9 'study planner' format, if editing is on, gives you several extra icons. One of these takes you to an 'edit planner settings' page which is a normal moodle form and changes certain settings related specifically to the study planner.

It would be nice if these could be integrated into course settings (especially since some of the course settings - most notably start date and number of sections - directly affect the study planner format, so it's weird to have those in course settings and others in study planner settings). But it's not too bad to deal with it that way!

Back to your point - as I understand it the settings.php system is for global admin settings (those theme settings are for the whole theme at site level, not per-course) so would not be useful in this case. This is down at the level of mform api, I think.

Blah, I just wrote out how I think adding it to course settings should be done, but then decided I don't think it should be done that way because of the user interface problem you mention (what happens when you change the format dropdown). Here's my revised proposal which is shorter: use a tab. smile Like some other areas, stick tabs in course settings. One tab could be '<format> settings'. (So 'Weekly settings' or 'Topics settings' or whatever.) You only get to see the tab for the current format, and if you change to look at that tab, you won't be able to change the format, so it'll be okay. How's that? This could be implemented similarly to module mod_form.php, so something like:

- format_form.php in format folder
- formatname_settings_load($course) in format lib.php to retrieve data values to supply to form
- formatname_settings_save($course, $data) in lib.php to save data values when form is saved

just a thought... I like the idea of course formats having settings (obviously, since I wrote a course format which has settings) and a way to make this simpler would be nice, even though it's possible now.

--sam





Average of ratings: Useful (1)
In reply to sam marshall

Re: Custom Course Format Settings

by Sam Hemelryk -
Hello Brandon + Sam,

I'm just chiming in very briefly.

It's a good idea Brandon, I did see your question in the theme's forum but checking it out completely skipped my mind sorry.

Sam, that whilst I am not a big fan of using tabs I think that your thoughts on a method for adding course format settings is fantastic.

In relation to the tabs I would much rather see it implemented through the navigation system (which can be output as tabs through the renderer if one desires).
Something like 'Format settings' immediately after the 'Settings' link in the course section of the settings navigation would awesome.

Cheers
Sam

In reply to Sam Hemelryk

Re: Custom Course Format Settings

by Brandon Turner -
Thanks "Sams" for your responses. 3 months later and I'm finally looking at it again.

Sam M: When I wrote my original post, for some reason I was thinking I could hook into the admin settings moodle has (similar to themes). I now realize, as you pointed out, that to do this at the course level I have to implement my own UI, my own database tables to persist to, etc. I've done this for my course format and it works well.

Sam H: I agree that adding a link to the course administration navigation would be ideal. I've submitted a patch at MDL-24348. Hopefully you guys will consider it for inclusion in Moodle 2.0.

The patch doesn't really make our jobs much easier in terms of adding custom settings, it only provides a convenient hook into the course administration navigation. It also does some magic to make the settings navigation node a drop-down/container if multiple settings pages exist for a course.

Perhaps if there is enough interest, I could work on a patch similar to what Sam M. suggested.