Note: You are currently viewing documentation for Moodle 3.3. Up-to-date documentation for the latest stable version of Moodle is probably available here: Modules and plugins replacement proposal.

Development:Modules and plugins replacement proposal

From MoodleDocs

Hi all before you get to excited this document is still under construction. Please bear with me while I create it and refrain from editing it. Also note there is a high chance things will change regually.

Creation of an alternative Modules and plugins database system. This is a design proposal for the system that will be created to replace the Modules and plugins database. Development of this system will be undertaken by Moodle HQ after this proposal has reached maturity.

The initial direction

The new system is to completely replace the current modules and plugins database, as well as the themes database. It has been decided that the new system will be a local plugin within Moodle. This gives us the advantage that we can both make use of the Moodle backend, as well as benefit from already having all of the user accounts, capabailities/permissions, and setup of Moodle.org for when this new system gets implemented. Because of this decision the new system will be making use of the Moodle API's whereever possible, this includes, comments, tags, if possible ratings (some improvements required) and of course the Moodle file API. Integration and reliance on these Moodle components will be documented within this proposal along with the database stucture, and screens that the system will consist of.

The following are the major design focuses for this new system:

Categorise contributed code
Categorisation of code based upon the type of the code, and perhaps for unspecific areas such as hacks categorisation based upon the nature of the code as well.
Track versions of contributed code
This will allow contributors to maintain multiple versions of thier code, hopefully better supporting the diversity of code between Moodle versions.
A trusted review system
A trusted review system consisting of both a general review and criteria based review for versions of contributed code.
Complete supported version tracking
Tracking of both major and minor release support by version of contributed code.
Full support for all types of contributed code
All native Moodle plugin types including theme's as well as core patches/hacks.
Improved user interaction
We hope to get users interacting more with contributors. Providing ratings, commenting, reiviewing, perhaps even contributing themselves.
Better search
The ability to easily search for plugins, and plugin versions, comments, and reviews.
More comprehensive reporting
Sortable, customisable reports for the an array of things within the new system.
Notification services and systems
Choose to be notified when there are new plugins, new versions, new reviews, and changes or any combination of.
Support for popular version control systems
Be able to link in to you projects git, cvs, or svn repository.
Statistics
Downloads, views, reviews, ratings, activity etc.
Awards
There will be awards for plugins that can be used for things such as showing the level of the plugin (gold, silver, bronze), or marking it was a status (featured).

Categorisation

Obvioulsy one of the big things that we want to achieve with this new system is proper categorisation of contributed code.

It would be great to be able to browse plugins by their category, search within a category, and view information organised/limited by category.

On top of this is tagging, the new system will support tagging pluggins so that we can further compartmentalise and then organise, limit, and view based upon this axis as well.

Plugins, plugin versions, and supported versions of Moodle

This new system will track not only plugins, but versions of plugins. Contributors will be able to create, or register a plugin with us and then as they continue to develope and maintain it release further versions as they desire.

When a new version for a plugin is created the contributor is able to enter detailed information at the version such as release notes, details about the VCS system used to manage the code, the previous version this version builds upon, and importantly the different versions of Moodle this plugin is designed to work with.

This is of course much more comrehensible than the information gathered by the current system where contributors update a plugin for each release and previous release information is lost.

Reviews and awards

Many people have asked for this functionality and we have listened, one of the major new features for this system will be reviews.

Reviewes will be completed by trusted people who are known to be knowledgable in Moodle development.

The reviewes themselves will consist of both a general review or the plugin as well as the review of specific criteria/ideals such as security, coding standard, usability, and documenation. The reviewer will then be able to rate each criteria, and of course the plugin as a whole.

In conjunction to this there will also be an awards system whereby when a plugin achieves notable goals it will be given awards to recognise this. This will in the initial release of the new system be a manual undertaking by an administrator.

Through the process of getting trusted reviews and awards we are again able to provide better recommendations and direction to our users.

Version controll systems and downloads

Reporting and nofitications

Database structure

The following is the puposed database structure for this new system.

