Note:

If you want to create a new page for developers, you should create it on the Moodle Developer Resource site.

Plugin types: Difference between revisions

From MoodleDocs
No edit summary
m (→‎List of Moodle plugin types: Add h5plib plugin type)
(36 intermediate revisions by 17 users not shown)
Line 1: Line 1:
{{Plugins development}}
The M in Moodle stands for modular.  The easiest and most maintainable way to add new functionality to Moodle is by writing one of these types of plugin.  
The M in Moodle stands for modular.  The easiest and most maintainable way to add new functionality to Moodle is by writing one of these types of plugin.  
If none of the standardized types fits your needs, you can use the "local" type.
 
== List of Moodle plugin types ==


{| class="nicetable"
{| class="nicetable"
|-
|-
! Plugin type
! Plugin type
! Component name
! Component name ([[Frankenstyle]])
! Moodle path
! Moodle path
! Description
! Description
Line 13: Line 16:
| mod
| mod
| /mod
| /mod
| Activity modules are the most important type of plugins.  They provide activities in courses. For example: Forum, Quiz and Assignment.
| Activity modules are essential types of plugins in Moodle as they provide activities in courses. For example: Forum, Quiz and Assignment.
| All
| 1.0+
|-
|-
| [[Admin reports]]
| [[Antivirus plugins]]
| report
| antivirus
| /admin/report
| /lib/antivirus
| Provides useful views of data in a Moodle site, for admins only.
| Antivirus scanner plugins provide functionality for virus scanning user uploaded files using third-party virus scanning tools in Moodle. For example: ClamAV.
| Up to 2.1 (for 2.2+ see [[Reports]])
| 3.1+
|-
|-
| [[Admin tools]]
| [[Assign_submission_plugins|Assignment submission plugins]]
| tool
| /admin/tool
| Provides utility scripts useful for admins to examine and modify a Moodle site
| 2.2+
|-
| [[Assignment types|Assignment 2.2 types]]
| assignment
| /mod/assignment/type
| Different forms of assignments to be graded by teachers
| 1.x - 2.2
|-
| Assignment 2.3 submissions
| assignsubmission
| assignsubmission
| /mod/assign/submission
| /mod/assign/submission
Line 40: Line 31:
| 2.3+
| 2.3+
|-
|-
| Assignment 2.3 feedbacks
| [[Assign_feedback_plugins|Assignment feedback plugins]]
| assignfeedback
| assignfeedback
| /mod/assign/feedback
| /mod/assign/feedback
Line 46: Line 37:
| 2.3+
| 2.3+
|-
|-
| [[Authentication plugins]]
| [[Book tools]]
| auth
| booktool
| /auth
| /mod/book/tool
| Allows connection to external sources of authentication
| 2.0
|-
| [[Blocks]]
| block
| /blocks
| Small information-displays or tools that can be moved around pages
| Small information-displays or tools that can be moved around pages
| 2.0+
| 2.1+
|-
|-
| [[Course formats]]
| [[Custom fields]]
| format
| customfield
| /course/format
| /customfield/field
| Different ways of laying out the activities and blocks in a course
| Custom field types, used e. g. in Custom course fields
| 1.3+
| 3.7+
|-
| [[Course reports]]
| coursereport
| /course/report
| Reports of activity within the course
| Up to 2.1 (for 2.2+ see [[Reports]])
|-
|-
| [[Database fields]]
| [[Database fields]]
Line 81: Line 60:
| Pre-defined templates for the Database activity module
| Pre-defined templates for the Database activity module
| 1.6+
| 1.6+
|-
| [[External tool source|LTI sources]]
| ltisource
| /mod/lti/source
| LTI providers can be added to external tools easily through the external tools interface see [https://docs.moodle.org/en/External_tool Documentation on External Tools]. This type of plugin is specific to LTI providers that need a plugin that can register custom handlers to process LTI messages
| 2.7+
|-
| [[File Converters]]
| fileconverter
| /files/converter
| Allow conversion between different types of user-submitted file. For example from .doc to PDF.
| 3.2+
|-
| [[LTI services]]
| ltiservice
| /mod/lti/service
| Allows the implementation of LTI services as described by the IMS LTI specification
| 2.8+
|-
| [[Machine learning backends]]
| mlbackend
| /lib/mlbackend
| Prediction processors for analytics API
| 3.4+
|-
| [[Forum reports]]
| forumreport
| /mod/forum/report
| Display various reports in the forum activity
| 3.8+
|-
| [[Quiz reports]]
| quiz
| /mod/quiz/report
| Display and analyse the results of quizzes, or just plug miscellaneous behaviour into the quiz module
| 1.1+
|-
| [[Quiz access rules]]
| quizaccess
| /mod/quiz/accessrule
| Add conditions to when or where quizzes can be attempted, for example only from some IP addresses, or student must enter a password first
| 2.2+
|-
| [[SCORM reports]]
| scormreport
| /mod/scorm/report
| Analysis of SCORM attempts
| 2.2+
|-
| [[Workshop grading strategies]]
| workshopform
| /mod/workshop/form
| Define the type of the grading form and implement the calculation of the grade for submission in the [[Workshop]] module
| 2.0+
|-
| [[Workshop allocation methods]]
| workshopallocation
| /mod/workshop/allocation
| Define ways how submissions are assigned for assessment in the [[Workshop]] module
| 2.0+
|-
| [[Workshop evaluation methods]]
| workshopeval
| /mod/workshop/eval
| Implement the calculation of the grade for assessment (grading grade) in the [[Workshop]] module
| 2.0+
|-
| [[Blocks]]
| block
| /blocks
| Small information-displays or tools that can be moved around pages
| 2.0+
|-
| [[Question types]]
| qtype
| /question/type
| Different types of question (e.g. multiple-choice, drag-and-drop) that can be used in quizzes and other activities
| 1.6+
|-
| [[Question behaviours]]
| qbehaviour
| /question/behaviour
| Control how student interact with questions during an attempt
| 2.1+
|-
| [[Question formats|Question import/export formats]]
| qformat
| /question/format
| Import and export question definitions to/from the question bank
| 1.6+
|-
| [[Filters|Text filters]]
| filter
| /filter
| Automatically convert, highlight, and transmogrify text posted into Moodle.
| 1.4+
|-
|-
| [[Editors]]
| [[Editors]]
Line 87: Line 162:
| Alternative text editors for editing content
| Alternative text editors for editing content
| 2.0+
| 2.0+
|-
| [[Atto|Atto editor plugins]]
| atto
| /lib/editor/atto/plugins
| Extra functionality for the Atto text editor
| 2.7+
|-
| [[TinyMCE editor plugins]]
| tinymce
| /lib/editor/tinymce/plugins
| Extra functionality for the TinyMCE text editor.
| 2.4+
|-
|-
| [[Enrolment plugins]]
| [[Enrolment plugins]]
Line 94: Line 181:
| 2.0+
| 2.0+
|-
|-
| [[Filters]]
| [[Authentication plugins]]
| filter
| auth
| /filter
| /auth
| Automatically convert, highlight, and transmogrify text posted into Moodle.
| Allows connection to external sources of authentication
| 1.4+
| 2.0+
|-
| [[Admin tools]]
| tool
| /admin/tool
| Provides utility scripts useful for various site administration and maintenance tasks
| 2.2+
|-
| [[Log stores]]
| logstore
| /admin/tool/log/store
| Event logs storage back-ends
| 2.7+
|-
| [[Availability conditions]]
| availability
| /availability/condition
| Conditions to restrict user access to activities and sections.
| 2.7+
|-
| [[Calendar types]]
| calendartype
| /calendar/type
| Defines how dates are displayed throughout Moodle
| 2.6+
|-
| [[Messaging consumers]]
| message
| /message/output
| Represent various targets where messages and notifications can be sent to (email, sms, jabber, ...)
| 2.0+
|-
| [[Course formats]]
| format
| /course/format
| Different ways of laying out the activities and blocks in a course
| 1.3+
|-
| [[Data formats]]
| dataformat
| /dataformat
| Formats for data exporting and downloading
| 3.1+
|-
| [[User profile fields]]
| profilefield
| /user/profile/field
| Add new types of data to user profiles
| 1.9+
|-
| [[Reports]]
| report
| /report
| Provides useful views of data in a Moodle site for admins and teachers
| 2.2+
|-
| [[Course reports]]
| coursereport
| /course/report
| Reports of activity within the course
| Up to 2.1 (for 2.2+ see [[Reports]])
|-
|-
| [[Gradebook export]]
| [[Gradebook export]]
Line 118: Line 265:
| 1.9+
| 1.9+
|-
|-
| [[Grading methods]]
| [[Grading methods|Advanced grading methods]]
| gradingform
| gradingform
| /grade/grading/form
| /grade/grading/form
| Interfaces for actually performing grading in activity modules (eg Rubrics).
| Interfaces for actually performing grading in activity modules (eg Rubrics)
| 2.2+
| 2.2+
|-
|-
| [[Local plugins]]
| [[MNet services]]
| local
| mnetservice
| /local
| /mnet/service
| Generic plugins for local customisations
| Allows to implement remote services for the [[MNet]] environment (deprecated, use web services instead)
| 2.0+
| 2.0+
|-
|-
| [[Messaging consumers]]
| [[Webservice protocols]]
| message
| webservice
| /message/output
| /webservice
| Send messages to users via different methods (email, sms, jabber, etc)
| Define new protocols for web service communication (such as SOAP, XML-RPC, JSON, REST ...)
| 2.0+
| 2.0+
|-
|-
| [[Plagiarism plugins]]
| [[Repository plugins]]
| plagiarism
| repository
| /plagiarism
| /repository
| Define external services to process submitted files and content
| Connect to external sources of files to use in Moodle
| 2.0+
| 2.0+
|-
|-
Line 148: Line 295:
| 1.9+
| 1.9+
|-
|-
| [[Question behaviours]]
| [[Search engines]]
| qbehaviour
| search
| /question/behaviour
| /search/engine
| Control how student interact with questions during an attempt
| Search engine backends to index Moodle's contents.
| 2.1+
| 3.1+
|-
|-
| [[Question formats]]
| [[Media players]]
| qformat
| media
| /question/format
| /media/player
| Import and export question definitions to/from the question bank
| Pluggable media players
| 1.6+
| 3.2+
|-
|-
| [[Question types]]
| [[Plagiarism plugins]]
| qtype
| plagiarism
| /question/type
| /plagiarism
| Different types of question (e.g. multiple-choice, drag-and-drop) that can be used in quizzes and other activities
| Define external services to process submitted files and content
| 1.6+
| 2.0+
|-
|-
| [[Quiz access rules]]
| [[Cache store]]
| quizaccess
| cachestore
| /mod/quiz/accessrule
| /cache/stores
| Add conditions to when or where quizzes can be attempted, for example only from some IP addresses, or student must enter a password first
| Cache storage back-ends.
| 2.2+
| 2.4+
|-
|-
| [[Quiz reports]]
| [[Cache locks]]
| quiz
| cachelock
| /mod/quiz/report
| /cache/locks
| Display and analyse the results of quizzes, or just plug miscellaneous behaviour into the quiz module
| Cache lock implementations.
| 1.1+
| 2.4+
|-
| [[Reports]]
| report
| /report
| Provides useful views of data in a Moodle site for admins and teachers
| 2.2+
|-
| [[Repository plugins]]
| repository
| /repository
| Connect to external sources of files to use in Moodle
| 2.0+
|-
| [[SCORM reports]]
| scormreport
| /mod/scorm/report
| Analysis of SCORM attempts
| 2.2+
|-
|-
| [[Themes]]
| [[Themes]]
| theme
| theme
| /theme
| /theme
| Change the look of Moodle by changing the the HTML and the CSS.  See also [[Themes 1.9]].
| Change the look of Moodle by changing the the HTML and the CSS.  
| 2.0+
| 2.0+
|-
|-
| [[User profile fields]]
| [[Local plugins]]
| profilefield
| local
| /user/profile/field
| /local
| Add new types of data to user profiles
| Generic plugins for local customisations
| 1.9+
| 2.0+
|-
|-
| [[Webservice protocols]]
| [[Assignment types|Legacy assignment types]]
| webservice
| assignment
| /webservice
| /mod/assignment/type
| Define new protocols for web service communication (such as SOAP, XML-RPC, JSON, REST ...)
| Different forms of assignments to be graded by teachers
| 2.0+
| 1.x - 2.2
|-
|-
| [[Workshop allocation methods]]
| [[Admin reports|Legacy admin reports]]
| workshopallocation
| report
| /mod/workshop/allocation
| /admin/report
| Define ways how submissions are assigned for assessment in the [[Workshop]] module
| Provides useful views of data in a Moodle site, for admins only.
| 2.0+
| Up to 2.1 (for 2.2+ see [[Reports]])
|-
|-
| [[Workshop evaluation methods]]
| [[Content bank content types]]
| workshopeval
| contenttype
| /mod/workshop/eval
| /contentbank/contenttype
| Implement the calculation of the grade for assessment (grading grade) in the [[Workshop]] module
| Content types to upload, create or edit in the content bank and use all over the Moodle site
| 2.0+
| 3.9+
|-
|-
| [[Workshop grading strategies]]
| [[H5P libraries]]
| workshopform
| h5plib
| /mod/workshop/form
| /h5p/h5plib
| Define the type of the grading form and implement the calculation of the grade for submission in the [[Workshop]] module
| Plugin type for the particular versions of the H5P integration library.
| 2.0+
| 3.9+
|}
|}


== Obtaining the list of plugin types known to your Moodle ==
To get the most exact list of types in your version of Moodle, use the following script. Put it to a file in the root directory of your Moodle installation and execute it via command line.


PRO TIP:  You can get the most exact list of types in your version of Moodle with the following script:
<code php>
<code php>
<?php                                                                                                      
<?php
define('CLI_SCRIPT', true);
define('CLI_SCRIPT', true);
require('path/to/config.php'); // global moodle config file.
require('config.php');
print_object(get_plugin_types());
 
$pluginman = core_plugin_manager::instance();
 
foreach ($pluginman->get_plugin_types() as $type => $dir) {
    $dir = substr($dir, strlen($CFG->dirroot));
    printf("%-20s %-50s %s".PHP_EOL, $type, $pluginman->plugintype_name_plural($type), $dir);
}
</code>
</code>


==Things you can find in all plugins==
Although there are many different types of plugin, there are some things that work the same way in all plugin types. Please see [[Plugin files]] page that describes things that work the same in all plugin types.
== Naming conventions ==
Warning if you have to choose a plugin (directory) name. The name is validated by the method <tt>lib/classes/component.php::is_valid_plugin_name()</tt> with a regexp: <tt>/^[a-z](?:[a-z0-9_](?!__))*[a-z0-9]+$/</tt>. In particular, the minus (-) character is not considered as valid, and the plugin will be silently ignored if the name is not valid.


There is an exception for [[Activity modules|activity modules]] that can not have the underscore in their name for legacy reasons.


== See also ==


==See also==
* [[Guidelines_for_contributed_code|Guidelines for contributing code]]
* [[Guidelines_for_contributed_code|Guidelines for contributing code]]
* [[Core APIs]]
* [[Core APIs]]
* [[Frankenstyle]]
* [[Frankenstyle]]
* [http://moodle.org/plugins Moodle Plugins database] - lists all the modules that people have contributed
* [http://moodle.org/plugins Moodle Plugins directory]  
 
* [[Tutorial]] to help you learn how to write plugins for Moodle from start to finish, while showing you how to navigate the most important developer documentation along the way.


[[Category:Coding guidelines|Plugins]]
[[Category:Coding guidelines|Plugins]]
[[Category:Plugins]]
[[Category:Plugins]]

Revision as of 08:26, 16 July 2020


The M in Moodle stands for modular. The easiest and most maintainable way to add new functionality to Moodle is by writing one of these types of plugin.

List of Moodle plugin types

Plugin type Component name (Frankenstyle) Moodle path Description Moodle versions
Activity modules mod /mod Activity modules are essential types of plugins in Moodle as they provide activities in courses. For example: Forum, Quiz and Assignment. 1.0+
Antivirus plugins antivirus /lib/antivirus Antivirus scanner plugins provide functionality for virus scanning user uploaded files using third-party virus scanning tools in Moodle. For example: ClamAV. 3.1+
Assignment submission plugins assignsubmission /mod/assign/submission Different forms of assignment submissions 2.3+
Assignment feedback plugins assignfeedback /mod/assign/feedback Different forms of assignment feedbacks 2.3+
Book tools booktool /mod/book/tool Small information-displays or tools that can be moved around pages 2.1+
Custom fields customfield /customfield/field Custom field types, used e. g. in Custom course fields 3.7+
Database fields datafield /mod/data/field Different types of data that may be added to the Database activity module 1.6+
Database presets datapreset /mod/data/preset Pre-defined templates for the Database activity module 1.6+
LTI sources ltisource /mod/lti/source LTI providers can be added to external tools easily through the external tools interface see Documentation on External Tools. This type of plugin is specific to LTI providers that need a plugin that can register custom handlers to process LTI messages 2.7+
File Converters fileconverter /files/converter Allow conversion between different types of user-submitted file. For example from .doc to PDF. 3.2+
LTI services ltiservice /mod/lti/service Allows the implementation of LTI services as described by the IMS LTI specification 2.8+
Machine learning backends mlbackend /lib/mlbackend Prediction processors for analytics API 3.4+
Forum reports forumreport /mod/forum/report Display various reports in the forum activity 3.8+
Quiz reports quiz /mod/quiz/report Display and analyse the results of quizzes, or just plug miscellaneous behaviour into the quiz module 1.1+
Quiz access rules quizaccess /mod/quiz/accessrule Add conditions to when or where quizzes can be attempted, for example only from some IP addresses, or student must enter a password first 2.2+
SCORM reports scormreport /mod/scorm/report Analysis of SCORM attempts 2.2+
Workshop grading strategies workshopform /mod/workshop/form Define the type of the grading form and implement the calculation of the grade for submission in the Workshop module 2.0+
Workshop allocation methods workshopallocation /mod/workshop/allocation Define ways how submissions are assigned for assessment in the Workshop module 2.0+
Workshop evaluation methods workshopeval /mod/workshop/eval Implement the calculation of the grade for assessment (grading grade) in the Workshop module 2.0+
Blocks block /blocks Small information-displays or tools that can be moved around pages 2.0+
Question types qtype /question/type Different types of question (e.g. multiple-choice, drag-and-drop) that can be used in quizzes and other activities 1.6+
Question behaviours qbehaviour /question/behaviour Control how student interact with questions during an attempt 2.1+
Question import/export formats qformat /question/format Import and export question definitions to/from the question bank 1.6+
Text filters filter /filter Automatically convert, highlight, and transmogrify text posted into Moodle. 1.4+
Editors editor /lib/editor Alternative text editors for editing content 2.0+
Atto editor plugins atto /lib/editor/atto/plugins Extra functionality for the Atto text editor 2.7+
TinyMCE editor plugins tinymce /lib/editor/tinymce/plugins Extra functionality for the TinyMCE text editor. 2.4+
Enrolment plugins enrol /enrol Ways to control who is enrolled in courses 2.0+
Authentication plugins auth /auth Allows connection to external sources of authentication 2.0+
Admin tools tool /admin/tool Provides utility scripts useful for various site administration and maintenance tasks 2.2+
Log stores logstore /admin/tool/log/store Event logs storage back-ends 2.7+
Availability conditions availability /availability/condition Conditions to restrict user access to activities and sections. 2.7+
Calendar types calendartype /calendar/type Defines how dates are displayed throughout Moodle 2.6+
Messaging consumers message /message/output Represent various targets where messages and notifications can be sent to (email, sms, jabber, ...) 2.0+
Course formats format /course/format Different ways of laying out the activities and blocks in a course 1.3+
Data formats dataformat /dataformat Formats for data exporting and downloading 3.1+
User profile fields profilefield /user/profile/field Add new types of data to user profiles 1.9+
Reports report /report Provides useful views of data in a Moodle site for admins and teachers 2.2+
Course reports coursereport /course/report Reports of activity within the course Up to 2.1 (for 2.2+ see Reports)
Gradebook export gradeexport /grade/export Export grades in various formats 1.9+
Gradebook import gradeimport /grade/import Import grades in various formats 1.9+
Gradebook reports gradereport /grade/report Display/edit grades in various layouts and reports 1.9+
Advanced grading methods gradingform /grade/grading/form Interfaces for actually performing grading in activity modules (eg Rubrics) 2.2+
MNet services mnetservice /mnet/service Allows to implement remote services for the MNet environment (deprecated, use web services instead) 2.0+
Webservice protocols webservice /webservice Define new protocols for web service communication (such as SOAP, XML-RPC, JSON, REST ...) 2.0+
Repository plugins repository /repository Connect to external sources of files to use in Moodle 2.0+
Portfolio plugins portfolio /portfolio Connect external portfolio services as destinations for users to store Moodle content 1.9+
Search engines search /search/engine Search engine backends to index Moodle's contents. 3.1+
Media players media /media/player Pluggable media players 3.2+
Plagiarism plugins plagiarism /plagiarism Define external services to process submitted files and content 2.0+
Cache store cachestore /cache/stores Cache storage back-ends. 2.4+
Cache locks cachelock /cache/locks Cache lock implementations. 2.4+
Themes theme /theme Change the look of Moodle by changing the the HTML and the CSS. 2.0+
Local plugins local /local Generic plugins for local customisations 2.0+
Legacy assignment types assignment /mod/assignment/type Different forms of assignments to be graded by teachers 1.x - 2.2
Legacy admin reports report /admin/report Provides useful views of data in a Moodle site, for admins only. Up to 2.1 (for 2.2+ see Reports)
Content bank content types contenttype /contentbank/contenttype Content types to upload, create or edit in the content bank and use all over the Moodle site 3.9+
H5P libraries h5plib /h5p/h5plib Plugin type for the particular versions of the H5P integration library. 3.9+

Obtaining the list of plugin types known to your Moodle

To get the most exact list of types in your version of Moodle, use the following script. Put it to a file in the root directory of your Moodle installation and execute it via command line.

<?php define('CLI_SCRIPT', true); require('config.php');

$pluginman = core_plugin_manager::instance();

foreach ($pluginman->get_plugin_types() as $type => $dir) {

   $dir = substr($dir, strlen($CFG->dirroot));
   printf("%-20s %-50s %s".PHP_EOL, $type, $pluginman->plugintype_name_plural($type), $dir);

}

Things you can find in all plugins

Although there are many different types of plugin, there are some things that work the same way in all plugin types. Please see Plugin files page that describes things that work the same in all plugin types.

Naming conventions

Warning if you have to choose a plugin (directory) name. The name is validated by the method lib/classes/component.php::is_valid_plugin_name() with a regexp: /^[a-z](?:[a-z0-9_](?!__))*[a-z0-9]+$/. In particular, the minus (-) character is not considered as valid, and the plugin will be silently ignored if the name is not valid.

There is an exception for activity modules that can not have the underscore in their name for legacy reasons.

See also