Or: How I Learned to Stop Worrying and Love Creating Claroline Modulesby Frédéric MinneInstitut de pédagogie universitaire et desmultimédiasUCL - Belgique
- 1. Zen and the Art ofClaroline Module Development
-
- Or: How I Learned to Stop Worrying and Love CreatingClaroline
Modules
Frdric Minne Institut de pdagogie universitaire et des
multimdias UCL - Belgique 2. Goal of this talk
- Take a look at the module architecture of Claroline
- Explain how to create a Module using the Claroline Module
API
- See how module development can be made simpler using the
embed.lib
- Take a look at the future and improvements of Claroline
modules
3. Modules in Claroline
4. Why modules in Claroline ?
- To enhance Claroline modularity
-
- To decouple the kernel and the tools (development and
release)
-
- To allow building la carte Claroline distributions
-
- To help the distribution of home-made tools
- To help developers to create new tools
5. What is a Claroline Module ? (functional view)
- A business unit that could be
-
-
- Adds some functionnalities to existing pages
-
-
- Displays output in reserved zone called docks
-
-
- A bigger piece of script that adds a new tool to Claroline
-
-
- Could be accessed through the tool list of a course
6. What is a Claroline Module ? (technical view)
- A package containing a set of files
-
-
- manifest.xml , describes the module
-
-
- entry.php , the entry point of the module
7. Creating Modules for Claroline
-
- A (not so) short tutorial
8. The (mandatory) Hello World Module
9. How does this script work ? 10. How does this script work
?
- First the script initialises and call the Claroline Kernel to
set session variables, check access rights, load libraries, load
lang and config...
- Then the script executes its business logic to produce the data
that will be used in display
- The Kernel is called to display Claroline header and
banner
- The script displays its output
- The Kernel is called to display Claroline footer
11. Write the module manifest (1)
- The module manifest contains the data needed to install and run
the module
-
- Module Label, module unique identifier
-
- Module Type, applet or tool
12. Write the module manifest (2)
- Other optional data could be added
-
- Module author data (website, email,...)
- The manifest is written in XML
13. Write the module manifest (3)
-
- The content of manifest.xml :
-
- < name > Hello World name >
-
- < description > a really useful tool description
>
-
- < version > 0.1 version >
-
- < email > [email_address] email >
-
- < web > http://me.mydomain.net/HELLO web >
14. Let's make the package and install the tool(with a demo)
- Create a zip archive hello_tool.zip containing
- Go to Administration > Platform > Modules
- Click the 'Install module' link and choose the hello_tool.zip
package
- Test the module in a course
15. It's Alive, Alive !!!!(The Mad Claroline Developer) 16.
Write your first applet
- An applet is a small piece of code
-
- But some applets could have an associated tool-like script
- Applets can output some data in reserved zones called
docks
-
- the manifest SHOULD include the definition of a default
dock
- Applets use a buffer to generate their output
17. The Hello World Applet
-
- < name > Hello World name >
-
- < description > Hello Applet description >
-
- < default_dock > userBannerRight default_dock >
18. Let's test this tremendous applet(with a demo)
- Create a zip archive hello_applet.zip containing
- Go to Administration > Platform > Modules
- Click the 'Install module' link and choose the hello_tool.zip
package
- The text Hello World ! appears in user banner
19. It's Alive, Alive !!!!(The Return of the Mad Claroline
Developer) 20. Using Claroline API to enhance the Hello World tool
(1)
- We want to personalize the message for each user
- We will use Claroline API functions to
-
- Control the tool workflow
-
- l10n / i18n messages using get_lang
21. Using Claroline API to enhance the Hello World tool (2)
-
- New version of the business logic in entry.php:
-
- if(claro_is_user_authenticated () )
-
- get_lang ( " Hello %firstName% %lastName% ! "
-
- ,array ( ' %firstName% '=>
-
- claro_get_current_user_data ('firstName'),' %lastName%
'=>
-
- claro_get_current_user_data ('lastName') )
-
- $sayhello=get_lang ( " Hello dear visitor ! " );
22. It's Alive, Alive !!!!(Oh no, not the Mad Claroline
Developer again) 23. Let's use the database to store data about
users
- Display the last date a user access to our module
-
- Create the database using the module setup scripts
-
- Use the module API to access the database tables
-
- Store and retrieve the data using Claroline SQL functions to
show the last script access date to a registered user
24. The module setup scripts
- The module setup contains :
-
- Main database SQL setup scripts :
-
-
- install.sql : sql script run at module install, typically for
database tables creation
-
-
- uninstall.sql : sql script run at module uninstall, typically
for tables deletion
-
- Course database SQL setup scripts run :
-
-
- course_install.sql : to install the module in a course
-
-
- course_uninstall.sql : run at course deletion
25. Main database SQL setup script for the Hello World !
module
-
- Create a table using install.sql :
-
- CREATE TABLEIF NOT EXISTS
-
- ` __CL_MAIN__ hello_user_access`(
-
- userIdint(11) unsigned not null,
-
- accessDatetimestamp not null default now(),
-
- Drop the table with uninstall.sql:
-
- ` __CL_MAIN__ hello_user_access` ;
26. Let's add database access code and test the module
- Use get_module_main_tbl to get the module table names
- Use claro_sql_query to create or update the last access date
associated with the current user
- Use claro_sql_query to get the last access date associated with
the current user
27. It's Alive, Alive !!!!(The revenge of the Mad Claroline
Developer) 28. Using course databases instead of main (central)
databases
- Write course setup scripts :
-
- using __CL_COURSE__ instead of __CL_MAIN__
- Call install_module_in_course
-
- module label of the current module
-
- claro_get_current_course_id()
- Use get_module_course_tbl instead of get_module_main_tbl
29. Differences between main and course databases
-
- Setup scripts executed only once
-
- Data are shared over the platform
-
- You have to store course informations
-
- Install script executed at each access to the module, uninstall
script executed at course deletion
-
- Data are private to a course, not shared
-
- Course information stored in database schema
30. Embed your script output
-
- And make your scripts code simpler with embed.lib
31. Embedding your script output : Why ?
- No more need to include header and footer
- Make your source code clearer
- Easily convert an existing script into a Claroline module
32. Embedding your script output : How ?
- Use embed.lib that provides
-
- function claro_embed, to embed script output in Claroline
-
- class ClaroScriptEmbed, OOP version with methods to add extra
element and control display
- Use a buffer to store your script output
-
- PHP output buffering functions
- Pass the buffer contents to the function/object
33. Use embed.lib in our module entry point
34. It's Alive, Alive !!!!(Demo time with the Mad Claroline
Developer) 35. The Future of Claroline Modules
-
- Let's take a look at some potential improvements in the
Claroline module architecture
36. New and enhanced module types
- Enhance current module types
-
- Allow applet contextualization
-
- Shared libraries and drivers
-
- Administration, platform and other tools that run outside a
course
-
- Languages, Themes and Wysiwyg editors
37. Improved module setup
- Dependency checking and enforcement
- Version management and upgrade
- Kernel safe mode (no modules loaded) in case of platform
crash
- Course install by Kernel not by hand
- Split file uninstallation from data deletion
38. Tools to make developers happy
- Enhanced debugging facilities
- New embedding classes for HTML Frames and Framesets (already in
1.9), for Applets (decorators)...
39. Questions and (maybe) answers 40. Contact E-mail
:[email_address] Jabber :[email_address] On Claroline Forums or IRC
Channel