General developer forum

Can a new plugin be both a Mod and a Block?

Picture of Darko Miletić
Re: Can a new plugin be both a Mod and a Block?
Core developersParticularly helpful Moodlers

> Hope that makes sense. ...... Matt

Not really. Be more specific. And no single module can not be both block and activity at the same time.

Average of ratings: -
Picture of Matt Chambers
Re: Can a new plugin be both a Mod and a Block?


My plugin will start off as a block. Lets assume that a student is on more than one Moodle Course. (Where one college course could be made up of multiple moodle courses like BTEC -> units). The plugin will sumarise these courses. 

So for example for quizes it will draw in all the users results, it will let the students access them, let the teachers mark them. It wont ever really update the other modules databases directly, but will read from them. It will just link to the other modules pages in order to update them.

So, its a block that will sit on the front page or a course. But its not really about that one course. Its a summary of the user, a whole class of users or all of the teachers students. So, as it has access across the entire moodle site i didnt know if I should create some files in a block folder and then reference some files that sit in a Module folder? Or do I just create a HUGE block?



Average of ratings: -
Picture of Hubert Chathi
Re: Can a new plugin be both a Mod and a Block?
Plugin developers

A block has full access to the Moodle database, so it can fetch any information that it needs.  Many blocks only limit their display to the current course, but there is nothing preventing a block from accessing data from other courses.
If you are wanting to display a link to a different module's page, that is a perfectly reasonable thing to do (as long as you ensure that the module exists).  (e.g. the Navigation block does that)

Average of ratings: -