Add an resource/activity to a plugin

Add an resource/activity to a plugin

by Helson C -
Number of replies: 7

Hello,

I need create a plugin in a way that i can add a resource to him, like a course page.

I know about plugin development, but in my search i dont find nothing related...


Thanks in advance.

Average of ratings: -
In reply to Helson C

Re: Add an resource/activity to a plugin

by Helson C -

Anyone?

In reply to Helson C

Re: Add an resource/activity to a plugin

by Mike Churchward -
Picture of Core developers Picture of Plugin developers Picture of Testers

Hi -

Documentation on developing an activity module starts here - https://docs.moodle.org/dev/Activity_modules.

Resources are just activity modules that define themselves as resources. In Moodle core, the modules "resource" and "book" are examples of modules that are defined as resources. You can use those as examples.

In both of those modules, you will find a "[modulename]_supports" function in their "lib.php" files that define them as resources ("MOD_ARCHETYPE_RESOURCE").

mike

Average of ratings: Useful (1)
In reply to Mike Churchward

Re: Add an resource/activity to a plugin

by Helson C -

Hi Mike, 

Really, i don't need create a new activity module or resource. Only create a plugin which accept add activity or resource from MOODLE, like book, quiz.. 

I need who the option "add new activity/resource" appear on my plugin.

Thank you so much and sorry for my bad english.

In reply to Helson C

Re: Add an resource/activity to a plugin

by Darko Miletić -

So if I understand correctly you would like to have an activity which would behave as course front page where you can add any other activity.

I don't think that is possible. You might consider custom course format that offers something like that.

For example this one:

https://moodle.org/plugins/view.php?plugin=format_flexsections

or this one:

https://moodle.org/plugins/view/format_flexpage

Which both offer topic within topic feature.

Average of ratings: Useful (1)
In reply to Darko Miletić

Re: Add an resource/activity to a plugin

by Helson C -

Hi Darko! :}

You almost got me! I don't need create a new activity or resource. I need use the default activity of MOODLE.

But, i need add these activity and resources in page of my plugin.


In short, I need add the link "add activity or resource" in my new plugin.

In reply to Helson C

Re: Add an resource/activity to a plugin

by Darko Miletić -

If you just need the link to the popup dialog here goes:

Look into [moodlepath]/course/renderer.php

Focus on:

core_course_renderer::course_modchooser
// And
core_course_renderer::course_section_add_cm_control
//which uses it

You can call it from your code like this:

/* @var $renderer core_course_renderer */
$renderer = $PAGE->get_renderer('core_course');
echo $renderer->course_modchooser([some parameters]);