As we start to make an activity module, it's important to note that activity modules are inherently more complex than both blocks and filters. An activity module has roughly ten required PHP files, over a dozen functions, three sub folders, and an icon graphic. This is in sharp contrast to the other module types that we created in earlier chapters. Following is a listing of the structure of an empty activity module. We will flesh out each component of the listing as we progress through the chapter:
Included in this chapter's source code files is an empty template folder for starting a new activity module. The folder is named NEWMODULE.
Most new modules are created by using the NEWMODULE template, which is a contributed module. This means that the module is not part of the Moodle core distribution, but has been donated to the Moodle project under the same GPL. The module can be downloaded from http://moodle.org/mod/data/view.php?d=13&rid=715&filter=1. NEWMODULE is a useful starting point for creating our activity. However, it does miss a few important functional requirements. The most notable of these is the lack of backup and restore functionality. The code in this chapter, while based on NEWMODULE, also includes adapted components from other core modules, especially in places where NEWMODULE is incomplete. This method of examining the core code, as a way to learn how Moodle works, is common practice in the Moodle development community. In the next section, we will describe the features of the module that we will be creating in this chapter.