local_contrib_plugin
id int (10) unsigned not null
categoryid int (10) unsigned not null
name varchar (255) not null The name of the plugin
shortdescription smalltext A short plain text description of the module
description mediumtext A complete description of the plugin
descriptionformat int(2) unsigned default 0 not null
websiteurl varchar (255) default NULL A url to a site/page about this plugin
sourcecontrolurl varchar (255) default NULL A url to a system being used to manage the source for this plugin
faqs mediumtext Frequently asked questions for/about this plugin
faqsformat int(2) unsigned default 0 not null
documentation mediumtext Documenation for/about this plugin
documentationformat int(2) unsigned default 0 not null
documentationurl varchar (255) default NULL A url to further documentation about this plugin
timecreated int (10) unsigned Time the plugin was created within out system
timelastmodified int (10) unsigned Last time the plugin or any of its versions were modified
approved int(1) unsigned default 0 not null Flag to track when this module was approved
available int(1) unsigned default 0 not null Toggle availablility of this module easily.


local_contrib_version
Tracks a version of a plugin
id int (10) unsigned not null
pluginid int (10) unsigned not null
previousversionid int (10) unsigned not null
nextversionid int (10) unsigned not null
version varchar(255)
name varchar(255)
releasenotes mediumtext
releasenotesformat int(2) unsigned default 0 not null
websiteurl varchar (255) default NULL A url to a site/page about this plugin version
altdownloadurl varchar (255) default NULL An alternative download location for this plugin version
vcssystem varchar (255) default NULL The version control system used to manage this version (git, cvs, svn)
vcsrepositoryurl varchar (255) default NULL The url to the VCS used to manage this plugin version
vcsbranch varchar (255) default NULL The branch for this version within the VCS
vcstag varchar (255) default NULL The tag for this version within the VCS
timecreated int (10) unsigned
timelastmodified int (10) unsigned
approved int(1) unsigned default 0 not null
available int(1) unsigned default 0 not null


local_contrib_category
Plugin categories
id int (10) unsigned not null
parentid int (10) unsigned not null
name varchar (255) not null The name of this category
shortdescription smalltext A short plain text description of this category
description mediumtext A full description of this category.
descriptionformat int(2) unsigned default 0 not null


local_contrib_contributor
Tracks the contributors to a project so that no one gets forgotten.
id int (10) unsigned not null
userid int (10) unsigned not null
pluginid int (10) unsigned not null
creator int(1) unsigned default 0
primary int(1) unsigned default 0
active int(1) unsigned default 1
timecreated int (10) unsigned not null


local_contrib_software_versions
Contains the different Moodle versions that a plugin version can support
id int (10) unsigned not null
name varchar(255)
version decimal (12,5) not null
timecreated int (10) unsigned not null


local_contrib_supported_versions
Maps a support Moodle version to a plugin
id int (10) unsigned not null
versionid int (10) unsigned not null
softwareversionid int (10) unsigned not null


local_contrib_review
Used to record plugin version reviews
id int (10) unsigned not null
userid int (10) unsigned not null
versionid int (10) unsigned not null
generalreview mediumtext
generalreviewformat int(2) unsigned default 0 not null


local_contrib_review_criteria
Contains the criteria a plugins versions should be reviewed on.
id int (10) unsigned not null
name varchar (255)
description mediumtext
descriptionformat int(2) unsigned default 0 not null
scaleid int (10) unsigned not null


local_contrib_review_outcome
Contains the outcome and comments of a reviewed criteria
id int (10) unsigned not null
name varchar (255)
description mediumtext
descriptionformat int(2) unsigned default 0 not null
scaleid int (10) unsigned not null


local_contrib_awards
Contains the different awards that can be granted to a plugin and/or plugin version
id int (10) unsigned not null
name varchar (255)
description mediumtext
descriptionformat int(2) unsigned default 0 not null


local_contrib_plugin_awards
Tracks the awards a plugin, or plugin version have been awarded
id int (10) unsigned not null
pluginid int (10) unsigned not null
versionid int (10) unsigned default NULL
timeawarded int (10) unsigned not null
userid int (10) unsigned not null

File areas

There are several file areas that will be used within this new system.

Please not this relies on changes to the core system in order to be possible, presently the file API doesn't support local plugins.

Type Contextid Component Filearea Itemid
Plugin badge Image [200x200] CONTEXT_SYSTEM local_contrib plugin_badge Plugin id
Plugin icon Image [16x16] CONTEXT_SYSTEM local_contrib plugin_icon Plugin id
Plugin screenshots Images 0..n CONTEXT_SYSTEM local_contrib plugin_screenshots Plugin version id
Review images Images 0..n CONTEXT_SYSTEM local_contrib review_images Review id
Award image Image [200x200] CONTEXT_SYSTEM local_contrib award_image Award id
Award icon Image [16x16] CONTEXT_SYSTEM local_contrib award_icon Award id

