mahara development for moodle developers
Post on 09-May-2015
2.545 Views
Preview:
DESCRIPTION
TRANSCRIPT
Introduction Key Similarities Key Differences Other main components Plugin Types Code flow layout A typical Mahara Page Lets write some code!
Mahara Development for Moodle Developers
Penny Leach <penny@catalyst.net.nz>
MoodleMoot Barcelona
October 24 2008
Penny Leach <penny@catalyst.net.nz> MoodleMoot Barcelona
Mahara Development for Moodle Developers
Introduction Key Similarities Key Differences Other main components Plugin Types Code flow layout A typical Mahara Page Lets write some code!
1 IntroductionWhere the similarities come fromMahara’s General approach
2 Key SimilaritiesDML & XMLDBUpgradesLanguage Packsconfig.php
Penny Leach <penny@catalyst.net.nz> MoodleMoot Barcelona
Mahara Development for Moodle Developers
Introduction Key Similarities Key Differences Other main components Plugin Types Code flow layout A typical Mahara Page Lets write some code!
3 Key DifferencesDatabaseInput and OutputError handling and debuggingMiscellaneous differences
4 Other main componentsSignalling
5 Plugin TypesIntroduction to PluginsArtefact PluginsOther PluginsThemes
Penny Leach <penny@catalyst.net.nz> MoodleMoot Barcelona
Mahara Development for Moodle Developers
Introduction Key Similarities Key Differences Other main components Plugin Types Code flow layout A typical Mahara Page Lets write some code!
6 Code flow layout
7 A typical Mahara Page
Penny Leach <penny@catalyst.net.nz> MoodleMoot Barcelona
Mahara Development for Moodle Developers
Introduction Key Similarities Key Differences Other main components Plugin Types Code flow layout A typical Mahara Page Lets write some code!
1 IntroductionWhere the similarities come fromMahara’s General approach
2 Key Similarities
3 Key Differences
4 Other main components
5 Plugin Types
6 Code flow layout
7 A typical Mahara Page
8 Lets write some code!
Penny Leach <penny@catalyst.net.nz> MoodleMoot Barcelona
Mahara Development for Moodle Developers
Introduction Key Similarities Key Differences Other main components Plugin Types Code flow layout A typical Mahara Page Lets write some code!
Where the similarities come from
History
• A very rushed first 3 months• A lot of code taken from Moodle by me• Over time we diverged and broke compatibility
Penny Leach <penny@catalyst.net.nz> MoodleMoot Barcelona
Mahara Development for Moodle Developers
Introduction Key Similarities Key Differences Other main components Plugin Types Code flow layout A typical Mahara Page Lets write some code!
Mahara’s General approach
General approach
• PHP5 from the start• Much stricter approach• Much more OO and later PHP features.• For example, plugin definitions are all abstract classes
Penny Leach <penny@catalyst.net.nz> MoodleMoot Barcelona
Mahara Development for Moodle Developers
Introduction Key Similarities Key Differences Other main components Plugin Types Code flow layout A typical Mahara Page Lets write some code!
1 Introduction
2 Key SimilaritiesDML & XMLDBUpgradesLanguage Packsconfig.php
3 Key Differences
4 Other main components
5 Plugin Types
6 Code flow layout
7 A typical Mahara Page
8 Lets write some code!
Penny Leach <penny@catalyst.net.nz> MoodleMoot Barcelona
Mahara Development for Moodle Developers
Introduction Key Similarities Key Differences Other main components Plugin Types Code flow layout A typical Mahara Page Lets write some code!
DML & XMLDB
DDL & XMLDB
• No UI to generate XML or upgrade PHP• Learn the API and write it yourself• Learn the XML and write it yourself• Offset by removal of NEXT/PREV checking• Added some changes back into Moodle early on
Penny Leach <penny@catalyst.net.nz> MoodleMoot Barcelona
Mahara Development for Moodle Developers
Introduction Key Similarities Key Differences Other main components Plugin Types Code flow layout A typical Mahara Page Lets write some code!
Upgrades
Upgrades
• version.php and database version number• db/upgrade.php and db/install.xml as usual• Upgrades require administrative login• disablelogin & minupgradefrom
Penny Leach <penny@catalyst.net.nz> MoodleMoot Barcelona
Mahara Development for Moodle Developers
Introduction Key Similarities Key Differences Other main components Plugin Types Code flow layout A typical Mahara Page Lets write some code!
Language Packs
Language Packs
• get string
• $string array of keys to values• Use of sprintf and %s rather than eval and $a
• Slightly different get string function contract (variablearguments rather than one mixed argument)
• Helpfiles are more often automatically detected based onform element, page and section
Penny Leach <penny@catalyst.net.nz> MoodleMoot Barcelona
Mahara Development for Moodle Developers
Introduction Key Similarities Key Differences Other main components Plugin Types Code flow layout A typical Mahara Page Lets write some code!
config.php
config.php
• Very similar beginning - db details• docroot is detected• dataroot the same• wwwroot optional (detected but not perfect)
• Then divergence begins• One big difference:
• config.php• config-dist.php• config-defaults.php
Penny Leach <penny@catalyst.net.nz> MoodleMoot Barcelona
Mahara Development for Moodle Developers
Introduction Key Similarities Key Differences Other main components Plugin Types Code flow layout A typical Mahara Page Lets write some code!
1 Introduction
2 Key Similarities
3 Key DifferencesDatabaseInput and OutputError handling and debuggingMiscellaneous differences
4 Other main components
5 Plugin Types
6 Code flow layout
7 A typical Mahara Page
8 Lets write some code!
Penny Leach <penny@catalyst.net.nz> MoodleMoot Barcelona
Mahara Development for Moodle Developers
Introduction Key Similarities Key Differences Other main components Plugin Types Code flow layout A typical Mahara Page Lets write some code!
Database
DML
• Same starting point but a few divergences:• Prepared statements and placeholders (select * from{table} where field = ?)
• No get records anymore, get records array andget records assoc instead
• Some function contracts changed to suit $values arraybetween $sql and other things like $limit
• 138 lines of diff in grep function between Moodle andMahara but really it’s not that different
Penny Leach <penny@catalyst.net.nz> MoodleMoot Barcelona
Mahara Development for Moodle Developers
Introduction Key Similarities Key Differences Other main components Plugin Types Code flow layout A typical Mahara Page Lets write some code!
Database
More DB differences
• Referential Integrity - there in XMLDB but disabled inMoodle for now
• Proper date fields rather than integers• Much more use of transactions• No magic id field on every table
Penny Leach <penny@catalyst.net.nz> MoodleMoot Barcelona
Mahara Development for Moodle Developers
Introduction Key Similarities Key Differences Other main components Plugin Types Code flow layout A typical Mahara Page Lets write some code!
Input and Output
Forms
• Completely different to Moodle, they were developed aboutthe same time
• Pieforms, written by a Mahara developer, Nigel.• Maintained as a separate library on sourceforge• Array based form definitions with callback functions• Much simpler than QuickForms and easier to customise
Penny Leach <penny@catalyst.net.nz> MoodleMoot Barcelona
Mahara Development for Moodle Developers
Introduction Key Similarities Key Differences Other main components Plugin Types Code flow layout A typical Mahara Page Lets write some code!
Input and Output
Parameter Input
• Completely different approach• Moodle will clean parameters to match rules• Mahara will reject anything that doesn’t match• Moodle:
• $id = required param(’id’, PARAM INT);• $id = optional param(’id’, 0, PARAM INT);
• Mahara:• $id = param integer(’id’);• $id = param integer(’id’, 0);
Penny Leach <penny@catalyst.net.nz> MoodleMoot Barcelona
Mahara Development for Moodle Developers
Introduction Key Similarities Key Differences Other main components Plugin Types Code flow layout A typical Mahara Page Lets write some code!
Error handling and debugging
Error handling and debugging
• Exceptions from the start• Throw specifically, catch generally in most cases• Clearly defined Exception hierarchy, which defines the
handling of errors• Logging targets (screen/logs), could be more later (eg
email to developers)• Logging levels: debug, warn, environment
Penny Leach <penny@catalyst.net.nz> MoodleMoot Barcelona
Mahara Development for Moodle Developers
Introduction Key Similarities Key Differences Other main components Plugin Types Code flow layout A typical Mahara Page Lets write some code!
Miscellaneous differences
Cron
• Proper scheduler• Database example
Penny Leach <penny@catalyst.net.nz> MoodleMoot Barcelona
Mahara Development for Moodle Developers
Introduction Key Similarities Key Differences Other main components Plugin Types Code flow layout A typical Mahara Page Lets write some code!
Miscellaneous differences
Miscellaneous differences
• less use of globals - get config rather than global $CFG• Contentious - use of Smarty for templates• Mochikit rather than YUI
Penny Leach <penny@catalyst.net.nz> MoodleMoot Barcelona
Mahara Development for Moodle Developers
Introduction Key Similarities Key Differences Other main components Plugin Types Code flow layout A typical Mahara Page Lets write some code!
1 Introduction
2 Key Similarities
3 Key Differences
4 Other main componentsSignalling
5 Plugin Types
6 Code flow layout
7 A typical Mahara Page
8 Lets write some code!
Penny Leach <penny@catalyst.net.nz> MoodleMoot Barcelona
Mahara Development for Moodle Developers
Introduction Key Similarities Key Differences Other main components Plugin Types Code flow layout A typical Mahara Page Lets write some code!
Signalling
Event handling
• Similar to Moodle• handle event
• Core throws events, plugins can subscribe• They register which events they want at install/upgrade• Processed at cron
Penny Leach <penny@catalyst.net.nz> MoodleMoot Barcelona
Mahara Development for Moodle Developers
Introduction Key Similarities Key Differences Other main components Plugin Types Code flow layout A typical Mahara Page Lets write some code!
Signalling
Activity handling
• Like events, but for user activity• Eg, feedback on a view• activity occurred
• Notifies all relevant users
Penny Leach <penny@catalyst.net.nz> MoodleMoot Barcelona
Mahara Development for Moodle Developers
Introduction Key Similarities Key Differences Other main components Plugin Types Code flow layout A typical Mahara Page Lets write some code!
1 Introduction
2 Key Similarities
3 Key Differences
4 Other main components
5 Plugin TypesIntroduction to PluginsArtefact PluginsOther PluginsThemes
6 Code flow layout
7 A typical Mahara Page
8 Lets write some code!
Penny Leach <penny@catalyst.net.nz> MoodleMoot Barcelona
Mahara Development for Moodle Developers
Introduction Key Similarities Key Differences Other main components Plugin Types Code flow layout A typical Mahara Page Lets write some code!
Introduction to Plugins
Introduction to Plugins
• Registers at installation time:• Cronjobs• Event subscriptions
• Also exports config form• Exactly the same way to install and upgrade as Moodle
Penny Leach <penny@catalyst.net.nz> MoodleMoot Barcelona
Mahara Development for Moodle Developers
Introduction Key Similarities Key Differences Other main components Plugin Types Code flow layout A typical Mahara Page Lets write some code!
Introduction to Plugins
The Plugin base class
• get cron
• get event subscriptions
• postinst
• has config
• get activity types
• Subtypes can enforce their own abstract methods
Penny Leach <penny@catalyst.net.nz> MoodleMoot Barcelona
Mahara Development for Moodle Developers
Introduction Key Similarities Key Differences Other main components Plugin Types Code flow layout A typical Mahara Page Lets write some code!
Artefact Plugins
Artefact
• Richest plugin type• Two new classes
• PluginArtefact• get artefact types
• get block types
• get plugin name
• menu items
• group tabs
• ArtefactType• get icon
• is singular
• public feedback allowed
• has config
Penny Leach <penny@catalyst.net.nz> MoodleMoot Barcelona
Mahara Development for Moodle Developers
Introduction Key Similarities Key Differences Other main components Plugin Types Code flow layout A typical Mahara Page Lets write some code!
Artefact Plugins
More on Artefacts
• Generally plugins will write a new ArtefactType base class• Example: artefact plugin Foo will make PluginArtefactFoo
and ArtefactTypeFoo• For each artefact type that get artefact types returns,
ArtefactTypeFoo subclass• Should be fairly obvious that the API is quite flexible
Penny Leach <penny@catalyst.net.nz> MoodleMoot Barcelona
Mahara Development for Moodle Developers
Introduction Key Similarities Key Differences Other main components Plugin Types Code flow layout A typical Mahara Page Lets write some code!
Other Plugins
Blocktype
• Blocktypes define how artefacts are displayed in a view• Probably the most simple Mahara plugin• We’ll have a go at writing one this afternoon• Bound to either an artefact plugin or ’system’ level
Penny Leach <penny@catalyst.net.nz> MoodleMoot Barcelona
Mahara Development for Moodle Developers
Introduction Key Similarities Key Differences Other main components Plugin Types Code flow layout A typical Mahara Page Lets write some code!
Other Plugins
Blocktype classes
• New subclass: PluginBlocktype extends Plugin
• single only
• get title
• get description
• get categories
• get viewtypes
• render instance
• artefactchooser element
• ... more
Penny Leach <penny@catalyst.net.nz> MoodleMoot Barcelona
Mahara Development for Moodle Developers
Introduction Key Similarities Key Differences Other main components Plugin Types Code flow layout A typical Mahara Page Lets write some code!
Other Plugins
Notification
• PluginNotification extends Plugin
• one new method: notify user
• Current: internal messages, email, emaildigest• Could be: jabber plugin, for example
Penny Leach <penny@catalyst.net.nz> MoodleMoot Barcelona
Mahara Development for Moodle Developers
Introduction Key Similarities Key Differences Other main components Plugin Types Code flow layout A typical Mahara Page Lets write some code!
Other Plugins
Interaction
• Used for adding things like Forums to Groups• Two new subclass:• PluginInteraction extends Plugin
• instance config form• instance config save
• InteractionInstance• get plugin• interaction remove user
Penny Leach <penny@catalyst.net.nz> MoodleMoot Barcelona
Mahara Development for Moodle Developers
Introduction Key Similarities Key Differences Other main components Plugin Types Code flow layout A typical Mahara Page Lets write some code!
Other Plugins
Other plugins
• Authentication - internal, ldap, xmlrpc (MNET), imap• Search - internal (sql), solr• Grouptype - standard, course
Penny Leach <penny@catalyst.net.nz> MoodleMoot Barcelona
Mahara Development for Moodle Developers
Introduction Key Similarities Key Differences Other main components Plugin Types Code flow layout A typical Mahara Page Lets write some code!
Themes
Themes
• theme directory contains:• config.php - parent theme, theme name• static - stylesheets, images• templates - smarty templates
Penny Leach <penny@catalyst.net.nz> MoodleMoot Barcelona
Mahara Development for Moodle Developers
Introduction Key Similarities Key Differences Other main components Plugin Types Code flow layout A typical Mahara Page Lets write some code!
1 Introduction
2 Key Similarities
3 Key Differences
4 Other main components
5 Plugin Types
6 Code flow layout
7 A typical Mahara Page
8 Lets write some code!
Penny Leach <penny@catalyst.net.nz> MoodleMoot Barcelona
Mahara Development for Moodle Developers
Introduction Key Similarities Key Differences Other main components Plugin Types Code flow layout A typical Mahara Page Lets write some code!
Layout
• Switch to code
Penny Leach <penny@catalyst.net.nz> MoodleMoot Barcelona
Mahara Development for Moodle Developers
Introduction Key Similarities Key Differences Other main components Plugin Types Code flow layout A typical Mahara Page Lets write some code!
1 Introduction
2 Key Similarities
3 Key Differences
4 Other main components
5 Plugin Types
6 Code flow layout
7 A typical Mahara Page
8 Lets write some code!
Penny Leach <penny@catalyst.net.nz> MoodleMoot Barcelona
Mahara Development for Moodle Developers
Introduction Key Similarities Key Differences Other main components Plugin Types Code flow layout A typical Mahara Page Lets write some code!
A typical Mahara Page
• Switch to code
Penny Leach <penny@catalyst.net.nz> MoodleMoot Barcelona
Mahara Development for Moodle Developers
Introduction Key Similarities Key Differences Other main components Plugin Types Code flow layout A typical Mahara Page Lets write some code!
1 Introduction
2 Key Similarities
3 Key Differences
4 Other main components
5 Plugin Types
6 Code flow layout
7 A typical Mahara Page
8 Lets write some code!Ideas?
Penny Leach <penny@catalyst.net.nz> MoodleMoot Barcelona
Mahara Development for Moodle Developers
Introduction Key Similarities Key Differences Other main components Plugin Types Code flow layout A typical Mahara Page Lets write some code!
Ideas?
Ideas?
• Themes• Blocktypes
• Twitter• Last.fm• Dopplr• Facebook• Flickr
Penny Leach <penny@catalyst.net.nz> MoodleMoot Barcelona
Mahara Development for Moodle Developers
top related