Writing a dotLRN Package

Writing a dotLRN Package

by Ben Adida.

Writing a dotLRN package is a task that is meant to hook generic OpenACS 4 functionality into the framework of dotLRN communities. As much as possible, one should worry solely about that core functionality. As long as this functionality is made scopable as per the subsite approach in OpenACS 4, hooking into dotLRN is fairly straight-forward.

The Structure of a dotLRN Package/Applet

As far as dotLRN is concerned, a dotLRN package is an applet (literally a "small application," nothing to do with Java applets) that must provide a simple API under the acs-service-contract mechanism. This API allows the dotLRN core to generically dispatch calls to each dotLRN applet when certain events happen.

Thus, a dotLRN applet must be able to respond to the following events:

Additional events may be added in the future to further enhance generalized applet functionality.

Most dotLRN applets will want to offer an interface to their users (although it's very possible that some won't). To do so, the dotLRN core will use the New Portal Architecture of OpenACS 4. A dotLRN applet can simply add itself to the appropriate portal pages by providing an NPA portlet. Note that the architecture of this portlet is dotLRN-independent! The contents of the portlet may rely on dotLRN functionality, but the means by which the portlet is added to portal pages does not!

Also, it is highly recommended that functionality be added to dotLRN by first thinking of generic OpenACS 4 functionality, and eventually hooking it into the dotLRN core. Thus, a dotLRN package will be usually composed of three OpenACS 4 packages:

Core Functionality

There is only one guideline in writing core functionality for a dotLRN applet: make sure the package can be correctly scoped across multiple subsites. This means that any data should be scoped correctly to a particular package_id. Take a look at the standard bboard package for a clear way to do this.

Portlet

The portlet should be created in line with the New Portal Architecture. We want to strongly discourage developers from making this portlet package dependent on dotLRN functionality: portlets will be able to query parameter information from the NPA (such as the package_id), independently of any dotLRN functionality.

For more details on creating a portlet package, check the New Portals Architecture

dotLRN Applet

A dotLRN applet is simply the glue that responds to specific requests. Let's take the example of the bboard applet to better understand what's going on.

First, we will write the actual procs that we expect to eventually hook into the dotLRN system.

The first proc is called when the bboard applet is added to a community

ad_proc -public dotlrn_bboard::applet_add {community_id} {} {
	# Instantiate bboard and mount it
}