Plugin code template.

Plugin code template.

by Said Bakr -
Number of replies: 9

Hi,

Is there any plugin code template that I could be able to use it as a skeleton to start plugin development for moodle3.x?

In addition, I tried to Google for a starter tutorial about Moodle development but I could not find.

Average of ratings: -
In reply to Said Bakr

Re: Plugin code template.

by Just H -

Development is not my thing but I would say start here.

I remember someone posted in the developers forum about a skeleton plugin he had on github so might be worth having a look through that forum too.

In reply to Just H

Re: Plugin code template.

by Richard Oelmann -
Picture of Core developers Picture of Plugin developers Picture of Testers

That could depend on what kind of plugin you are thinking of developing - themes have a different structure to blocks for example.

In reply to Said Bakr

Re: Plugin code template.

by Marcus Green -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers

What type of plugin are you thinking of developing?. A search of google on the terms "moodle plugin template code" returns several examples. Any template would be fairly plugin type specific. A template for a filter would not be very helpful if you were developing a block or question type. If you were considering developing a question type you might find Jamie Pratts template useful here

https://github.com/jamiepratt/moodle-qtype_TEMPLATE

and possibly my expansion of his work here

https://github.com/marcusgreen/moodle-qtype_TEMPLATE


Average of ratings: Useful (1)
In reply to Marcus Green

Re: Plugin code template.

by Said Bakr -

This is my big problem as a beginner in Moodle. I could not able to determine which type of plugin should I follow to apply what I need to get. My scenario is simple as the following screen shot:

The modification result

To get the number of enrolled students for each course in the courses list on the front page, I got lost between the types of Moodle. Should it to be Course type, Reports Type, Block type or Local type. In addition, basically, I could not able to know which plugin responsible for creating that "Available courses" list.


In reply to Said Bakr

Re: Plugin code template.

by Richard Oelmann -
Picture of Core developers Picture of Plugin developers Picture of Testers

That is probably best achieved by customising your theme and having a renderer override for the available courses display - there are lots of examples of this in existing themes, although not of your particular requirement.

https://docs.moodle.org/dev/Overriding_a_renderer

Average of ratings: Useful (2)
In reply to Richard Oelmann

Re: Plugin code template.

by Said Bakr -

Thank you very much it was very helpful resource's link. I have duplicated More theme and renamed it with new name, then I added renderer.php to the new theme root with the following:

class theme_overridetest_core_renderer extends core_renderer {
 
}
 
 
include_once($CFG->dirroot . "/course/renderer.php");
 
class theme_abdellatif_core_course_renderer extends core_course_renderer {
 
   protected function coursecat_coursebox_content(coursecat_helper $chelper, $course) {

Then using  enrollment api:


return $content.'Enrolled Students: ' .count_enrolled_users(context_COURSE::instance($course->id),'mod/assignment:submit'));

Of course it is not totally adjusted but It is good start for me at this point, so I could able to get the screen shot as real output.

In reply to Said Bakr

Re: Plugin code template.

by Said Bakr -

As described in the previous post, I become able to solve the issue. However, there is a little issue. In order to make some management to the solution, i.e. making an option that allow/disallow showing the option of displaying the total count of a course enrolled students. I had to make this option from the theme settings:


A screen shot for theme settings

What I need to get now, is to override     " Dashboard / ► Site administration / ► Appearance / ► Courses  " to be able add this option as a settings for courses? where is the renderer of this?



In reply to Said Bakr

Re: Plugin code template.

by Michael Aherne -
Picture of Core developers Picture of Peer reviewers Picture of Plugin developers

There are some templates for other plugins at https://github.com/search?q=user%3Adanielneis+new

(I haven't used these but I believe they're used by the moosh tool so they're probably quite sound)
Average of ratings: Useful (2)