Dokeos programming tutorial
From Dokeos
Still to do: explain how to write a plugin.
Contents |
Install and experiment
As a first step, you should install Dokeos and experiment a little with it. Try to see it from different perspectives: as platform admin, as course admin / teacher / trainer, and as student / trainee. You can find user manuals in several languages on the dokeos website. The admin manual there is also interesting. Stay away from the developer manual though, because all its material is available on this wiki and more up to date, plus lots more stuff that never appeared in the manual.
You can find stable and beta releases on our sourceforge releases page or the dokeos.com download page. Developers are of course encouraged to live dangerously and download the latest code from our version control system (Subversion).
Learn PHP
If you don't know PHP, it's time to learn. Dokeos is written entirely in PHP. We also use MySQL as a database back-end, and our PHP code outputs html code with occassionaly some JavaScript. You'll find that PHP is not the cleanest language in existence, but it is not difficult to learn and you can develop in it very quickly.
There is a pretty good and simple tutorial at the php.net website that will help you get started. The rest of the manual there is also very good. And, the insanely succesful wikimedia project is not only producing an encyclopedia, but also a collection of free books, and yes there is a book on PHP.
We have a small list of common PHP mistakes.
History, evolution of Dokeos
For many programmers it will help to get some knowledge of the history of Dokeos.
Dokeos has grown a lot since its humble beginnings. The Dokeos community is visible at the Dokeos forum and at http://www.dokeos.com/community.php. Everyone using Dokeos is also free to create their own personal page on this wiki and/or list their name and organisation on the users page.
Agreements and guidelines
Being able to program and contribute code is not enough. You have to follow the same style of coding and developer agreements as all other developers, so all our code looks and acts the same. Consistency is key in building a maintainable application.
All Dokeos developers have to follow the Coding conventions. Learning how to use the CVS is also very important - it's a great tool once you get used to it.
Using the API
Before starting to program, check out the existing function libraries in the inc/lib/ folder. Try to use as much functions from the Dokeos API as you can, this can save you a lot of work, especially in the long run, when updating your code for new Dokeos versions, database changes...
We have started writing a page on Using the API.
We will start releasing API documentation soon, promise...
Plugins
Dokeos is improving in several ways to handle the need for people to extend its functionality. First, the API is getting larger and better organised, meaning that more functionality and database info can be reached by plugin developers in a predictable way, consistent with the standard code.
Second, there is a mechanism for showing small plugins in the right-hand menu of the start page, or at the top of the Dokeos banner. There will come a mechanism for easier adding of plugin tools too, but for now that requires some more effort. See also Writing an integrated plugin.
Third, there is now a new Extend Dokeos section on the Dokeos website dealing specifically with extensions - small scripts, new tools, stylesheets, icon packs... you can download existing extensions or create and upload your own!
Example tool plugins
This section is not complete yet.
As an example, let's take an existing php project and integrate this into Dokeos. We select phpWiki (uses a database) and pmwiki (does not use a database) for this.
Example other plugin
This section is not complete yet.
The cvs code now has an experimental new plugin system that just begs to be used for small new plugins. If people develop some interesting ones we can put them on our download pages. A search tool plugin is under development.
Good programming
Programming is not just writing, but also rewriting. The process of taking existing code and making small changes in it to make the code better (easier to read and maintain, better separation...) is called refactoring. And yes, we have several refactoring tips for you.
If you like to read, The Cathedral and the Bazaar is a great work about open source development.
Exercises
This section is only partially complete.
Easy exercises
- Use the plugin/template.php to create your own tool plugin
- save the file under another name, e.g. testplugin.php
- go to a course, then surf to (dokeos url)/claroline/plugin/testplugin.php
- add a link to this url on the course homepage
- modify the testplugin: echo some information to the screen, output a message using one of the display functions,...
- Write a simple plugin to display in the right-hand column of the index page
- Try to add a wiki to Dokeos, for example phpWiki (uses database) or pmwiki (uses files)
Moderate exercises
- Refactor an existing script: keep the functionality the same, but make the code cleaner. Read the page with Refactoring tips first.
Advanced exercises
- Implement an item of your choice from the dream map
- Visual database: try to create a new plugin that uses the statistics database but offers more detailed information and/or graphic tables...
- Deep hacking / API use: how would you integrate a more advanced forum with Dokeos? Describe what you try at this page.
- Deep hacking / API use: how would you integrate the Mediawiki - this is arguably the most advanced wiki software - with Dokeos?

