Setting default access restrictions

Setting default access restrictions

by Rex Lorenzo -
Number of replies: 1

Does anyone have any experience/sample code for using the coursemodule_standard_elements call?  

What I want to do is set a default access restriction condition when a user creates a new module. I see the competencies plugin (tool_lp) is using it, but can I use it to set default access restriction conditions?

What I am currently doing is handling the course_module_created event trigger to add the access restriction after the course module is created. But it seems kinda a kludge because someone magically appears after someone creates the course module. If they didn't want the access restriction they would need to edit the module again, rather than remove or see the restriction on the initial module creation form.

Average of ratings: -
In reply to Rex Lorenzo

Re: Setting default access restrictions

by Darko Miletić -

You could probably do that provided that you know how those controls behave. You should create a local plugin or admin tool plugin that implements coursemodule_standard_elements hook and do the logic there.

For example if you have a plugin local_foo in the lib. php for that plugin you should have following method:

function local_foo_coursemodule_standard_elements($pluginform, $mform) {
    if (!empty(get_config('core', 'enableavailability'))) {
       // Do whatever you need to do here.
    }
}





Average of ratings: Useful (1)