Capabilities

The following are the capabilities that this new local plugin will introduce and utilise.

Capability Type Description
local/contrib:view read View the system
local/contrib:viewunapproved read View unapproved plugins
local/contrib:createplugins write Create new plugins within the system
local/contrib:editownplugins write Edit plugins the user previously created
local/contrib:editanyplugin write Edit any plugins within the system
local/contrib:deleteownplugin write Delete a plugin you created
local/contrib:deleteanyplugin write Delete a plugin
local/contrib:deleteownpluginversion write Delete a plugin version you created
local/contrib:deleteanypluginversion write Delete a plugin version
local/contrib:approveplugin write Approve a plugin
local/contrib:approvepluginversion write Approve a plugin version
local/contrib:publishreviews write Create and publish a review
local/contrib:editownreview write Edit a review you created
local/contrib:editanyreview write Edit a review written by anyone
local/contrib:comment write Add a comment on a plugin, plugin version, or review
local/contrib:rate write Rate a plugin or plugin version
local/contrib:managesupportableversions write Manage supportable

Screen mockups

Navigation screens

The following are the navigation screens for the system, these are screens that will be readily accessible to those who are not logged in or have little or no permissions other than view.

The front page

A category view

Viewing a plugin

Viewing a version of a plugin

Reading a review

Downloading a version of a plugin

Plugin administration screens

Creating a plugin

Creating a plugin version

Adding plugin information

System administration screens

General settings

Managing categories

Managing Moodle versions

Managing awards

Managing supportable versions

Reports

Plugin report

Plugin approval report

Plugin version approval report

Recent activity

Requiring attention

Review report

Required core changes

One of the goals for this new system was to get it using the core Moodle systems where possible and practical. Presently this proposal relies of several changes been made to core systems in order to get them into a usable state by this plugin. While I understand it is not desirable to have to make core changes I do think that in all cases making these changes would be of general benefit anyway. In all cases I am happy to be responsible to for making the required changes.

Changes to the ratings API

Presently the ratings system is VERY limited. When a rating is stored is associated by a context and an item id. The problem with this of course is that it immediatly limits ratings to be applied to only one structure per context. In the case of this new system which is currently planned as a local plugin it is running under the system context which immediatly makes the rating system unusable. As part of the development of this new system I would like to purpose the following changes at the same time:

  1. Add two new columns to the rating table in the database that are similar to fields found in the file table
    • component (string 255) This is the frankenstyle name of the component the rating relates to e.g. mod_forum, local_contrib
    • ratingarea (string 255) This is a unique name that the utilisine component can use to allow several areas within a component to be rated e.g. for the forum you may have post, and discussion.
  2. Extend the API to require the two new fields but provide backwards compatability to working without them.
  3. Review all locations using the rating system presently and refactor to make use of these two new fields.

Add support for local plugins to use file API

Presently local plugins are unable to make use of the file API because there is no provisioning for them within pluginfile.php. I would like to see support added for files within local plugins in a similar way as to modules and blocks. I think that the following snippet of code would just about do the job: diff --git a/pluginfile.php b/pluginfile.php index 0ab8428..4e756b2 100644 --- a/pluginfile.php +++ b/pluginfile.php @@ -730,6 +730,25 @@ if ($component === 'blog') {

    }

    send_file_not_found();

+} else if (strpos($component, 'local_') === 0) { + $localpluginname = substr($component, 6); + + if ($context->contextlevel != CONTEXT_SYSTEM) { + // local plugins can only exist within the system context + send_file_not_found(); + } + + $libfile = "$CFG->dirroot/local/$localpluginname/lib.php"; + if (!file_exists($libfile)) { + send_file_not_found(); + } + require_once($libfile); + + $function = $compontent.'_pluginfile'; + if (function_exists($function)) { + $function($filearea, $args, $forcedownload); + } + send_file_not_found();

} else if (strpos($component, '_') === false) {
    // all core subsystems have to be specified above, no more guessing here!

This would require local plugins to define a method such as local_contrib_pluginfile in order to handle files.

More information