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

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

by Matt Chambers -
Number of replies: 3

Hello ALL. I am creating a new plugin that I want to be accessible as a block. It will sit on a course or several courses i think and I want it to be able to access multiple courses, the database and do things for an entire user or users. 

A Block is to go on a page or course to be used and edited and a Mod is something that will add to pre existing code and manipulate things in the background, is this right?. But I think my plugin will do both. Does this mean that I need both a block and a Module?

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

Average of ratings: -
In reply to Matt Chambers

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

by Darko Miletić -

> 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.

In reply to Darko Miletić

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

by Matt Chambers -

Ok. 

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?

Thanks

Matt

In reply to Matt Chambers

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

by Hubert Chathi -

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)