Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Mahara Development for Moodle Developers

3,018 views

Published on

Workshop by Penny Leach at the MoodleMoot Barcelona 2008 on 24 October 2008

Published in: Education
  • Be the first to comment

  • Be the first to like this

Mahara Development for Moodle Developers

  1. 1. Introduction Key Similarities Key Differences Other main components Plugin Types Code flow layout A typical Mahara Page 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
  2. 2. Introduction Key Similarities Key Differences Other main components Plugin Types Code flow layout A typical Mahara Page 1 Introduction Where the similarities come from Mahara’s General approach 2 Key Similarities DML & XMLDB Upgrades Language Packs config.php Penny Leach <penny@catalyst.net.nz> MoodleMoot Barcelona Mahara Development for Moodle Developers
  3. 3. Introduction Key Similarities Key Differences Other main components Plugin Types Code flow layout A typical Mahara Page 3 Key Differences Database Input and Output Error handling and debugging Miscellaneous differences 4 Other main components Signalling 5 Plugin Types Introduction to Plugins Artefact Plugins Other Plugins Themes Penny Leach <penny@catalyst.net.nz> MoodleMoot Barcelona Mahara Development for Moodle Developers
  4. 4. Introduction Key Similarities Key Differences Other main components Plugin Types Code flow layout A typical Mahara Page 6 Code flow layout 7 A typical Mahara Page Penny Leach <penny@catalyst.net.nz> MoodleMoot Barcelona Mahara Development for Moodle Developers
  5. 5. Introduction Key Similarities Key Differences Other main components Plugin Types Code flow layout A typical Mahara Page 1 Introduction Where the similarities come from Mahara’s General approach 2 Key Similarities 3 Key Differences 4 Other main components 5 Plugin Types 6 Code flow layout Penny Leach <penny@catalyst.net.nz> MoodleMoot Barcelona Mahara Development for Moodle Developers
  6. 6. Introduction Key Similarities Key Differences Other main components Plugin Types Code flow layout A typical Mahara Page 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
  7. 7. Introduction Key Similarities Key Differences Other main components Plugin Types Code flow layout A typical Mahara Page 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
  8. 8. Introduction Key Similarities Key Differences Other main components Plugin Types Code flow layout A typical Mahara Page 1 Introduction 2 Key Similarities DML & XMLDB Upgrades Language Packs config.php 3 Key Differences 4 Other main components 5 Plugin Types Penny Leach <penny@catalyst.net.nz> MoodleMoot Barcelona Mahara6 Code flow layout Development for Moodle Developers
  9. 9. Introduction Key Similarities Key Differences Other main components Plugin Types Code flow layout A typical Mahara Page 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
  10. 10. Introduction Key Similarities Key Differences Other main components Plugin Types Code flow layout A typical Mahara Page 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
  11. 11. Introduction Key Similarities Key Differences Other main components Plugin Types Code flow layout A typical Mahara Page 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 (variable arguments rather than one mixed argument) • Helpfiles are more often automatically detected based on form element, page and section Penny Leach <penny@catalyst.net.nz> MoodleMoot Barcelona Mahara Development for Moodle Developers
  12. 12. Introduction Key Similarities Key Differences Other main components Plugin Types Code flow layout A typical Mahara Page 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
  13. 13. Introduction Key Similarities Key Differences Other main components Plugin Types Code flow layout A typical Mahara Page 1 Introduction 2 Key Similarities 3 Key Differences Database Input and Output Error handling and debugging Miscellaneous differences 4 Other main components 5 Plugin Types Penny Leach <penny@catalyst.net.nz> MoodleMoot Barcelona Mahara6 Code flow layout Development for Moodle Developers
  14. 14. Introduction Key Similarities Key Differences Other main components Plugin Types Code flow layout A typical Mahara Page 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 and get records assoc instead • Some function contracts changed to suit $values array between $sql and other things like $limit • 138 lines of diff in grep function between Moodle and Mahara but really it’s not that different Penny Leach <penny@catalyst.net.nz> MoodleMoot Barcelona Mahara Development for Moodle Developers
  15. 15. Introduction Key Similarities Key Differences Other main components Plugin Types Code flow layout A typical Mahara Page Database More DB differences • Referential Integrity - there in XMLDB but disabled in Moodle 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
  16. 16. Introduction Key Similarities Key Differences Other main components Plugin Types Code flow layout A typical Mahara Page Input and Output Forms • Completely different to Moodle, they were developed about the 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
  17. 17. Introduction Key Similarities Key Differences Other main components Plugin Types Code flow layout A typical Mahara Page 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
  18. 18. Introduction Key Similarities Key Differences Other main components Plugin Types Code flow layout A typical Mahara Page 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
  19. 19. Introduction Key Similarities Key Differences Other main components Plugin Types Code flow layout A typical Mahara Page Miscellaneous differences Cron • Proper scheduler • Database example Penny Leach <penny@catalyst.net.nz> MoodleMoot Barcelona Mahara Development for Moodle Developers
  20. 20. Introduction Key Similarities Key Differences Other main components Plugin Types Code flow layout A typical Mahara Page 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
  21. 21. Introduction Key Similarities Key Differences Other main components Plugin Types Code flow layout A typical Mahara Page 1 Introduction 2 Key Similarities 3 Key Differences 4 Other main components Signalling 5 Plugin Types 6 Code flow layout 7 A typical Mahara Page Penny Leach <penny@catalyst.net.nz> MoodleMoot Barcelona Mahara Development for Moodle Developers
  22. 22. Introduction Key Similarities Key Differences Other main components Plugin Types Code flow layout A typical Mahara Page 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
  23. 23. Introduction Key Similarities Key Differences Other main components Plugin Types Code flow layout A typical Mahara Page 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
  24. 24. Introduction Key Similarities Key Differences Other main components Plugin Types Code flow layout A typical Mahara Page 1 Introduction 2 Key Similarities 3 Key Differences 4 Other main components 5 Plugin Types Introduction to Plugins Artefact Plugins Other Plugins Themes Penny Leach <penny@catalyst.net.nz> MoodleMoot Barcelona Mahara6 Code flow layout Development for Moodle Developers
  25. 25. Introduction Key Similarities Key Differences Other main components Plugin Types Code flow layout A typical Mahara Page 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
  26. 26. Introduction Key Similarities Key Differences Other main components Plugin Types Code flow layout A typical Mahara Page 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
  27. 27. Introduction Key Similarities Key Differences Other main components Plugin Types Code flow layout A typical Mahara Page 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
  28. 28. Introduction Key Similarities Key Differences Other main components Plugin Types Code flow layout A typical Mahara Page 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
  29. 29. Introduction Key Similarities Key Differences Other main components Plugin Types Code flow layout A typical Mahara Page 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
  30. 30. Introduction Key Similarities Key Differences Other main components Plugin Types Code flow layout A typical Mahara Page 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
  31. 31. Introduction Key Similarities Key Differences Other main components Plugin Types Code flow layout A typical Mahara Page 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
  32. 32. Introduction Key Similarities Key Differences Other main components Plugin Types Code flow layout A typical Mahara Page 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
  33. 33. Introduction Key Similarities Key Differences Other main components Plugin Types Code flow layout A typical Mahara Page 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
  34. 34. Introduction Key Similarities Key Differences Other main components Plugin Types Code flow layout A typical Mahara Page 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
  35. 35. Introduction Key Similarities Key Differences Other main components Plugin Types Code flow layout A typical Mahara Page 1 Introduction 2 Key Similarities 3 Key Differences 4 Other main components 5 Plugin Types 6 Code flow layout 7 A typical Mahara Page Penny Leach <penny@catalyst.net.nz> MoodleMoot Barcelona Mahara Development for Moodle Developers
  36. 36. Introduction Key Similarities Key Differences Other main components Plugin Types Code flow layout A typical Mahara Page Layout • Switch to code Penny Leach <penny@catalyst.net.nz> MoodleMoot Barcelona Mahara Development for Moodle Developers
  37. 37. Introduction Key Similarities Key Differences Other main components Plugin Types Code flow layout A typical Mahara Page 1 Introduction 2 Key Similarities 3 Key Differences 4 Other main components 5 Plugin Types 6 Code flow layout 7 A typical Mahara Page Penny Leach <penny@catalyst.net.nz> MoodleMoot Barcelona Mahara Development for Moodle Developers
  38. 38. Introduction Key Similarities Key Differences Other main components Plugin Types Code flow layout A typical Mahara Page A typical Mahara Page • Switch to code Penny Leach <penny@catalyst.net.nz> MoodleMoot Barcelona Mahara Development for Moodle Developers
  39. 39. Introduction Key Similarities Key Differences Other main components Plugin Types Code flow layout A typical Mahara Page 1 Introduction 2 Key Similarities 3 Key Differences 4 Other main components 5 Plugin Types 6 Code flow layout 7 A typical Mahara Page Penny Leach <penny@catalyst.net.nz> MoodleMoot Barcelona Mahara Development for Moodle Developers
  40. 40. Introduction Key Similarities Key Differences Other main components Plugin Types Code flow layout A typical Mahara Page Ideas? Ideas? • Themes • Blocktypes • Twitter • Last.fm • Dopplr • Facebook • Flickr Penny Leach <penny@catalyst.net.nz> MoodleMoot Barcelona Mahara Development for Moodle Developers

×