GETTING STARTED



One of the challenges in Moodle development is finding a good starting point for creating a Moodle plug-in. I thought it would be cool to build a step-wise tutorial on the subject as I embark on a personal whim:

Building a Moodle Module that allows the Student to post their Moodle Forum posts to FaceBook, and elicits responses from their group of friends into a totally separate forum. Perhaps too ambitious for a first project, but it hits all of the major challenges.

I will start by coming up with a cool name for the plug-in. I am thinking of calling it InYourFace ?  This particular exercise will focus on building an activity module - a module that provides an activity that can be added to any Moodle course.

WHERE DO WE START?

NOTE: This tutorial assumes that you already have a working installation of Moodle 1.9.x available, and that you have at least one course installed in your Moodle instance.  It also assumes that you have some basic knowledge of PHP and MySQL.

Before we embark on writing our first Moodle module, let's download a template provided by the folks at Moodle.org. In our case, we will be writing our module for Moodle version 1.9.x:

Download Link for The Module Template for Moodle 1.9

We end up with a file called NEWMODULE.zip which we need to save to our local drive and unzip. In my case, I download to the Public folder, unzip the file and end up with .\Public\NEWMODULE.

NEXT ARTICLE IN SERIES

Wednesday, May 12, 2010

02MOD: Moodle Module Setup - Replacing the Module Name

TO START THE TUTORIAL FROM THE BEGINNING, CLICK HERE

After the install.xml file has been updated, it is time to update all references to NEWMODULE in the template, and replace them with our own module's name. In this case, we will replace all references to NEWMODULE to inyourface.



CHANGES TO FILES IN THE MODULE'S ROOT DIRECTORY

In all these cases, we will be searching for "newmodule" and replacing it with "inyourface"

1. Edit index.php
: For the Moodle 1.9 template, this file contains 23 references to the module name. A simple search & replace takes care of it.

2. Edit lib.php: Just like the index.php, a simple search & replace does the trick. There are 49 references to the module name in this file.

3. Edit mod_form.php: Same as above. Lather, rinse, repeat. There are 16 references to replace.

4, Edit view.php: There are 22 references to replace in this file.


CHANGES TO FILES IN THE .\lang\en_utf8 DIRECTORY


1. Rename file newmodule.php: This file should be renamed so it matches our module's name. In this case, I renamed it to inyourface.php

2. Edit the contents of the newly renamed file: Inside of the language file, all references to newmodule must be replaced with our module's name. There are 9 references to the module, but the variable $string['[MODULE]name'] should be replaced with whatever we would like Moodle to display to the end user. In our case, I have changed it to "Post to Facebook"

We are almost there. One more change . . .



CHANGES IN THE .\lang\en_utf8\help DIRECTORY

1. Rename the newmodule directory: Immediately below the \help directory, there is a single directory named newmodule. It needs to be renamed to our module's name. In our case, I renamed it to inyourface.

This directory will eventually hold all of the help files for our module. More on that later.



We are now ready to see whether our Module will be recognized by Moodle. Right now it doesn't do much of anything, but we'll beef it up once we are sure that we have made all of the right edits to the template

NEXT ARTICLE IN SERIES

No comments:

Post a Comment